mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Support granular target Python versions (#534)
## Summary Allows, e.g., `--python-version 3.7` or `--python-version 3.7.9`. This was also feedback I received in the original PR. Closes https://github.com/astral-sh/puffin/issues/533.
This commit is contained in:
parent
06ee321e9c
commit
c3a917bbf6
6 changed files with 160 additions and 57 deletions
|
@ -473,7 +473,7 @@ fn compile_python_312() -> Result<()> {
|
|||
.arg("pip-compile")
|
||||
.arg("requirements.in")
|
||||
.arg("--python-version")
|
||||
.arg("py312")
|
||||
.arg("3.12")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
|
@ -502,7 +502,7 @@ fn compile_python_37() -> Result<()> {
|
|||
.arg("pip-compile")
|
||||
.arg("requirements.in")
|
||||
.arg("--python-version")
|
||||
.arg("py37")
|
||||
.arg("3.7")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
|
@ -514,6 +514,50 @@ fn compile_python_37() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Resolve a specific version of Black against an invalid Python version.
|
||||
#[test]
|
||||
fn compile_python_invalid_version() -> Result<()> {
|
||||
let temp_dir = TempDir::new()?;
|
||||
|
||||
let requirements_in = temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("black==23.10.1")?;
|
||||
|
||||
insta::with_settings!({
|
||||
filters => INSTA_FILTERS.to_vec()
|
||||
}, {
|
||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
||||
.arg("pip-compile")
|
||||
.arg("requirements.in")
|
||||
.arg("--python-version")
|
||||
.arg("3.7.x")
|
||||
.current_dir(&temp_dir));
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Resolve a specific version of Black against an invalid Python version.
|
||||
#[test]
|
||||
fn compile_python_dev_version() -> Result<()> {
|
||||
let temp_dir = TempDir::new()?;
|
||||
|
||||
let requirements_in = temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("black==23.10.1")?;
|
||||
|
||||
insta::with_settings!({
|
||||
filters => INSTA_FILTERS.to_vec()
|
||||
}, {
|
||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
||||
.arg("pip-compile")
|
||||
.arg("requirements.in")
|
||||
.arg("--python-version")
|
||||
.arg("3.7-dev")
|
||||
.current_dir(&temp_dir));
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test that we select the last 3.8 compatible numpy version instead of trying to compile an
|
||||
/// incompatible sdist <https://github.com/astral-sh/puffin/issues/388>
|
||||
#[test]
|
||||
|
|
|
@ -6,17 +6,19 @@ info:
|
|||
- pip-compile
|
||||
- requirements.in
|
||||
- "--python-version"
|
||||
- py312
|
||||
- "3.12"
|
||||
- "--cache-dir"
|
||||
- /tmp/.tmp4asOTQ
|
||||
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpBGkaCR
|
||||
- "--exclude-newer"
|
||||
- "2023-11-18T12:00:00Z"
|
||||
env:
|
||||
VIRTUAL_ENV: /tmp/.tmpjRCdtR/.venv
|
||||
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpfxl60Y/.venv
|
||||
---
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by Puffin v0.0.1 via the following command:
|
||||
# puffin pip-compile requirements.in --python-version py312 --cache-dir [CACHE_DIR]
|
||||
# puffin pip-compile requirements.in --python-version 3.12 --cache-dir [CACHE_DIR]
|
||||
black==23.10.1
|
||||
click==8.1.7
|
||||
# via black
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
source: crates/puffin-cli/tests/pip_compile.rs
|
||||
info:
|
||||
program: puffin
|
||||
args:
|
||||
- pip-compile
|
||||
- requirements.in
|
||||
- "--python-version"
|
||||
- 3.7-dev
|
||||
---
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
error: invalid value '3.7-dev' for '--python-version <PYTHON_VERSION>': Python version 3.7-dev is a development release
|
||||
|
||||
For more information, try '--help'.
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
source: crates/puffin-cli/tests/pip_compile.rs
|
||||
info:
|
||||
program: puffin
|
||||
args:
|
||||
- pip-compile
|
||||
- requirements.in
|
||||
- "--python-version"
|
||||
- 3.7.x
|
||||
---
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
error: invalid value '3.7.x' for '--python-version <PYTHON_VERSION>': Version `3.7.x` doesn't match PEP 440 rules
|
||||
|
||||
For more information, try '--help'.
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue