mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
pep508: un-export fields for MarkerEnvironment
We now use the getters and setters everywhere. There were some places where we wanted to build a `MarkerEnvironment` out of whole cloth, usually in tests. To facilitate those use cases, we add a `MarkerEnvironmentBuilder` that provides a convenient constructor. It's basically like a `MarkerEnvironment::new`, but with named parameters. That's useful here because there are so many fields (and they many have the same type).
This commit is contained in:
parent
be12cfb2b8
commit
7d67b7bb49
11 changed files with 198 additions and 169 deletions
|
@ -38,13 +38,12 @@ criterion_main!(uv);
|
|||
|
||||
mod resolver {
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Result;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use distribution_types::{IndexLocations, Requirement, Resolution, SourceDist};
|
||||
use pep508_rs::{MarkerEnvironment, StringVersion};
|
||||
use pep508_rs::{MarkerEnvironment, MarkerEnvironmentBuilder};
|
||||
use platform_tags::{Arch, Os, Platform, Tags};
|
||||
use uv_cache::Cache;
|
||||
use uv_client::RegistryClient;
|
||||
|
@ -58,19 +57,19 @@ mod resolver {
|
|||
};
|
||||
|
||||
static MARKERS: Lazy<MarkerEnvironment> = Lazy::new(|| {
|
||||
MarkerEnvironment {
|
||||
implementation_name: "cpython".to_string(),
|
||||
implementation_version: StringVersion::from_str("3.11.5").unwrap(),
|
||||
os_name: "posix".to_string(),
|
||||
platform_machine: "arm64".to_string(),
|
||||
platform_python_implementation: "CPython".to_string(),
|
||||
platform_release: "21.6.0".to_string(),
|
||||
platform_system: "Darwin".to_string(),
|
||||
platform_version: "Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000".to_string(),
|
||||
python_full_version: StringVersion::from_str("3.11.5").unwrap(),
|
||||
python_version: StringVersion::from_str("3.11").unwrap(),
|
||||
sys_platform: "darwin".to_string(),
|
||||
}
|
||||
MarkerEnvironment::try_from(MarkerEnvironmentBuilder {
|
||||
implementation_name: "cpython",
|
||||
implementation_version: "3.11.5",
|
||||
os_name: "posix",
|
||||
platform_machine: "arm64",
|
||||
platform_python_implementation: "CPython",
|
||||
platform_release: "21.6.0",
|
||||
platform_system: "Darwin",
|
||||
platform_version: "Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000",
|
||||
python_full_version: "3.11.5",
|
||||
python_version: "3.11",
|
||||
sys_platform: "darwin",
|
||||
}).unwrap()
|
||||
});
|
||||
|
||||
static PLATFORM: Platform = Platform::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue