Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix/use_urls_for_ch…
Browse files Browse the repository at this point in the history
…annel
  • Loading branch information
baszalmstra committed May 28, 2024
2 parents 33195ad + 4e76c95 commit 716cae3
Show file tree
Hide file tree
Showing 20 changed files with 3,462 additions and 3,888 deletions.
10 changes: 8 additions & 2 deletions examples/linking/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ requirements:

tests:
- script:
- zlink
- ldd $PREFIX/bin/zlink
- if: linux
then:
- zlink
- ldd $PREFIX/bin/zlink
- if: osx
then:
- zlink
- otool -L $PREFIX/bin/zlink
6,761 changes: 3,081 additions & 3,680 deletions pixi.lock

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ install = "cargo install --path . --locked"
end_to_end_test = "pytest test/end-to-end -v -s"
test = "cargo test"
lint = "pre-commit run --all"

[feature.docs.tasks]
build-docs = "mkdocs build --strict"
docs = "mkdocs serve"
deploy-latest = "mike deploy --push --update-aliases $RELEASE_VERSION latest"
Expand All @@ -30,9 +32,14 @@ pytest = "7.4.2.*"
pyyaml = ">=6.0.1,<6.1"
conda-package-handling = "2.2.0.*"

# Documentation building
[feature.docs.dependencies]
mkdocs = "1.5.3.*"
mkdocs-material = ">=9.5.16,<9.7"
pillow = ">=9.4.0"
cairosvg = "2.7.1.*"
mike = "2.0.0.*"

[environments]
# Using same solve group to keep the environment consistent in versions used and improving cache hits
default = {solve-group = "default"}
docs = {features = ["docs"], no-default-feature = true, solve-group = "default"}
7 changes: 4 additions & 3 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ mod test {
use rattler_digest::{parse_digest_from_hex, Md5, Sha256};
use url::Url;

use crate::render::resolved_dependencies::{self, DependencyInfo};
use crate::render::resolved_dependencies::{self, SourceDependency};

use super::{Directories, Output};

Expand Down Expand Up @@ -665,9 +665,10 @@ mod test {
#[test]
fn test_resolved_dependencies_rendering() {
let resolved_dependencies = resolved_dependencies::ResolvedDependencies {
specs: vec![DependencyInfo::Raw {
specs: vec![SourceDependency {
spec: MatchSpec::from_str("python 3.12.* h12332", ParseStrictness::Strict).unwrap(),
}],
}
.into()],
resolved: vec![RepoDataRecord {
package_record: PackageRecord {
arch: Some("x86_64".into()),
Expand Down
8 changes: 3 additions & 5 deletions src/post_process/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use std::{
path::{Path, PathBuf},
};

use crate::post_process::{package_nature::PackageNature, relink};
use crate::{
metadata::Output,
post_process::{package_nature::PrefixInfo, relink::RelinkError},
};
use crate::{
post_process::{package_nature::PackageNature, relink},
render::resolved_dependencies::DependencyInfo,
};

use crate::render::resolved_dependencies::RunExportDependency;
use globset::{Glob, GlobSet, GlobSetBuilder};
use rattler_conda_types::{PackageName, PrefixRecord};

Expand Down Expand Up @@ -121,7 +119,7 @@ fn resolved_run_dependencies(
.depends
.iter()
.filter(|dep| {
if let DependencyInfo::RunExport { from, .. } = dep {
if let Some(RunExportDependency { from, .. }) = dep.as_run_export() {
from != &String::from("build")
} else {
true
Expand Down
11 changes: 5 additions & 6 deletions src/recipe/jinja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use minijinja::value::Object;
use minijinja::{Environment, Value};
use rattler_conda_types::{PackageName, ParseStrictness, Version};

use crate::render::pin::PinArgs;
pub use crate::render::pin::{Pin, PinExpression};
pub use crate::selectors::SelectorConfig;

Expand Down Expand Up @@ -95,9 +96,7 @@ fn jinja_pin_function(
// we translate the compiler into a YAML string
let mut pin_subpackage = Pin {
name,
max_pin: None,
min_pin: None,
exact: false,
args: PinArgs::default(),
};

let pin_expr_from_value = |pin_expr: &minijinja::value::Value| {
Expand All @@ -113,16 +112,16 @@ fn jinja_pin_function(
let max_pin = kwargs.get_attr("max_pin")?;
if max_pin != minijinja::value::Value::UNDEFINED {
let pin_expr = pin_expr_from_value(&max_pin)?;
pin_subpackage.max_pin = Some(pin_expr);
pin_subpackage.args.max_pin = Some(pin_expr);
}
let min = kwargs.get_attr("min_pin")?;
if min != minijinja::value::Value::UNDEFINED {
let pin_expr = pin_expr_from_value(&min)?;
pin_subpackage.min_pin = Some(pin_expr);
pin_subpackage.args.min_pin = Some(pin_expr);
}
let exact = kwargs.get_attr("exact")?;
if exact != minijinja::value::Value::UNDEFINED {
pin_subpackage.exact = exact.is_true();
pin_subpackage.args.exact = exact.is_true();
}
}

Expand Down
25 changes: 16 additions & 9 deletions src/recipe/parser/requirements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ mod test {
use std::str::FromStr;

use crate::recipe::jinja::PinExpression;
use crate::render::pin::PinArgs;

use super::*;

Expand Down Expand Up @@ -569,27 +570,33 @@ mod test {
let pin_subpackage = PinSubpackage {
pin_subpackage: Pin {
name: PackageName::from_str("foo").unwrap(),
max_pin: Some(PinExpression::from_str("x.x").unwrap()),
min_pin: Some(PinExpression::from_str("x.x.x.x").unwrap()),
exact: false,
args: PinArgs {
max_pin: Some(PinExpression::from_str("x.x").unwrap()),
min_pin: Some(PinExpression::from_str("x.x.x.x").unwrap()),
exact: false,
},
},
};

let pin_compatible = PinCompatible {
pin_compatible: Pin {
name: PackageName::from_str("bar").unwrap(),
max_pin: Some(PinExpression::from_str("x.x.x").unwrap()),
min_pin: Some(PinExpression::from_str("x.x").unwrap()),
exact: false,
args: PinArgs {
max_pin: Some(PinExpression::from_str("x.x.x").unwrap()),
min_pin: Some(PinExpression::from_str("x.x").unwrap()),
exact: false,
},
},
};

let pin_compatible_2 = PinCompatible {
pin_compatible: Pin {
name: PackageName::from_str("bar").unwrap(),
max_pin: None,
min_pin: Some(PinExpression::from_str("x.x").unwrap()),
exact: true,
args: PinArgs {
max_pin: None,
min_pin: Some(PinExpression::from_str("x.x").unwrap()),
exact: true,
},
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: src/recipe/parser/requirements.rs
assertion_line: 619
expression: "serde_yaml::to_string(&requirements).unwrap()"
---
build:
Expand All @@ -8,15 +9,12 @@ build:
name: foo
max_pin: x.x
min_pin: x.x.x.x
exact: false
- pin_compatible:
name: bar
max_pin: x.x.x
min_pin: x.x
exact: false
- pin_compatible:
name: bar
max_pin: null
min_pin: x.x
exact: true
- compiler: gcc
61 changes: 41 additions & 20 deletions src/render/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,23 @@ pub struct Pin {
/// The name of the package to pin
pub name: PackageName,

/// The pin arguments
#[serde(flatten)]
pub args: PinArgs,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PinArgs {
/// A pin to a version, using `x.x.x...` as syntax
#[serde(skip_serializing_if = "Option::is_none")]
pub max_pin: Option<PinExpression>,

/// A minimum pin to a version, using `x.x.x...` as syntax
#[serde(skip_serializing_if = "Option::is_none")]
pub min_pin: Option<PinExpression>,

/// If an exact pin is given, we pin the exact version & hash
#[serde(default)]
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub exact: bool,
}

Expand All @@ -73,7 +82,7 @@ impl Pin {
/// Apply the pin to a version and hash of a resolved package. If a max_pin, min_pin or exact 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 {
if self.args.exact {
return Ok(MatchSpec::from_str(
&format!("{} {} {}", self.name.as_normalized(), version, hash),
ParseStrictness::Strict,
Expand All @@ -86,6 +95,7 @@ impl Pin {

// extract same amount of digits as the pin expression (in the form of x.x.x) from version str
let min_pin = self
.args
.min_pin
.clone()
.unwrap_or_else(|| PinExpression("x.x.x.x.x.x".to_string()));
Expand All @@ -104,6 +114,7 @@ impl Pin {
spec.push_str(&format!(" >={}", pin));

let max_pin = self
.args
.max_pin
.clone()
.unwrap_or_else(|| PinExpression("x".to_string()));
Expand Down Expand Up @@ -143,13 +154,13 @@ impl Pin {
}

pub(crate) fn internal_repr(&self) -> String {
let max_pin_str = if let Some(max_pin) = &self.max_pin {
let max_pin_str = if let Some(max_pin) = &self.args.max_pin {
format!("{}", max_pin)
} else {
"".to_string()
};

let min_pin_str = if let Some(min_pin) = &self.min_pin {
let min_pin_str = if let Some(min_pin) = &self.args.min_pin {
format!("{}", min_pin)
} else {
"".to_string()
Expand All @@ -160,7 +171,7 @@ impl Pin {
self.name.as_normalized(),
max_pin_str,
min_pin_str,
self.exact
self.args.exact
)
}

Expand Down Expand Up @@ -194,9 +205,11 @@ impl Pin {
.expect("could not parse back package name from internal representation");
Pin {
name: package_name,
max_pin,
min_pin,
exact,
args: PinArgs {
max_pin,
min_pin,
exact,
},
}
}
}
Expand All @@ -209,9 +222,11 @@ mod test {
fn test_apply_pin() {
let pin = Pin {
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,
args: PinArgs {
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: false,
},
};

let version = Version::from_str("1.2.3").unwrap();
Expand All @@ -225,19 +240,23 @@ mod test {

let pin = Pin {
name: PackageName::from_str("foo").unwrap(),
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: None,
exact: false,
args: PinArgs {
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: None,
exact: false,
},
};

let spec = pin.apply(&version, hash).unwrap();
assert_eq!(spec.to_string(), "foo >=1.2.3,<1.2.4");

let pin = Pin {
name: PackageName::from_str("foo").unwrap(),
max_pin: None,
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: false,
args: PinArgs {
max_pin: None,
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: false,
},
};

let spec = pin.apply(&version, hash).unwrap();
Expand All @@ -248,9 +267,11 @@ mod test {
fn test_apply_exact_pin() {
let pin = Pin {
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,
args: PinArgs {
max_pin: Some(PinExpression("x.x.x".to_string())),
min_pin: Some(PinExpression("x.x.x".to_string())),
exact: true,
},
};

let version = Version::from_str("1.2.3").unwrap();
Expand Down
Loading

0 comments on commit 716cae3

Please sign in to comment.