mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-29 11:07:59 +00:00
Support build constraints (#5639)
## Summary Partially resolves #5561. Haven't added overrides support yet but I can add it tomorrow if the current approach for constraints is ok. ## Test Plan `cargo test` Manually checked trace logs after changing the constraints.
This commit is contained in:
parent
c558d70690
commit
ff9f3dede1
25 changed files with 360 additions and 4 deletions
|
|
@ -17,7 +17,7 @@ use uv_build::{SourceBuild, SourceBuildContext};
|
|||
use uv_cache::Cache;
|
||||
use uv_client::RegistryClient;
|
||||
use uv_configuration::{
|
||||
BuildKind, BuildOptions, ConfigSettings, IndexStrategy, Reinstall, SetupPyStrategy,
|
||||
BuildKind, BuildOptions, ConfigSettings, Constraints, IndexStrategy, Reinstall, SetupPyStrategy,
|
||||
};
|
||||
use uv_configuration::{Concurrency, PreviewMode};
|
||||
use uv_distribution::DistributionDatabase;
|
||||
|
|
@ -35,6 +35,7 @@ use uv_types::{BuildContext, BuildIsolation, EmptyInstalledPackages, HashStrateg
|
|||
pub struct BuildDispatch<'a> {
|
||||
client: &'a RegistryClient,
|
||||
cache: &'a Cache,
|
||||
constraints: Constraints,
|
||||
interpreter: &'a Interpreter,
|
||||
index_locations: &'a IndexLocations,
|
||||
index_strategy: IndexStrategy,
|
||||
|
|
@ -58,6 +59,7 @@ impl<'a> BuildDispatch<'a> {
|
|||
pub fn new(
|
||||
client: &'a RegistryClient,
|
||||
cache: &'a Cache,
|
||||
constraints: &'a [Requirement],
|
||||
interpreter: &'a Interpreter,
|
||||
index_locations: &'a IndexLocations,
|
||||
flat_index: &'a FlatIndex,
|
||||
|
|
@ -77,6 +79,7 @@ impl<'a> BuildDispatch<'a> {
|
|||
Self {
|
||||
client,
|
||||
cache,
|
||||
constraints: Constraints::from_requirements(constraints.iter().cloned()),
|
||||
interpreter,
|
||||
index_locations,
|
||||
flat_index,
|
||||
|
|
@ -140,8 +143,9 @@ impl<'a> BuildContext for BuildDispatch<'a> {
|
|||
let python_requirement = PythonRequirement::from_interpreter(self.interpreter);
|
||||
let markers = self.interpreter.markers();
|
||||
let tags = self.interpreter.tags()?;
|
||||
|
||||
let resolver = Resolver::new(
|
||||
Manifest::simple(requirements.to_vec()),
|
||||
Manifest::simple(requirements.to_vec()).with_constraints(self.constraints.clone()),
|
||||
OptionsBuilder::new()
|
||||
.exclude_newer(self.exclude_newer)
|
||||
.index_strategy(self.index_strategy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue