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

update to the latest rattler version #180

Merged
merged 4 commits into from
Sep 12, 2023
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
651 changes: 289 additions & 362 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ native-tls = ['reqwest/native-tls', 'rattler/native-tls']
rustls-tls = ['reqwest/rustls-tls', 'rattler/rustls-tls']

[dependencies]
serde = { version = "1.0.171", features = ["derive"] }
serde_yaml = "0.9.24"
serde = { version = "1.0.188", features = ["derive"] }
serde_yaml = "0.9.25"
rattler_conda_types = { git = "https://github.com/mamba-org/rattler", branch = "main", default-features = false }
rattler_package_streaming = { git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_digest = { git = "https://github.com/mamba-org/rattler", branch = "main" }
Expand All @@ -34,41 +34,41 @@ rattler_networking = { git = "https://github.com/mamba-org/rattler", branch = "m
# rattler_shell = { path = "../rattler/crates/rattler_shell" }
# rattler_virtual_packages = { path = "../rattler/crates/rattler_virtual_packages" }
# rattler_networking = { path = "../rattler/crates/rattler_networking" }
anyhow = "1.0.72"
anyhow = "1.0.75"
walkdir = "2.3.3"
sha2 = "0.10.7"
hex = "0.4.3"
serde_json = "1.0.103"
serde_json = "1.0.105"
tempdir = "0.3.7"
reqwest = "0.11.18"
tokio = {version = "1.29.1", features = ["rt", "macros", "rt-multi-thread"] }
reqwest = "0.11.20"
tokio = {version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] }
itertools = "0.11.0"
content_inspector = "0.2.4"
serde_with = "3.1.0"
url = "2.4.0"
serde_with = "3.3.0"
url = "2.4.1"
tracing = "0.1.37"
clap = { version = "4.3.16", features = ["derive", "env", "cargo"] }
minijinja = { version = "1.0.5", features = ["unstable_machinery"] }
clap = { version = "4.4.2", features = ["derive", "env", "cargo"] }
minijinja = { version = "1.0.7", features = ["unstable_machinery"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
num_cpus = "1.16.0"
goblin = "0.7.1"
scroll = "0.11.0"
pathdiff = "0.2.1"
comfy-table = "7.0.1"
futures = "0.3.28"
indicatif = "0.17.5"
indicatif = "0.17.6"
console = { version = "0.15.7", features = ["windows-console-colors"] }
once_cell = "1.18.0"
thiserror = "1.0.43"
tempfile = "3.6.0"
chrono = "0.4.26"
thiserror = "1.0.48"
tempfile = "3.8.0"
chrono = "0.4.28"
sha1 = "0.10.5"
git2 = { version = "0.17.2", features = ["vendored-openssl"] }
fs_extra = "1.3.0"

[dev-dependencies]
insta = {version = "1.31.0", features = ["yaml"] }
rstest = "0.18.1"
rstest = "0.18.2"

[profile.dev.package."*"]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pub fn vars(output: &Output, build_state: &str) -> HashMap<String, String> {
}

// pkg vars
insert!(vars, "PKG_NAME", output.name());
insert!(vars, "PKG_NAME", output.name().as_normalized());
insert!(vars, "PKG_VERSION", output.version());
insert!(vars, "PKG_BUILDNUM", output.recipe.build.number.to_string());

Expand Down
1 change: 1 addition & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ pub fn index(
let mut repodata = RepoData {
info: Some(ChannelInfo {
subdir: platform.clone(),
base_url: None,
}),
packages: Default::default(),
conda_packages: Default::default(),
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ async fn run_build_from_args(args: BuildOpts) -> anyhow::Result<()> {
hash: hash::compute_buildstring(&variant, &noarch_type),
variant: variant.clone(),
no_clean: args.keep_build,
directories: Directories::create(&name, &recipe_path, &args.output_dir)?,
directories: Directories::create(
name.as_normalized(),
&recipe_path,
&args.output_dir,
)?,
channels,
timestamp: chrono::Utc::now(),
subpackages,
Expand Down
15 changes: 8 additions & 7 deletions src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! All the metadata that makes up a recipe file
use rattler_conda_types::package::EntryPoint;
use rattler_conda_types::NoArchType;
use rattler_conda_types::PackageName;
use rattler_conda_types::Platform;
use serde::{Deserialize, Serialize};
use serde_with::formats::PreferOne;
Expand Down Expand Up @@ -173,9 +174,9 @@ pub struct BuildOptions {
#[serde(skip_serializing_if = "ScriptEnv::is_empty", default)]
pub script_env: ScriptEnv,
/// A recipe can choose to ignore certain run exports of its dependencies
pub ignore_run_exports: Option<Vec<String>>,
pub ignore_run_exports: Option<Vec<PackageName>>,
/// A recipe can choose to ignore all run exports of coming from some packages
pub ignore_run_exports_from: Option<Vec<String>>,
pub ignore_run_exports_from: Option<Vec<PackageName>>,
/// The recipe can specify a list of run exports that it provides
pub run_exports: Option<RunExports>,
/// A noarch package runs on any platform. It can be either a python package or a generic package.
Expand Down Expand Up @@ -438,7 +439,7 @@ pub struct BuildConfiguration {
/// The timestamp to use for the build
pub timestamp: chrono::DateTime<chrono::Utc>,
/// All subpackages coming from this output or other outputs from the same recipe
pub subpackages: BTreeMap<String, PackageIdentifier>,
pub subpackages: BTreeMap<PackageName, PackageIdentifier>,
}

impl BuildConfiguration {
Expand All @@ -451,14 +452,14 @@ impl BuildConfiguration {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Package {
/// The name of the package
pub name: String,
pub name: PackageName,
/// The version of the package
pub version: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PackageIdentifier {
pub name: String,
pub name: PackageName,
pub version: String,
pub build_string: String,
}
Expand Down Expand Up @@ -499,7 +500,7 @@ pub struct Output {
}

impl Output {
pub fn name(&self) -> &str {
pub fn name(&self) -> &PackageName {
&self.recipe.package.name
}

Expand All @@ -517,7 +518,7 @@ impl Display for Output {
writeln!(
f,
"\nOutput: {}-{}-{}\n",
self.name(),
self.name().as_normalized(),
self.version(),
self.build_string()
)?;
Expand Down
6 changes: 3 additions & 3 deletions src/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn create_index_json(output: &Output) -> Result<String, PackagingError> {
};

let index_json = IndexJson {
name: output.name().to_string(),
name: output.name().clone(),
version: output.version().parse()?,
build: output.build_string().to_string(),
build_number: recipe.build.number,
Expand Down Expand Up @@ -635,7 +635,7 @@ pub fn package_conda(
return Err(PackagingError::DependenciesNotFinalized);
}

let tmp_dir = TempDir::new(output.name())?;
let tmp_dir = TempDir::new(output.name().as_normalized())?;
let tmp_dir_path = tmp_dir.path();

let mut tmp_files = HashSet::new();
Expand Down Expand Up @@ -749,7 +749,7 @@ pub fn package_conda(
// TODO get proper hash
let file = format!(
"{}-{}-{}.tar.bz2",
output.name(),
output.name().as_normalized(),
output.version(),
output.build_string()
);
Expand Down
2 changes: 1 addition & 1 deletion src/render/dependency_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ mod tests {
Dependency::PinSubpackage(p) => p,
_ => panic!("Expected PinSubpackage"),
};
assert_eq!(p.pin_subpackage.name, "super-package");
assert_eq!(p.pin_subpackage.name.as_normalized(), "super-package");
assert_eq!(
p.pin_subpackage.max_pin.as_ref().unwrap().to_string(),
"x.x"
Expand Down
39 changes: 23 additions & 16 deletions src/render/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
str::FromStr,
};

use rattler_conda_types::{MatchSpec, Version};
use rattler_conda_types::{MatchSpec, PackageName, Version};
use serde::{de, Deserialize, Deserializer, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Display for PinExpression {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pin {
/// The name of the package to pin
pub name: String,
pub name: PackageName,

/// A pin to a version, using `x.x.x...` as syntax
pub max_pin: Option<PinExpression>,
Expand Down Expand Up @@ -73,13 +73,16 @@ impl Pin {
/// are given, the pin is applied to the version accordingly.
pub fn apply(&self, version: &Version, hash: &str) -> Result<MatchSpec, PinError> {
if self.exact {
return Ok(
MatchSpec::from_str(&format!("{} {} {}", self.name, version, hash))
// TODO use MatchSpecError when it becomes accessible
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?,
);
return Ok(MatchSpec::from_str(&format!(
"{} {} {}",
self.name.as_normalized(),
version,
hash
))
// TODO use MatchSpecError when it becomes accessible
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?);
}
let mut spec = self.name.clone();
let mut spec = self.name.as_normalized().to_string();
let version_str = version.to_string();

// extract same amount of digits as the pin expression (in the form of x.x.x) from version str
Expand Down Expand Up @@ -136,7 +139,7 @@ impl Pin {
spec.push(',');
spec.push_str(&format!("<{}", pin));

Ok(MatchSpec::from_str(&spec)
Ok(MatchSpec::from_str(spec.as_str())
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?)
}

Expand All @@ -155,7 +158,10 @@ impl Pin {

format!(
"{} MAX_PIN={} MIN_PIN={} EXACT={}",
self.name, max_pin_str, min_pin_str, self.exact
self.name.as_normalized(),
max_pin_str,
min_pin_str,
self.exact
)
}

Expand All @@ -179,9 +185,10 @@ impl Pin {
};

let exact = exact == "EXACT=true";

let package_name = PackageName::try_from(name)
.expect("could not parse back package name from internal representation");
Pin {
name,
name: package_name,
max_pin,
min_pin,
exact,
Expand All @@ -196,7 +203,7 @@ mod test {
#[test]
fn test_apply_pin() {
let pin = Pin {
name: "foo".to_string(),
name: PackageName::from_str("foo").unwrap(),
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: false,
Expand All @@ -212,7 +219,7 @@ mod test {
assert_eq!(spec.to_string(), "foo >=1,<1.0.1");

let pin = Pin {
name: "foo".to_string(),
name: PackageName::from_str("foo").unwrap(),
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: None,
exact: false,
Expand All @@ -222,7 +229,7 @@ mod test {
assert_eq!(spec.to_string(), "foo >=1.2.3,<1.2.4");

let pin = Pin {
name: "foo".to_string(),
name: PackageName::from_str("foo").unwrap(),
max_pin: None,
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: false,
Expand All @@ -235,7 +242,7 @@ mod test {
#[test]
fn test_apply_exact_pin() {
let pin = Pin {
name: "foo".to_string(),
name: PackageName::from_str("foo").unwrap(),
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: true,
Expand Down
10 changes: 9 additions & 1 deletion src/render/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mod functions {
use std::str::FromStr;

use minijinja::Error;
use rattler_conda_types::PackageName;

use crate::render::pin::{Pin, PinExpression};

Expand All @@ -66,8 +67,15 @@ mod functions {
kwargs: Option<minijinja::value::Value>,
) -> Result<String, Error> {
// we translate the compiler into a YAML string
let package_name = PackageName::try_from(name).map_err(|e| {
Error::new(
minijinja::ErrorKind::SyntaxError,
format!("Invalid package name in pin_subpackage: {}", e),
)
})?;

let mut pin_subpackage = Pin {
name,
name: package_name,
max_pin: None,
min_pin: None,
exact: false,
Expand Down
Loading
Loading