Add Conda tests to system-install.yml (#2281)

Closes https://github.com/astral-sh/uv/issues/2280.
This commit is contained in:
Charlie Marsh 2024-03-07 08:44:19 -08:00 committed by GitHub
parent 54311c8664
commit b3ac0e30ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 7 deletions

View file

@ -231,3 +231,44 @@ jobs:
- name: "Validate global Python install"
run: python3.9 scripts/check_system_python.py --uv ./target/debug/uv
install-conda:
name: Install on Conda (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
activate-environment: uv
python-version: ${{ matrix.python-version }}
- name: Conda info
shell: bash -el {0}
run: conda info
- name: Conda list
shell: pwsh
run: conda list
- name: "Install Rust toolchain"
run: rustup show
- uses: Swatinem/rust-cache@v2
- name: "Build"
run: cargo build
- name: "Print Python path"
shell: bash -el {0}
run: echo $(which python)
- name: "Validate global Python install"
shell: bash -el {0}
run: python ./scripts/check_system_python.py --uv ./target/debug/uv

View file

@ -179,18 +179,32 @@ pub fn create_bare_venv(
match fs_err::copy(shim, scripts.join(python_exe)) {
Ok(_) => {}
Err(err) if err.kind() == io::ErrorKind::NotFound => {
let launcher = match python_exe {
"python.exe" => "venvwlauncher.exe",
"pythonw.exe" => "venvwlauncher.exe",
_ => unreachable!(),
};
// 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))?;
.join(launcher);
// If the `venvwlauncher.exe` shim doesn't exist, then on Conda at least, we
// can look for it next to the Python executable itself.
match fs_err::copy(shim, scripts.join(python_exe)) {
Ok(_) => {}
Err(err) if err.kind() == io::ErrorKind::NotFound => {
let shim = base_python.with_file_name(launcher);
fs_err::copy(shim, scripts.join(python_exe))?;
}
Err(err) => {
return Err(err.into());
}
}
}
Err(err) => {
return Err(err.into());

View file

@ -92,10 +92,18 @@ if __name__ == "__main__":
)
logging.info("Installing into virtual environment...")
# Disable the `CONDA_PREFIX` and `VIRTUAL_ENV` environment variables, so that
# we only rely on virtual environment discovery via the `.venv` directory.
# Our "system Python" here might itself be a Conda environment!
env = os.environ.copy()
env["CONDA_PREFIX"] = ""
env["VIRTUAL_ENV"] = ""
subprocess.run(
[uv, "pip", "install", "pylint"],
[uv, "pip", "install", "pylint", "--verbose"],
cwd=temp_dir,
check=True,
env=env,
)
# Ensure that the package (`pylint`) isn't installed globally.