Files
uv/crates/uv-resolver/src/python_requirement.rs
T

39 lines
1.2 KiB
Rust
Raw Normal View History

use pep508_rs::{MarkerEnvironment, StringVersion};
2024-02-15 11:19:46 -06:00
use uv_interpreter::Interpreter;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct PythonRequirement {
/// The installed version of Python.
installed: StringVersion,
/// 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: StringVersion,
}
impl PythonRequirement {
2024-06-02 21:33:18 -04:00
pub fn from_marker_environment(interpreter: &Interpreter, env: &MarkerEnvironment) -> Self {
Self {
installed: interpreter.python_full_version().clone(),
2024-06-02 21:33:18 -04:00
target: env.python_full_version().clone(),
}
}
2024-06-02 21:33:18 -04:00
pub fn from_interpreter(interpreter: &Interpreter) -> Self {
Self {
installed: interpreter.python_full_version().clone(),
target: interpreter.python_full_version().clone(),
}
}
/// Return the installed version of Python.
pub fn installed(&self) -> &StringVersion {
&self.installed
}
/// Return the target version of Python.
pub fn target(&self) -> &StringVersion {
&self.target
}
}