Skip to content
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
9 changes: 8 additions & 1 deletion crates/uv/src/commands/pip/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub(crate) async fn pip_compile(
excludes_from_workspace: Vec<uv_normalize::PackageName>,
build_constraints_from_workspace: Vec<Requirement>,
environments: SupportedEnvironments,
required_environments: SupportedEnvironments,
extras: ExtrasSpecification,
groups: GroupsSpecification,
output_file: Option<&Path>,
Expand Down Expand Up @@ -385,7 +386,13 @@ pub(crate) async fn pip_compile(
};

let artifact_environments = if universal {
environments.clone()
SupportedEnvironments::from_markers(
environments
.iter()
.chain(required_environments.iter())
.copied()
.collect(),
)
} else {
SupportedEnvironments::default()
};
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.excludes_from_workspace,
args.build_constraints_from_workspace,
args.environments,
args.required_environments,
args.settings.extras,
groups,
args.settings.output_file.as_deref(),
Expand Down
11 changes: 11 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2777,6 +2777,7 @@ pub(crate) struct PipCompileSettings {
pub(crate) excludes_from_workspace: Vec<PackageName>,
pub(crate) build_constraints_from_workspace: Vec<Requirement>,
pub(crate) environments: SupportedEnvironments,
pub(crate) required_environments: SupportedEnvironments,
pub(crate) refresh: Refresh,
pub(crate) settings: PipSettings,
}
Expand Down Expand Up @@ -2899,6 +2900,15 @@ impl PipCompileSettings {
SupportedEnvironments::default()
};

let required_environments = if let Some(configuration) = &filesystem {
configuration
.required_environments
.clone()
.unwrap_or_default()
} else {
SupportedEnvironments::default()
};

Self {
format,
src_file,
Expand All @@ -2923,6 +2933,7 @@ impl PipCompileSettings {
excludes_from_workspace,
build_constraints_from_workspace,
environments,
required_environments,
refresh: Refresh::from(refresh),
settings: PipSettings::combine(
PipOptions {
Expand Down
53 changes: 53 additions & 0 deletions crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14369,6 +14369,59 @@ fn universal_constrained_environment() -> Result<()> {
Ok(())
}

/// Resolve with `--universal`, requiring artifact coverage for user-provided environments.
#[test]
fn universal_required_environment() -> Result<()> {
let context = uv_test::test_context!("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(&indoc::formatdoc! {r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["no-sdist-no-wheels-with-matching-platform-a"]

[tool.uv]
required-environments = ["platform_machine == 'arm64'"]

[[tool.uv.index]]
name = "packse"
url = "{}"
default = true
"#,
packse_index_url()
})?;

let filters: Vec<_> = context
.filters()
.into_iter()
.chain([(
// This hint is only shown when the current platform doesn't match the target.
r"\n\n\s+hint: The resolution failed for an environment that is not the current one[^\n]*",
"",
)])
.collect();

uv_snapshot!(filters, context.pip_compile()
.arg("pyproject.toml")
.arg("--universal")
.arg("--exclude-newer-package")
.arg("no-sdist-no-wheels-with-matching-platform-a=false")
.env_remove(EnvVars::UV_EXCLUDE_NEWER), @"
success: false
exit_code: 1
----- stdout -----

----- stderr -----
× No solution found when resolving dependencies for split (markers: platform_machine == 'arm64'):
╰─▶ Because only no-sdist-no-wheels-with-matching-platform-a==1.0.0 is available and no-sdist-no-wheels-with-matching-platform-a==1.0.0 has no `platform_machine == 'arm64'`-compatible wheels, we can conclude that all versions of no-sdist-no-wheels-with-matching-platform-a cannot be used.
And because project depends on no-sdist-no-wheels-with-matching-platform-a, we can conclude that your requirements are unsatisfiable.
");

Ok(())
}

/// Resolve a package that has no versions that satisfy the current Python version.
#[test]
fn compile_enumerate_no_versions() -> Result<()> {
Expand Down
Loading
Loading