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

feat: implement CEP-17 and prepare release #1161

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
971 changes: 509 additions & 462 deletions Cargo.lock

Large diffs are not rendered by default.

59 changes: 31 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["rust-tests"]

[package]
name = "rattler-build"
version = "0.28.2"
version = "0.29.0"
authors = ["rattler-build contributors <hi@prefix.dev>"]
homepage = "https://github.com/prefix-dev/rattler-build"
edition = "2021"
Expand Down Expand Up @@ -45,22 +45,22 @@ name = "rattler-build"
required-features = ["recipe-generation"]

[dependencies]
serde = { version = "1.0.213", features = ["derive"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_yaml = "0.9.34"
serde-untagged = "0.1.6"
anyhow = "1.0.91"
anyhow = "1.0.92"
walkdir = "2.5.0"
sha2 = "0.10.8"
hex = "0.4.3"
serde_json = "1.0.132"
reqwest = { version = "0.12.8", default-features = false, features = [
reqwest = { version = "0.12.9", default-features = false, features = [
"multipart",
] }
tokio = { version = "1.41.0", features = ["rt", "macros", "rt-multi-thread", "process"] }
itertools = "0.13.0"
content_inspector = "0.2.4"
serde_with = "3.11.0"
url = "2.5.2"
url = "2.5.3"
tracing = "0.1.40"
clap = { version = "4.5.20", features = ["derive", "env", "cargo"] }
minijinja = { version = "2.4.0", features = [
Expand All @@ -76,14 +76,14 @@ tracing-subscriber = { version = "0.3.18", features = [
marked-yaml = { version = "0.7.1" }
miette = { version = "7.2.0", features = ["fancy"] }
num_cpus = "1.16.0"
goblin = "0.9.1"
goblin = "0.9.2"
scroll = "0.12.0"
pathdiff = "0.2.2"
comfy-table = "7.1.1"
futures = "0.3.31"
indicatif = "0.17.8"
console = { version = "0.15.8", features = ["windows-console-colors"] }
thiserror = "1.0.65"
thiserror = "1.0.68"
tempfile = "3.13.0"
chrono = "0.4.38"
sha1 = "0.10.6"
Expand All @@ -96,12 +96,12 @@ petgraph = "0.6.5"
indexmap = "2.6.0"
dunce = "1.0.5"
fs-err = "3.0.0"
which = "6.0.3"
clap_complete = "4.5.35"
which = "7.0.0"
clap_complete = "4.5.37"
clap_complete_nushell = "4.5.4"
tokio-util = "0.7.12"

tar = "0.4.42"
tar = "0.4.43"
zip = { version = "2.2.0", default-features = false, features = [
"flate2",
"deflate",
Expand All @@ -118,34 +118,34 @@ rattler_installs_packages = { version = "0.9.0", default-features = false, optio
async-once-cell = "0.5.4"
terminal_size = "0.4.0"
memchr = "2.7.4"
ratatui = { version = "0.28.1", optional = true }
ratatui = { version = "0.29.0", optional = true }
crossterm = { version = "0.28.1", features = ["event-stream"], optional = true }
ansi-to-tui = { version = "6.0.1", optional = true }
throbber-widgets-tui = { version = "0.7", optional = true }
tui-input = { version = "0.10.1", optional = true }
ansi-to-tui = { version = "7.0.0", optional = true }
throbber-widgets-tui = { version = "0.8", optional = true }
tui-input = { version = "0.11.0", optional = true }
reflink-copy = "0.1.19"
rayon = "1.10.0"
patch = "0.7.0"
regex = "1.11.1"
async-recursion = "1.1.1"

# Rattler crates
rattler = { version = "0.27.16", default-features = false, features = ["cli-tools", "indicatif"] }
rattler_cache = { version = "0.2.7", default-features = false }
rattler_conda_types = { version = "0.28.3", default-features = false }
rattler_digest = { version = "1.0.2", default-features = false, features = ["serde"] }
rattler_index = { version = "0.19.33", default-features = false }
rattler_networking = { version = "0.21.4", default-features = false }
rattler_redaction = { version = "0.1.2" }
rattler_repodata_gateway = { version = "0.21.18", default-features = false, features = ["gateway"] }
rattler_shell = { version = "0.22.4", default-features = false, features = ["sysinfo"] }
rattler_solve = { version = "1.1.0", default-features = false, features = ["resolvo", "serde"] }
rattler_virtual_packages = { version = "1.1.7", default-features = false }
rattler_package_streaming = { version = "0.22.10", default-features = false }
rattler = { version = "0.28.0", default-features = false, features = ["cli-tools", "indicatif"] }
rattler_cache = { version = "0.2.8", default-features = false }
rattler_conda_types = { version = "0.29.0", default-features = false }
rattler_digest = { version = "1.0.3", default-features = false, features = ["serde"] }
rattler_index = { version = "0.19.34", default-features = false }
rattler_networking = { version = "0.21.5", default-features = false }
rattler_redaction = { version = "0.1.3" }
rattler_repodata_gateway = { version = "0.21.19", default-features = false, features = ["gateway"] }
rattler_shell = { version = "0.22.5", default-features = false, features = ["sysinfo"] }
rattler_solve = { version = "1.2.0", default-features = false, features = ["resolvo", "serde"] }
rattler_virtual_packages = { version = "1.1.8", default-features = false }
rattler_package_streaming = { version = "0.22.11", default-features = false }
lazy_static = "1.5.0"

[dev-dependencies]
insta = { version = "1.40.0", features = ["yaml"] }
insta = { version = "1.41.1", features = ["yaml"] }
rstest = "0.23.0"
tracing-test = "0.2.5"
tracing-indicatif = "0.3.6"
Expand All @@ -165,7 +165,10 @@ pre-build = [
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH",
]

# [patch.crates-io]
[patch.crates-io]
# this fork contains fixes for slow zip reading and large file writing
zip = { git = "https://github.com/wolfv/zip2", branch = "patched"}

# rattler = { git = "https://github.com/nichmor/rattler", branch = "feat/add-extra-field-on-about-json" }
# rattler_conda_types = { git = "https://github.com/nichmor/rattler", branch = "feat/add-extra-field-on-about-json" }
# rattler_digest = { git = "https://github.com/nichmor/rattler", branch = "feat/add-extra-field-on-about-json" }
Expand Down
2 changes: 1 addition & 1 deletion rust-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
glob = "0.3.1"
rattler_package_streaming = { version = "0.22.10", default-features = false }
rattler_package_streaming = { version = "0.22.11", default-features = false }
serde_json = "1.0.132"
sha1 = "0.10.6"
duct = "0.13.7"
1 change: 1 addition & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ mod test {
version: VersionWithSource::from_str("1.2.3").unwrap(),
purls: None,
run_exports: None,
python_site_packages_path: None,
},
file_name: "test-1.2.3-h123.tar.bz2".into(),
url: Url::from_str("https://test.com/test/linux-64/test-1.2.3-h123.tar.bz2")
Expand Down
3 changes: 3 additions & 0 deletions src/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub enum PackagingError {

#[error("No license files were copied")]
LicensesNotFound,

#[error("Invalid Metadata: {0}")]
InvalidMetadata(String),
}

/// This function copies the license files to the info/licenses folder.
Expand Down
7 changes: 7 additions & 0 deletions src/packaging/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ impl Output {
})
.unwrap_or_default();

if recipe.build().python().site_packages_path.is_some() {
// check that the package name is Python, otherwise fail
if self.name().as_normalized() != "python" {
return Err(PackagingError::InvalidMetadata("Cannot set python_site_packages_path for a package that is not called `python`".to_string()));
}
}
Ok(IndexJson {
name: self.name().clone(),
version: self.version().clone().into(),
Expand Down Expand Up @@ -301,6 +307,7 @@ impl Output {
noarch: *recipe.build().noarch(),
track_features,
features: None,
python_site_packages_path: recipe.build().python().site_packages_path.clone(),
})
}

Expand Down
18 changes: 10 additions & 8 deletions src/post_process/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,22 @@ pub(crate) fn create_entry_points(
)
})?;

let python_version = python_record.package_record.version.clone();
// using target_platform is OK because this should never be noarch
let python_info =
PythonInfo::from_python_record(&python_record.package_record, *output.target_platform())
.map_err(|e| {
PackagingError::CannotCreateEntryPoint(format!(
"Could not create python info: {}",
e
))
})?;

for ep in &output.recipe.build().python().entry_points {
let script = python_entry_point_template(
&output.prefix().to_string_lossy(),
output.target_platform().is_windows(),
ep,
// using target_platform is OK because this should never be noarch
&PythonInfo::from_version(&python_version, *output.target_platform()).map_err(|e| {
PackagingError::CannotCreateEntryPoint(format!(
"Could not create python info: {}",
e
))
})?,
&python_info,
);

if output.target_platform().is_windows() {
Expand Down
11 changes: 10 additions & 1 deletion src/recipe/parser/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ pub struct Python {
/// This is only relevant for macOS.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub use_python_app_entrypoint: bool,

/// The relative site-packages path that a Python build _exports_ for other
/// packages to use. This setting only makes sense for the `python` package
/// itself. For example, a python 3.13 version could advertise a
/// site-packages path of `lib/python3.13/site-packages` for `noarch:
/// python` packages to use.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub site_packages_path: Option<String>,
}

impl Python {
Expand All @@ -520,7 +528,8 @@ impl TryConvertNode<Python> for RenderedMappingNode {
self.iter(),
entry_points,
skip_pyc_compilation,
use_python_app_entrypoint
use_python_app_entrypoint,
site_packages_path
);
Ok(python)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ build:
skip_pyc_compilation:
- test/bla/**/*.py
use_python_app_entrypoint: true
site_packages_path: foo/bar/lib/python4.5/site-packages
dynamic_linking:
rpaths:
- lib/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Recipe {
entry_points: [],
skip_pyc_compilation: [],
use_python_app_entrypoint: false,
site_packages_path: None,
},
dynamic_linking: DynamicLinking {
rpaths: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Recipe {
entry_points: [],
skip_pyc_compilation: [],
use_python_app_entrypoint: false,
site_packages_path: None,
},
dynamic_linking: DynamicLinking {
rpaths: [],
Expand Down
1 change: 1 addition & 0 deletions test-data/recipes/test-parsing/single_output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ build:
skip_pyc_compilation:
- test/bla/**/*.py
use_python_app_entrypoint: true
site_packages_path: foo/bar/lib/python4.5/site-packages

always_copy_files:
- file1
Expand Down
Loading