2024-03-08 11:02:31 -06:00
|
|
|
use pep440_rs::Version;
|
2024-01-03 11:20:45 -04:00
|
|
|
use pep508_rs::MarkerEnvironment;
|
2024-02-15 11:19:46 -06:00
|
|
|
use uv_interpreter::Interpreter;
|
2024-01-03 11:20:45 -04:00
|
|
|
|
2024-02-15 10:48:15 -06:00
|
|
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
2024-01-22 00:32:02 -06:00
|
|
|
pub struct PythonRequirement {
|
2024-01-03 11:20:45 -04:00
|
|
|
/// The installed version of Python.
|
2024-01-22 00:32:02 -06:00
|
|
|
installed: Version,
|
2024-01-03 11:20:45 -04:00
|
|
|
/// 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.
|
2024-01-22 00:32:02 -06:00
|
|
|
target: Version,
|
2024-01-03 11:20:45 -04:00
|
|
|
}
|
|
|
|
|
|
2024-01-22 00:32:02 -06:00
|
|
|
impl PythonRequirement {
|
|
|
|
|
pub fn new(interpreter: &Interpreter, markers: &MarkerEnvironment) -> Self {
|
2024-01-03 11:20:45 -04:00
|
|
|
Self {
|
2024-01-22 09:22:27 -05:00
|
|
|
installed: interpreter.python_version().clone(),
|
2024-01-22 01:44:39 -05:00
|
|
|
target: markers.python_full_version.version.clone(),
|
2024-01-03 11:20:45 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Return the installed version of Python.
|
2024-03-04 20:20:42 -08:00
|
|
|
pub fn installed(&self) -> &Version {
|
2024-01-22 00:32:02 -06:00
|
|
|
&self.installed
|
2024-01-03 11:20:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Return the target version of Python.
|
2024-03-04 20:20:42 -08:00
|
|
|
pub fn target(&self) -> &Version {
|
2024-01-22 00:32:02 -06:00
|
|
|
&self.target
|
2024-01-03 11:20:45 -04:00
|
|
|
}
|
|
|
|
|
}
|