mirror of https://github.com/astral-sh/uv
Fix non-optional uv-pep440 features (#8693)
This commit is contained in:
parent
2b0e16cb75
commit
4bf01ed337
|
|
@ -6,6 +6,7 @@ use crate::{
|
||||||
version, Operator, OperatorParseError, Version, VersionPattern, VersionPatternParseError,
|
version, Operator, OperatorParseError, Version, VersionPattern, VersionPatternParseError,
|
||||||
};
|
};
|
||||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
/// Sorted version specifiers, such as `>=2.1,<3`.
|
/// Sorted version specifiers, such as `>=2.1,<3`.
|
||||||
|
|
@ -23,19 +24,12 @@ use tracing::warn;
|
||||||
/// // VersionSpecifiers derefs into a list of specifiers
|
/// // VersionSpecifiers derefs into a list of specifiers
|
||||||
/// assert_eq!(version_specifiers.iter().position(|specifier| *specifier.operator() == Operator::LessThan), Some(1));
|
/// assert_eq!(version_specifiers.iter().position(|specifier| *specifier.operator() == Operator::LessThan), Some(1));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(
|
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
|
||||||
Eq,
|
#[cfg_attr(
|
||||||
PartialEq,
|
feature = "rkyv",
|
||||||
Ord,
|
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)
|
||||||
PartialOrd,
|
|
||||||
Debug,
|
|
||||||
Clone,
|
|
||||||
Hash,
|
|
||||||
rkyv::Archive,
|
|
||||||
rkyv::Deserialize,
|
|
||||||
rkyv::Serialize,
|
|
||||||
)]
|
)]
|
||||||
#[rkyv(derive(Debug))]
|
#[cfg_attr(feature = "rkyv", rkyv(derive(Debug)))]
|
||||||
pub struct VersionSpecifiers(Vec<VersionSpecifier>);
|
pub struct VersionSpecifiers(Vec<VersionSpecifier>);
|
||||||
|
|
||||||
impl std::ops::Deref for VersionSpecifiers {
|
impl std::ops::Deref for VersionSpecifiers {
|
||||||
|
|
@ -97,6 +91,7 @@ impl VersionSpecifiers {
|
||||||
specifiers.push(VersionSpecifier::not_equals_star_version(prev.clone()));
|
specifiers.push(VersionSpecifier::not_equals_star_version(prev.clone()));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
warn!("Ignoring unsupported gap in `requires-python` version: {next:?} -> {lower:?}");
|
warn!("Ignoring unsupported gap in `requires-python` version: {next:?} -> {lower:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,19 +234,12 @@ impl std::error::Error for VersionSpecifiersParseError {}
|
||||||
/// let version_specifier = VersionSpecifier::from_str("== 1.*").unwrap();
|
/// let version_specifier = VersionSpecifier::from_str("== 1.*").unwrap();
|
||||||
/// assert!(version_specifier.contains(&version));
|
/// assert!(version_specifier.contains(&version));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(
|
#[derive(Eq, Ord, PartialEq, PartialOrd, Debug, Clone, Hash)]
|
||||||
Eq,
|
#[cfg_attr(
|
||||||
Ord,
|
feature = "rkyv",
|
||||||
PartialEq,
|
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)
|
||||||
PartialOrd,
|
|
||||||
Debug,
|
|
||||||
Clone,
|
|
||||||
Hash,
|
|
||||||
rkyv::Archive,
|
|
||||||
rkyv::Deserialize,
|
|
||||||
rkyv::Serialize,
|
|
||||||
)]
|
)]
|
||||||
#[rkyv(derive(Debug))]
|
#[cfg_attr(feature = "rkyv", rkyv(derive(Debug)))]
|
||||||
pub struct VersionSpecifier {
|
pub struct VersionSpecifier {
|
||||||
/// ~=|==|!=|<=|>=|<|>|===, plus whether the version ended with a star
|
/// ~=|==|!=|<=|>=|<|>|===, plus whether the version ended with a star
|
||||||
pub(crate) operator: Operator,
|
pub(crate) operator: Operator,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ regex = { workspace = true }
|
||||||
rustc-hash = { workspace = true }
|
rustc-hash = { workspace = true }
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
serde = { workspace = true, features = ["derive", "rc"] }
|
serde = { workspace = true, features = ["derive", "rc"] }
|
||||||
serde_json = { workspace = true, optional = true }
|
|
||||||
smallvec = { workspace = true }
|
smallvec = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tracing = { workspace = true, optional = true }
|
tracing = { workspace = true, optional = true }
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ pub use origin::RequirementOrigin;
|
||||||
#[cfg(feature = "non-pep508-extensions")]
|
#[cfg(feature = "non-pep508-extensions")]
|
||||||
pub use unnamed::{UnnamedRequirement, UnnamedRequirementUrl};
|
pub use unnamed::{UnnamedRequirement, UnnamedRequirementUrl};
|
||||||
pub use uv_normalize::{ExtraName, InvalidNameError, PackageName};
|
pub use uv_normalize::{ExtraName, InvalidNameError, PackageName};
|
||||||
|
/// Version and version specifiers used in requirements (reexport).
|
||||||
|
// https://github.com/konstin/pep508_rs/issues/19
|
||||||
|
pub use uv_pep440;
|
||||||
use uv_pep440::{Version, VersionSpecifier, VersionSpecifiers};
|
use uv_pep440::{Version, VersionSpecifier, VersionSpecifiers};
|
||||||
pub use verbatim_url::{
|
pub use verbatim_url::{
|
||||||
expand_env_vars, split_scheme, strip_host, Scheme, VerbatimUrl, VerbatimUrlError,
|
expand_env_vars, split_scheme, strip_host, Scheme, VerbatimUrl, VerbatimUrlError,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue