Skip to content

Commit

Permalink
Fall back
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 4, 2024
1 parent 7077c6a commit 1c41f3a
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 99 deletions.
176 changes: 101 additions & 75 deletions .github/workflows/system-install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: System Install

on:
pull_request:
workflow_dispatch:

concurrency:
Expand All @@ -15,55 +14,82 @@ env:
RUSTUP_MAX_RETRIES: 10

jobs:
# install-ubuntu:
# name: "Install Python on Ubuntu"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - uses: actions/setup-python@v5
# with:
# python-version: "3.12"
#
# - name: "Install Rust toolchain"
# run: rustup show
#
# - uses: Swatinem/rust-cache@v2
#
# - name: "Build"
# run: cargo build
#
# - name: "Print Python path"
# run: echo $(which python)
#
# - name: "Validate global Python install"
# run: python scripts/check_system_python.py --uv ./target/debug/uv
#
# install-macos:
# name: "Install Python on macOS"
# runs-on: macos-14
# steps:
# - uses: actions/checkout@v4
#
# - name: "Install Python"
# run: brew install python@3.8
#
# - name: "Install Rust toolchain"
# run: rustup show
#
# - uses: Swatinem/rust-cache@v2
#
# - name: "Build"
# run: cargo build
#
# - name: "Print Python path"
# run: echo $(which python3.11)
#
# - name: "Validate global Python install"
# run: python3.11 scripts/check_system_python.py --uv ./target/debug/uv

install-windows:
name: "Install Python on Windows"
install-ubuntu:
name: "Install Python on Ubuntu"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: "Install Rust toolchain"
run: rustup show

- uses: Swatinem/rust-cache@v2

- name: "Build"
run: cargo build

- name: "Print Python path"
run: echo $(which python)

- name: "Validate global Python install"
run: python scripts/check_system_python.py --uv ./target/debug/uv

install-macos:
name: "Install Python on macOS"
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: "Install Python"
run: brew install python@3.8

- name: "Install Rust toolchain"
run: rustup show

- uses: Swatinem/rust-cache@v2

- name: "Build"
run: cargo build

- name: "Print Python path"
run: echo $(which python3.11)

- name: "Validate global Python install"
run: python3.11 scripts/check_system_python.py --uv ./target/debug/uv

install-windows-python-310:
name: "Install Python 3.10 on Windows"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: "Install Rust toolchain"
run: rustup show

- uses: Swatinem/rust-cache@v2

- name: "Build"
run: cargo build

- name: "Print Python path"
run: echo $(which python)

- name: "Create virtual environment"
run: ./target/debug/uv venv

- name: "Validate global Python install"
run: py -3.10 ./scripts/check_system_python.py --uv ./target/debug/uv

install-windows-python-313:
name: "Install Python 3.13 on Windows"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -89,29 +115,29 @@ jobs:
run: ./target/debug/uv venv

- name: "Validate global Python install"
run: py -3.10 ./scripts/check_system_python.py --uv ./target/debug/uv
run: py -3.13 ./scripts/check_system_python.py --uv ./target/debug/uv

install-pyenv:
name: "Install Python using pyenv"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: "Install pyenv"
uses: "gabrielfalcao/pyenv-action@v18"
with:
default: 3.9.7

# install-pyenv:
# name: "Install Python using pyenv"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - name: "Install pyenv"
# uses: "gabrielfalcao/pyenv-action@v18"
# with:
# default: 3.9.7
#
# - name: "Install Rust toolchain"
# run: rustup show
#
# - uses: Swatinem/rust-cache@v2
#
# - name: "Build"
# run: cargo build
#
# - name: "Print Python path"
# run: echo $(which python3.9)
#
# - name: "Validate global Python install"
# run: python3.9 scripts/check_system_python.py --uv ./target/debug/uv
- name: "Install Rust toolchain"
run: rustup show

- uses: Swatinem/rust-cache@v2

- name: "Build"
run: cargo build

- name: "Print Python path"
run: echo $(which python3.9)

- name: "Validate global Python install"
run: python3.9 scripts/check_system_python.py --uv ./target/debug/uv
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/uv-virtualenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ thiserror = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, optional = true }
which = { workspace = true }
walkdir.workspace = true

[features]
cli = ["clap", "tracing-subscriber"]
44 changes: 22 additions & 22 deletions crates/uv-virtualenv/src/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ pub fn create_bare_venv(
// a virtual environment is a symlink to the base interpreter.
uv_fs::canonicalize_executable(interpreter.sys_executable())?
} else if cfg!(windows) {
println!("interpreter.is_virtualenv(): {:?}", interpreter.is_virtualenv());
println!("interpreter.base_executable(): {:?}", interpreter.base_executable());
println!("interpreter.base_prefix(): {:?}", interpreter.base_prefix());
println!("interpreter.sys_executable(): {:?}", interpreter.sys_executable());
println!("uv_fs::canonicalize_executable(interpreter.sys_executable()): {:?}", uv_fs::canonicalize_executable(interpreter.sys_executable()));

// On Windows, follow `virtualenv`. If we're in a virtual environment, use
// `sys._base_executable` if it exists; if not, use `sys.base_prefix`. For example, with
// Python installed from the Windows Store, `sys.base_prefix` is slightly "incorrect".
Expand All @@ -80,9 +74,8 @@ pub fn create_bare_venv(
interpreter.base_prefix().join("python.exe")
}
} else {
interpreter.sys_executable().to_path_buf()
uv_fs::canonicalize_executable(interpreter.sys_executable())?
}

} else {
unimplemented!("Only Windows and Unix are supported")
};
Expand Down Expand Up @@ -170,14 +163,6 @@ pub fn create_bare_venv(
)?;
}

println!("interpreter.stdlib(): {:?}", interpreter.stdlib());
println!("uv_fs::canonicalize_executable(interpreter.sys_executable()): {:?}", uv_fs::canonicalize_executable(interpreter.stdlib()));

// Show the entire directory structure.
for x in walkdir::WalkDir::new(base_python.parent().unwrap()) {
println!("{:?}", x);
}

#[cfg(windows)]
{
// https://github.com/python/cpython/blob/d457345bbc6414db0443819290b04a9a4333313d/Lib/venv/__init__.py#L261-L267
Expand All @@ -190,12 +175,27 @@ pub fn create_bare_venv(
.join("venv")
.join("scripts")
.join("nt")
.join(match python_exe {
"python.exe" => "venvwlauncher.exe",
"pythonw.exe" => "venvwlauncher.exe",
_ => unreachable!(),
});
fs_err::copy(shim, scripts.join(python_exe))?;
.join(python_exe);
match fs_err::copy(shim, scripts.join(python_exe)) {
Ok(_) => {}
Err(err) if err.kind() == io::ErrorKind::NotFound => {
// If `python.exe` doesn't exist, try the `venvlaucher.exe` shim.
let shim = interpreter
.stdlib()
.join("venv")
.join("scripts")
.join("nt")
.join(match python_exe {
"python.exe" => "venvwlauncher.exe",
"pythonw.exe" => "venvwlauncher.exe",
_ => unreachable!(),
});
fs_err::copy(shim, scripts.join(python_exe))?;
}
Err(err) => {
return Err(err.into());
}
}
}
}
#[cfg(not(any(unix, windows)))]
Expand Down

0 comments on commit 1c41f3a

Please sign in to comment.