Skip to content

Commit

Permalink
fix: fixes actual wheel building (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager authored Nov 27, 2023
1 parent 4c8d8bc commit a791a50
Show file tree
Hide file tree
Showing 6 changed files with 789 additions and 9 deletions.
48 changes: 46 additions & 2 deletions crates/rattler_installs_packages/src/sdist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ mod tests {
}

#[tokio::test(flavor = "multi_thread")]
pub async fn build_rich() {
pub async fn sdist_metadata() {
let path =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/sdists/rich-13.6.0.tar.gz");

let sdist = super::SDist::from_path(&path, &"rich".parse().unwrap()).unwrap();
let sdist = SDist::from_path(&path, &"rich".parse().unwrap()).unwrap();

let package_db = get_package_db();
let env_markers = Pep508EnvMakers::from_env().await.unwrap();
Expand All @@ -254,4 +254,48 @@ mod tests {

assert_debug_snapshot!(result.1);
}

#[tokio::test(flavor = "multi_thread")]
pub async fn build_rich_with_metadata() {
let path =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/sdists/rich-13.6.0.tar.gz");

let sdist = SDist::from_path(&path, &"rich".parse().unwrap()).unwrap();

let package_db = get_package_db();
let env_markers = Pep508EnvMakers::from_env().await.unwrap();
let resolve_options = ResolveOptions::default();
let wheel_builder = WheelBuilder::new(&package_db.0, &env_markers, None, &resolve_options);

// Build the wheel
wheel_builder.get_sdist_metadata(&sdist).await.unwrap();
let result = wheel_builder.build_wheel(&sdist).await.unwrap();

// Try to re-open the wheel
let wheel = crate::wheel::Wheel::from_path(&result, &"rich".parse().unwrap()).unwrap();

let (_, metadata) = wheel.metadata().unwrap();
assert_debug_snapshot!(metadata);
}
#[tokio::test(flavor = "multi_thread")]
pub async fn build_rich_no_metadata() {
let path =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/sdists/rich-13.6.0.tar.gz");

let sdist = SDist::from_path(&path, &"rich".parse().unwrap()).unwrap();

let package_db = get_package_db();
let env_markers = Pep508EnvMakers::from_env().await.unwrap();
let resolve_options = ResolveOptions::default();
let wheel_builder = WheelBuilder::new(&package_db.0, &env_markers, None, &resolve_options);

// Build the wheel
let result = wheel_builder.build_wheel(&sdist).await.unwrap();

// Try to re-open the wheel
let wheel = crate::wheel::Wheel::from_path(&result, &"rich".parse().unwrap()).unwrap();

let (_, metadata) = wheel.metadata().unwrap();
assert_debug_snapshot!(metadata);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
---
source: crates/rattler_installs_packages/src/sdist.rs
expression: metadata
---
WheelCoreMetadata {
name: PackageName {
source: "rich",
normalized: "rich",
},
version: Version {
epoch: 0,
release: [
13,
6,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
metadata_version: MetadataVersion(
Version {
epoch: 0,
release: [
2,
1,
],
pre: None,
post: None,
dev: None,
local: None,
},
),
requires_dist: [
Requirement {
name: "ipywidgets",
extras: None,
version_or_url: Some(
VersionSpecifier(
VersionSpecifiers(
[
VersionSpecifier {
operator: GreaterThanEqual,
version: Version {
epoch: 0,
release: [
7,
5,
1,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
VersionSpecifier {
operator: LessThan,
version: Version {
epoch: 0,
release: [
9,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
],
),
),
),
marker: Some(
Expression(
MarkerExpression {
l_value: Extra,
operator: Equal,
r_value: QuotedString(
"jupyter",
),
},
),
),
},
Requirement {
name: "markdown-it-py",
extras: None,
version_or_url: Some(
VersionSpecifier(
VersionSpecifiers(
[
VersionSpecifier {
operator: GreaterThanEqual,
version: Version {
epoch: 0,
release: [
2,
2,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
],
),
),
),
marker: None,
},
Requirement {
name: "pygments",
extras: None,
version_or_url: Some(
VersionSpecifier(
VersionSpecifiers(
[
VersionSpecifier {
operator: GreaterThanEqual,
version: Version {
epoch: 0,
release: [
2,
13,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
VersionSpecifier {
operator: LessThan,
version: Version {
epoch: 0,
release: [
3,
0,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
],
),
),
),
marker: None,
},
Requirement {
name: "typing-extensions",
extras: None,
version_or_url: Some(
VersionSpecifier(
VersionSpecifiers(
[
VersionSpecifier {
operator: GreaterThanEqual,
version: Version {
epoch: 0,
release: [
4,
0,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
VersionSpecifier {
operator: LessThan,
version: Version {
epoch: 0,
release: [
5,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
],
),
),
),
marker: Some(
Expression(
MarkerExpression {
l_value: MarkerEnvVersion(
PythonVersion,
),
operator: LessThan,
r_value: QuotedString(
"3.9",
),
},
),
),
},
],
requires_python: Some(
VersionSpecifiers(
[
VersionSpecifier {
operator: GreaterThanEqual,
version: Version {
epoch: 0,
release: [
3,
7,
0,
],
pre: None,
post: None,
dev: None,
local: None,
},
},
],
),
),
extras: {
Extra {
source: "jupyter",
normalized: "jupyter",
},
},
}
Loading

0 comments on commit a791a50

Please sign in to comment.