Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: moved pypi environment modifiers #1699

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ zip = { version = "0.6.6", default-features = false }

pixi_config = { path = "crates/pixi_config" }
pixi_consts = { path = "crates/pixi_consts" }
pixi_default_sys = { path = "crates/pixi_default_sys" }
pixi_manifest = { path = "crates/pixi_manifest" }
pypi_modifiers = { path = "crates/pypi_modifiers" }

[package]
authors.workspace = true
Expand Down Expand Up @@ -214,7 +216,9 @@ rattler_solve = { workspace = true, features = ["resolvo", "serde"] }

pixi_config = { workspace = true }
pixi_consts = { workspace = true }
pixi_default_sys = { workspace = true }
pixi_manifest = { workspace = true }
pypi_modifiers = { workspace = true }
rattler_virtual_packages = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true, features = [
Expand Down
13 changes: 13 additions & 0 deletions crates/pixi_default_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
authors.workspace = true
description = "This crate defines the default system requirements"
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "pixi_default_sys"
baszalmstra marked this conversation as resolved.
Show resolved Hide resolved
readme.workspace = true
repository.workspace = true
version = "0.1.0"

[dependencies]
rattler_conda_types = { workspace = true }
24 changes: 24 additions & 0 deletions crates/pixi_default_sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use rattler_conda_types::{Platform, Version};

/// The default GLIBC version to use. This is used when no system requirements are specified.
pub fn default_glibc_version() -> Version {
"2.28".parse().unwrap()
tdejager marked this conversation as resolved.
Show resolved Hide resolved
}

/// The default linux version to use. This is used when no system requirements are specified.
pub fn default_linux_version() -> Version {
"5.10".parse().unwrap()
}

/// Returns the default Mac OS version for the specified platform. The platform must refer to a
/// MacOS platform.
pub fn default_mac_os_version(platform: Platform) -> Version {
match platform {
Platform::OsxArm64 => "13.0".parse().unwrap(),
Platform::Osx64 => "13.0".parse().unwrap(),
_ => panic!(
"default_mac_os_version() called with non-osx platform: {}",
platform
),
}
}
18 changes: 18 additions & 0 deletions crates/pypi_modifiers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
authors.workspace = true
description = "This crate contains an interpretation of PyPI Environment Markers and Wheel Tags for use in pixi"
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "pypi_modifiers"
readme.workspace = true
repository.workspace = true
version = "0.1.0"

[dependencies]
miette = { workspace = true }
pep508_rs = { workspace = true }
pixi_default_sys = { workspace = true }
pixi_manifest = { workspace = true }
platform-tags = { workspace = true }
rattler_conda_types = { workspace = true }
2 changes: 2 additions & 0 deletions crates/pypi_modifiers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod pypi_marker_env;
pub mod pypi_tags;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::project::virtual_packages::{default_glibc_version, default_mac_os_version};
use miette::{Context, IntoDiagnostic};
use pixi_default_sys::{default_glibc_version, default_mac_os_version};
use pixi_manifest::{LibCSystemRequirement, SystemRequirements};
use platform_tags::Os;
use platform_tags::Tags;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use itertools::Itertools;
use crate::fancy_display::FancyDisplay;
use crate::lock_file::{UpdateLockFileOptions, UvResolutionContext};
use crate::project::has_features::HasFeatures;
use crate::pypi_tags::{get_pypi_tags, is_python_record};
use crate::utils::uv::pypi_options_to_index_locations;
use crate::Project;
use pypi_modifiers::pypi_tags::{get_pypi_tags, is_python_record};
use rattler_conda_types::Platform;
use rattler_lock::{Package, UrlOrPath};
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion src/install_pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ use crate::{
conda_pypi_clobber::PypiCondaClobberRegistry,
lock_file::UvResolutionContext,
prefix::Prefix,
pypi_tags::{get_pypi_tags, is_python_record},
uv_reporter::{UvReporter, UvReporterOptions},
};
use pixi_consts::consts;
use pypi_modifiers::pypi_tags::{get_pypi_tags, is_python_record};

type CombinedPypiPackageData = (PypiPackageData, PypiPackageEnvironmentData);

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub mod task;
pub mod util;
pub mod utils;

mod pypi_marker_env;
mod pypi_tags;
mod uv_reporter;

mod fancy_display;
Expand Down
2 changes: 1 addition & 1 deletion src/lock_file/records_by_name.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::lock_file::{PypiPackageIdentifier, PypiRecord};
use crate::pypi_tags::is_python_record;
use pypi_modifiers::pypi_tags::is_python_record;
use rattler_conda_types::{PackageName, RepoDataRecord, VersionWithSource};
use std::borrow::Borrow;
use std::collections::hash_map::Entry;
Expand Down
4 changes: 2 additions & 2 deletions src/lock_file/resolve/pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::lock_file::LockedPypiPackages;
use crate::lock_file::{
package_identifier, PypiPackageIdentifier, PypiRecord, UvResolutionContext,
};
use crate::pypi_marker_env::determine_marker_environment;
use crate::pypi_tags::{get_pypi_tags, is_python_record};
use pypi_modifiers::pypi_marker_env::determine_marker_environment;
use pypi_modifiers::pypi_tags::{get_pypi_tags, is_python_record};

use distribution_types::{
BuiltDist, Dist, FlatIndexLocation, HashPolicy, IndexUrl, Name, Resolution, ResolvedDist,
Expand Down
3 changes: 2 additions & 1 deletion src/lock_file/satisfiability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ use uv_git::GitReference;
use uv_normalize::{ExtraName, PackageName};

use super::{PypiRecord, PypiRecordsByName, RepoDataRecordsByName};

use crate::{
project::{grouped_environment::GroupedEnvironment, has_features::HasFeatures, Environment},
pypi_marker_env::determine_marker_environment,
utils::uv::{as_uv_req, AsPep508Error},
};
use pypi_modifiers::pypi_marker_env::determine_marker_environment;

#[derive(Debug, Error, Diagnostic)]
pub enum EnvironmentUnsat {
Expand Down
4 changes: 2 additions & 2 deletions src/lock_file/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use miette::{IntoDiagnostic, LabeledSpan, MietteDiagnostic, WrapErr};
use parking_lot::Mutex;
use pixi_consts::consts;
use pixi_manifest::EnvironmentName;
use pypi_modifiers::pypi_marker_env::determine_marker_environment;
use pypi_modifiers::pypi_tags::is_python_record;
use rattler::package_cache::PackageCache;
use rattler_conda_types::{Arch, MatchSpec, Platform, RepoDataRecord};
use rattler_lock::{LockFile, PypiIndexes, PypiPackageData, PypiPackageEnvironmentData};
Expand Down Expand Up @@ -51,8 +53,6 @@ use crate::{
Environment,
},
pypi_mapping::{self, Reporter},
pypi_marker_env::determine_marker_environment,
pypi_tags::is_python_record,
Project,
};

Expand Down
24 changes: 1 addition & 23 deletions src/project/virtual_packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::project::errors::UnsupportedPlatformError;
use crate::project::Environment;
use itertools::Itertools;
use miette::Diagnostic;
use pixi_default_sys::{default_glibc_version, default_linux_version, default_mac_os_version};
use pixi_manifest::{LibCSystemRequirement, SystemRequirements};
use rattler_conda_types::{GenericVirtualPackage, Platform, Version};
use rattler_virtual_packages::{
Expand All @@ -11,29 +12,6 @@ use rattler_virtual_packages::{
use std::collections::HashMap;
use thiserror::Error;

/// The default GLIBC version to use. This is used when no system requirements are specified.
pub fn default_glibc_version() -> Version {
"2.28".parse().unwrap()
}

/// The default linux version to use. This is used when no system requirements are specified.
pub fn default_linux_version() -> Version {
"5.10".parse().unwrap()
}

/// Returns the default Mac OS version for the specified platform. The platform must refer to a
/// MacOS platform.
pub fn default_mac_os_version(platform: Platform) -> Version {
match platform {
Platform::OsxArm64 => "13.0".parse().unwrap(),
Platform::Osx64 => "13.0".parse().unwrap(),
_ => panic!(
"default_mac_os_version() called with non-osx platform: {}",
platform
),
}
}

/// Returns a reasonable modern set of virtual packages that should be safe enough to assume.
/// At the time of writing, this is in sync with the conda-lock set of minimal virtual packages.
/// <https://github.com/conda/conda-lock/blob/3d36688278ebf4f65281de0846701d61d6017ed2/conda_lock/virtual_package.py#L175>
Expand Down
Loading