Skip to content

Commit

Permalink
Merge branch 'main' into migration-to-astral-docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Feb 26, 2024
2 parents e98adc2 + ad705d0 commit f43331e
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sync-python-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Sync latest Python releases"
add-paths: "rye/src/downloads.inc"
add-paths: "rye/src/sources/generated/python_downloads.inc"
branch: "sync-python-releases"
title: "Sync Python Releases"
body: |
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/sync-uv-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# For this action to work you must explicitly allow GitHub Actions to create pull requests.
# This setting can be found in a repository's settings under Actions > General > Workflow permissions.
# For repositories belonging to an organization, this setting can be managed by
# admins in organization settings under Actions > General > Workflow permissions.
name: Sync UV Releases
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

permissions:
contents: write
pull-requests: write

jobs:
sync:
if: github.repository == 'astral-sh/rye'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rye
uses: eifinger/setup-rye@v1
with:
enable-cache: true
- name: Sync UV Releases
run: make sync-uv-releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Sync latest Python releases"
add-paths: "rye/src/sources/generated/uv_downloads.inc"
branch: "sync-uv-releases"
title: "Sync UV Releases"
body: |
- Synced latest UV releases
<sup>Auto-generated by [sync-uv-releases.yml](https://github.com/astral-sh/rye/blob/main/.github/workflows/sync-uv-releases.yml)</sup>
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ _Unreleased_
- rye no longer fails if an incorrect `VIRTUAL_ENV` environment
variable is exported. #766

- Added latest Python builds. #771

- When `uv` is used the prompt is now set to the project name. #773

- Allow `rye fetch --force` to force re-fetch a downloaded toolchain. #778

<!-- released start -->

## 0.26.0
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ lint:

.PHONY: sync-python-releases
sync-python-releases: .venv
@rye run find-downloads > rye/src/downloads.inc
@rye run find-downloads > rye/src/sources/generated/python_downloads.inc

sync-uv-releases: .venv
@rye run uv-downloads > rye/src/sources/generated/uv_downloads.inc
16 changes: 8 additions & 8 deletions docs/.includes/quick-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Alternatively if you don't trust this approach, you can download the latest release
binary. On first run it will install itself.

* [rye-x86_64-linux.gz](https://github.com/mitsuhiko/rye/releases/latest/download/rye-x86_64-linux.gz) for 64bit Intel computers
* [rye-aarch64-linux.gz](https://github.com/mitsuhiko/rye/releases/latest/download/rye-aarch64-linux.gz) for 64bit ARM computers
* [rye-x86_64-linux.gz](https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-linux.gz) for 64bit Intel computers
* [rye-aarch64-linux.gz](https://github.com/astral-sh/rye/releases/latest/download/rye-aarch64-linux.gz) for 64bit ARM computers

```bash
gunzip rye-x86_64-linux.gz
Expand All @@ -31,8 +31,8 @@
Alternatively if you don't trust this approach, you can download the latest release
binary. On first run it will install itself.

* [rye-aarch64-macos.gz](https://github.com/mitsuhiko/rye/releases/latest/download/rye-aarch64-macos.gz) for M1/M2 Macs
* [rye-x86_64-macos.gz](https://github.com/mitsuhiko/rye/releases/latest/download/rye-x86_64-macos.gz) for Intel Macs
* [rye-aarch64-macos.gz](https://github.com/astral-sh/rye/releases/latest/download/rye-aarch64-macos.gz) for M1/M2 Macs
* [rye-x86_64-macos.gz](https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-macos.gz) for Intel Macs

```bash
gunzip rye-aarch64-macos.gz
Expand All @@ -47,8 +47,8 @@
to have "Developer Mode" activated when using Rye and before starting the
installation. [Learn more](../guide/faq.md).

* [rye-x86_64-windows.exe](https://github.com/mitsuhiko/rye/releases/latest/download/rye-x86_64-windows.exe) for 64bit Intel Windows
* [rye-x86-windows.exe](https://github.com/mitsuhiko/rye/releases/latest/download/rye-x86-windows.exe) for 32bit Intel Windows
* [rye-x86_64-windows.exe](https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-windows.exe) for 64bit Intel Windows
* [rye-x86-windows.exe](https://github.com/astral-sh/rye/releases/latest/download/rye-x86-windows.exe) for 32bit Intel Windows

!!!Note

Expand All @@ -58,7 +58,7 @@

Additionally sometimes a Trojan warning about "Bearfoos" is shown. This is a false
positive. For more information see the discussion [Windows Bearfoos
virus associated with rye](https://github.com/mitsuhiko/rye/issues/468).
virus associated with rye](https://github.com/astral-sh/rye/issues/468).

=== "Compile Yourself"

Expand All @@ -68,5 +68,5 @@
Afterwards you can install `Rye` via `cargo`:

```bash
cargo install --git https://github.com/mitsuhiko/rye rye
cargo install --git https://github.com/astral-sh/rye rye
```
8 changes: 6 additions & 2 deletions docs/guide/commands/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Fetch a specific version of Python:
$ rye fetch 3.8.13
Downloading cpython@3.8.13
Checking checksum
success: Downloaded cpython@3.8.13
Unpacking
Downloaded cpython@3.8.13
```

To fetch the pinned version of Python you can leave out the argument:
Expand All @@ -20,7 +21,8 @@ To fetch the pinned version of Python you can leave out the argument:
$ rye fetch
Downloading cpython@3.8.17
Checking checksum
success: Downloaded cpython@3.8.17
Unpacking
Downloaded cpython@3.8.17
```

## Arguments
Expand All @@ -31,6 +33,8 @@ success: Downloaded cpython@3.8.17

## Options

* `-f, --force`: Fetch the Python toolchain even if it is already installed.

* `-v, --verbose`: Enables verbose diagnostics

* `-q, --quiet`: Turns off all output
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extensions. There is no known solution to this problem today other than
This issue is inherited from `python-build-standalone` and more information can
be found in the documentation: [References to Build-Time Paths](https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html#references-to-build-time-paths). There is also an open
Rye issue for it: [Issue #621](https://github.com/mitsuhiko/rye/issues/621).
Rye issue for it: [Issue #621](https://github.com/astral-sh/rye/issues/621).
## TKinter Support
Expand Down Expand Up @@ -199,4 +199,4 @@ while because the compiler spits out some bytes that have been associated with T
written in Rust.

It can be ignored. For more information see the discussion [Windows Bearfoos
virus associated with rye](https://github.com/mitsuhiko/rye/issues/468).
virus associated with rye](https://github.com/astral-sh/rye/issues/468).
10 changes: 5 additions & 5 deletions docs/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ a folder in your home directory and manage itself there.
Rye will automatically download suitable Python toolchains as needed. For more
information about this [read about toolchains](toolchains/index.md). To install
a specific version download a binary directly
[from GitHub](https://github.com/mitsuhiko/rye/releases).
[from GitHub](https://github.com/astral-sh/rye/releases).

## Customized Installation

Expand Down Expand Up @@ -77,14 +77,14 @@ opt-out, or you run a custom shell you will need to do this manually.
Rye ships an `env` file which should be sourced to update `PATH` automatically.

```bash
echo 'source "$HOME/.rye/env"' >> ~/.profile
echo 'source "$HOME/.rye/env"' >> ~/.zprofile
```

In some setups `.profile` is not sourced, in which case you can add it to your
`.zprofile`:
In some setups `.zprofile` is not sourced, in which case you can add it to your
`.zshrc`:

```bash
echo 'source "$HOME/.rye/env"' >> ~/.zprofile
echo 'source "$HOME/.rye/env"' >> ~/.zshrc
```

=== "Fish"
Expand Down
22 changes: 15 additions & 7 deletions rye/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn ensure_self_venv_with_toolchain(

// initialize the virtualenv
{
let uv_venv = uv.venv(&venv_dir, &py_bin, &version)?;
let uv_venv = uv.venv(&venv_dir, &py_bin, &version, None)?;
// write our marker
uv_venv.write_marker()?;
// update pip and our requirements
Expand Down Expand Up @@ -277,7 +277,7 @@ fn ensure_latest_self_toolchain(output: CommandOutput) -> Result<PythonVersion,
}
Ok(version)
} else {
fetch(&SELF_PYTHON_TARGET_VERSION, output)
fetch(&SELF_PYTHON_TARGET_VERSION, output, false)
}
}

Expand All @@ -301,7 +301,7 @@ fn ensure_specific_self_toolchain(
toolchain_version
);
}
fetch(&toolchain_version.into(), output)
fetch(&toolchain_version.into(), output, false)
} else {
if output != CommandOutput::Quiet {
echo!(
Expand All @@ -317,10 +317,11 @@ fn ensure_specific_self_toolchain(
pub fn fetch(
version: &PythonVersionRequest,
output: CommandOutput,
force: bool,
) -> Result<PythonVersion, Error> {
if let Ok(version) = PythonVersion::try_from(version.clone()) {
let py_bin = get_toolchain_python_bin(&version)?;
if py_bin.is_file() {
if !force && py_bin.is_file() {
if output == CommandOutput::Verbose {
echo!("Python version already downloaded. Skipping.");
}
Expand All @@ -339,10 +340,17 @@ pub fn fetch(
echo!("target dir: {}", target_dir.display());
}
if target_dir.is_dir() && target_py_bin.is_file() {
if output == CommandOutput::Verbose {
echo!("Python version already downloaded. Skipping.");
if !force {
if output == CommandOutput::Verbose {
echo!("Python version already downloaded. Skipping.");
}
return Ok(version);
}
if output != CommandOutput::Quiet {
echo!("Removing the existing Python version");
}
return Ok(version);
fs::remove_dir_all(&target_dir)
.with_context(|| format!("failed to remove target folder {}", target_dir.display()))?;
}

fs::create_dir_all(&target_dir).path_context(&target_dir, "failed to create target folder")?;
Expand Down
5 changes: 4 additions & 1 deletion rye/src/cli/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub struct Args {
///
/// If no version is provided, the requested version from local project or `.python-version` will be fetched.
version: Option<String>,
/// Fetch the Python toolchain even if it is already installed.
#[arg(short, long)]
force: bool,
/// Enables verbose diagnostics.
#[arg(short, long)]
verbose: bool,
Expand All @@ -40,6 +43,6 @@ pub fn execute(cmd: Args) -> Result<(), Error> {
}
};

fetch(&version, output).context("error while fetching Python installation")?;
fetch(&version, output, cmd.force).context("error while fetching Python installation")?;
Ok(())
}
2 changes: 1 addition & 1 deletion rye/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn install(
uninstall_helper(&target_venv_path, &shim_dir)?;

// make sure we have a compatible python version
let py_ver = fetch(py_ver, output)?;
let py_ver = fetch(py_ver, output, false)?;

create_virtualenv(
output,
Expand Down
Loading

0 comments on commit f43331e

Please sign in to comment.