mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Rename to uv
(#1302)
First, replace all usages in files in-place. I used my editor for this. If someone wants to add a one-liner that'd be fun. Then, update directory and file names: ``` # Run twice for nested directories find . -type d -print0 | xargs -0 rename s/puffin/uv/g find . -type d -print0 | xargs -0 rename s/puffin/uv/g # Update files find . -type f -print0 | xargs -0 rename s/puffin/uv/g ``` Then add all the files again ``` # Add all the files again git add crates git add python/uv # This one needs a force-add git add -f crates/uv-trampoline ```
This commit is contained in:
parent
328b116d5d
commit
2586f655bb
229 changed files with 1796 additions and 1818 deletions
71
crates/uv-resolver/src/python_requirement.rs
Normal file
71
crates/uv-resolver/src/python_requirement.rs
Normal file
|
@ -0,0 +1,71 @@
|
|||
use distribution_types::{CompatibleDist, Dist};
|
||||
use pep440_rs::{Version, VersionSpecifiers};
|
||||
use pep508_rs::MarkerEnvironment;
|
||||
use uv_interpreter::Interpreter;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub struct PythonRequirement {
|
||||
/// The installed version of Python.
|
||||
installed: Version,
|
||||
/// The target version of Python; that is, the version of Python for which we are resolving
|
||||
/// dependencies. This is typically the same as the installed version, but may be different
|
||||
/// when specifying an alternate Python version for the resolution.
|
||||
target: Version,
|
||||
}
|
||||
|
||||
impl PythonRequirement {
|
||||
pub fn new(interpreter: &Interpreter, markers: &MarkerEnvironment) -> Self {
|
||||
Self {
|
||||
installed: interpreter.python_version().clone(),
|
||||
target: markers.python_full_version.version.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the installed version of Python.
|
||||
pub(crate) fn installed(&self) -> &Version {
|
||||
&self.installed
|
||||
}
|
||||
|
||||
/// Return the target version of Python.
|
||||
pub(crate) fn target(&self) -> &Version {
|
||||
&self.target
|
||||
}
|
||||
|
||||
/// If the dist doesn't match the given Python requirement, return the version specifiers.
|
||||
pub(crate) fn validate_dist<'a>(
|
||||
&self,
|
||||
dist: &'a CompatibleDist,
|
||||
) -> Option<&'a VersionSpecifiers> {
|
||||
// Validate the _installed_ file.
|
||||
let requires_python = dist.for_installation().requires_python.as_ref()?;
|
||||
|
||||
// If the dist doesn't support the target Python version, return the failing version
|
||||
// specifiers.
|
||||
if !requires_python.contains(self.target()) {
|
||||
return Some(requires_python);
|
||||
}
|
||||
|
||||
// If the dist is a source distribution, and doesn't support the installed Python
|
||||
// version, return the failing version specifiers, since we won't be able to build it.
|
||||
if matches!(dist.for_installation().dist, Dist::Source(_)) {
|
||||
if !requires_python.contains(self.installed()) {
|
||||
return Some(requires_python);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the resolved file.
|
||||
let requires_python = dist.for_resolution().requires_python.as_ref()?;
|
||||
|
||||
// If the dist is a source distribution, and doesn't support the installed Python
|
||||
// version, return the failing version specifiers, since we won't be able to build it.
|
||||
// This isn't strictly necessary, since if `dist.resolve_metadata()` is a source distribution, it
|
||||
// should be the same file as `dist.install_metadata()` (validated above).
|
||||
if matches!(dist.for_resolution().dist, Dist::Source(_)) {
|
||||
if !requires_python.contains(self.installed()) {
|
||||
return Some(requires_python);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue