Skip to content

Commit

Permalink
do not imply pre-release when != operator is used (#7974)
Browse files Browse the repository at this point in the history
closes #6640

Could you suggest how I should test it?

(already tested locally)

---------

Co-authored-by: konstin <[email protected]>
Co-authored-by: Charles Tapley Hoyt <[email protected]>
Co-authored-by: Charlie Marsh <[email protected]>
  • Loading branch information
4 people committed Nov 4, 2024
1 parent 2f5824f commit 25efa7d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/uv-resolver/src/prerelease.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use uv_pypi_types::RequirementSource;

use uv_normalize::PackageName;

use crate::resolver::ForkSet;
use crate::{DependencyMode, Manifest, ResolverMarkers};
use uv_normalize::PackageName;
use uv_pep440::Operator;

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
Expand Down Expand Up @@ -84,6 +84,9 @@ impl PrereleaseStrategy {

if specifier
.iter()
.filter(|spec| {
!matches!(spec.operator(), Operator::NotEqual | Operator::NotEqualStar)
})
.any(uv_pep440::VersionSpecifier::any_prerelease)
{
packages.add(&requirement, ());
Expand Down
36 changes: 36 additions & 0 deletions crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12720,3 +12720,39 @@ fn unsupported_requires_python_dynamic_metadata() -> Result<()> {

Ok(())
}

#[test]
fn negation_not_imply_prerelease() -> Result<()> {
let context = TestContext::new("3.12");

let requirements_in = context.temp_dir.child("requirements.in");
requirements_in.write_str("flask<2.0.1, !=2.0.0rc1")?;
uv_snapshot!(context
.pip_compile()
.arg("requirements.in"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
click==8.1.7
# via flask
flask==2.0.0
# via -r requirements.in
itsdangerous==2.1.2
# via flask
jinja2==3.1.3
# via flask
markupsafe==2.1.5
# via
# jinja2
# werkzeug
werkzeug==3.0.1
# via flask
----- stderr -----
Resolved 6 packages in [TIME]
"###);

Ok(())
}

0 comments on commit 25efa7d

Please sign in to comment.