Skip to content

Commit 1e824d2

Browse files
committed
Add test to ensure a linux marked dep isn't added to an osx lockfile.
1 parent e3e2915 commit 1e824d2

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

crates/pixi/tests/integration_rust/pypi_tests.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,64 @@ index-url = "{index_url}"
164164
);
165165
}
166166

167+
#[tokio::test]
168+
async fn pyproject_environment_markers_considered() {
169+
setup_tracing();
170+
171+
let simple = PyPIDatabase::new()
172+
.with(PyPIPackage::new("numpy", "1.0.0").with_tag("cp311", "cp311", "manylinux1_x86_64"))
173+
.into_simple_index()
174+
.unwrap();
175+
176+
let platform = Platform::OsxArm64;
177+
let platform_str = platform.as_str();
178+
179+
let mut package_db = MockRepoData::default();
180+
package_db.add_package(
181+
Package::build("python", "3.11.0")
182+
.with_subdir(platform)
183+
.finish(),
184+
);
185+
let channel = package_db.into_channel().await.unwrap();
186+
let channel_url = channel.url();
187+
let index_url = simple.index_url();
188+
189+
let pyproject = format!(
190+
r#"
191+
[build-system]
192+
requires = ["setuptools"]
193+
build-backend = "setuptools.build_meta"
194+
195+
[project]
196+
name = "environment-markers"
197+
dependencies = [
198+
"numpy; sys_platform == 'linux'"
199+
]
200+
201+
[tool.pixi.workspace]
202+
channels = ["{channel_url}"]
203+
platforms = ["{platform_str}"]
204+
conda-pypi-map = {{}}
205+
206+
[tool.pixi.dependencies]
207+
python = "==3.11.0"
208+
209+
[tool.pixi.pypi-options]
210+
index-url = "{index_url}"
211+
"#,
212+
);
213+
214+
let pixi = PixiControl::from_pyproject_manifest(&pyproject).unwrap();
215+
216+
let lock = pixi.update_lock_file().await.unwrap();
217+
218+
let numpy_req = Requirement::from_str("numpy; sys_platform == 'linux'").unwrap();
219+
assert!(
220+
!lock.contains_pep508_requirement("default", platform, numpy_req.clone()),
221+
"default environment should include numpy"
222+
);
223+
}
224+
167225
#[tokio::test]
168226
async fn test_flat_links_based_index_returns_path() {
169227
setup_tracing();

0 commit comments

Comments
 (0)