mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Support uv export
for non-project workspaces (#10144)
Some checks are pending
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
This commit is contained in:
parent
ddde9481e3
commit
3435777e87
4 changed files with 516 additions and 31 deletions
|
@ -630,7 +630,7 @@ impl Lock {
|
|||
.iter()
|
||||
.copied()
|
||||
.map(|marker| SimplifiedMarkerTree::new(&self.requires_python, marker))
|
||||
.filter_map(super::requires_python::SimplifiedMarkerTree::try_to_string),
|
||||
.filter_map(SimplifiedMarkerTree::try_to_string),
|
||||
);
|
||||
doc.insert("supported-markers", value(supported_environments));
|
||||
}
|
||||
|
@ -3567,7 +3567,7 @@ struct Dependency {
|
|||
/// by assuming `requires-python` is satisfied. So if
|
||||
/// `requires-python = '>=3.8'`, then
|
||||
/// `python_version >= '3.8' and python_version < '3.12'`
|
||||
/// gets simplfiied to `python_version < '3.12'`.
|
||||
/// gets simplified to `python_version < '3.12'`.
|
||||
///
|
||||
/// Generally speaking, this marker should not be exposed to
|
||||
/// anything outside this module unless it's for a specialized use
|
||||
|
|
|
@ -19,7 +19,7 @@ use uv_pep508::MarkerTree;
|
|||
use uv_pypi_types::{ParsedArchiveUrl, ParsedGitUrl};
|
||||
|
||||
use crate::graph_ops::marker_reachability;
|
||||
use crate::lock::{Package, PackageId, Source};
|
||||
use crate::lock::{LockErrorKind, Package, PackageId, Source};
|
||||
use crate::universal_marker::{ConflictMarker, UniversalMarker};
|
||||
use crate::{InstallTarget, LockError};
|
||||
|
||||
|
@ -50,7 +50,7 @@ impl<'lock> RequirementsTxtExport<'lock> {
|
|||
|
||||
let root = petgraph.add_node(Node::Root);
|
||||
|
||||
// Add the workspace package to the queue.
|
||||
// Add the workspace packages to the queue.
|
||||
for root_name in target.packages() {
|
||||
if prune.contains(root_name) {
|
||||
continue;
|
||||
|
@ -135,6 +135,98 @@ impl<'lock> RequirementsTxtExport<'lock> {
|
|||
}
|
||||
}
|
||||
|
||||
// Add requirements that are exclusive to the workspace root (e.g., dependency groups in
|
||||
// (legacy) non-project workspace roots).
|
||||
let root_groups = target
|
||||
.groups()
|
||||
.map_err(|err| LockErrorKind::DependencyGroup { err })?;
|
||||
let root_requirements = {
|
||||
root_groups
|
||||
.iter()
|
||||
.filter_map(|(group, deps)| {
|
||||
if dev.contains(group) {
|
||||
Some(deps)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
.filter(|dep| !prune.contains(&dep.name))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
// Index the lockfile by package name, to avoid making multiple passes over the lockfile.
|
||||
if !root_requirements.is_empty() {
|
||||
let by_name: FxHashMap<_, Vec<_>> = {
|
||||
let names = root_requirements
|
||||
.iter()
|
||||
.map(|dep| &dep.name)
|
||||
.collect::<FxHashSet<_>>();
|
||||
target.lock().packages().iter().fold(
|
||||
FxHashMap::with_capacity_and_hasher(size_guess, FxBuildHasher),
|
||||
|mut map, package| {
|
||||
if names.contains(&package.id.name) {
|
||||
map.entry(&package.id.name).or_default().push(package);
|
||||
}
|
||||
map
|
||||
},
|
||||
)
|
||||
};
|
||||
|
||||
for requirement in root_requirements {
|
||||
for dist in by_name.get(&requirement.name).into_iter().flatten() {
|
||||
// Determine whether this entry is "relevant" for the requirement, by intersecting
|
||||
// the markers.
|
||||
let marker = if dist.fork_markers.is_empty() {
|
||||
requirement.marker
|
||||
} else {
|
||||
let mut combined = MarkerTree::FALSE;
|
||||
for fork_marker in &dist.fork_markers {
|
||||
combined.or(fork_marker.pep508());
|
||||
}
|
||||
combined.and(requirement.marker);
|
||||
combined
|
||||
};
|
||||
|
||||
// Simplify the marker.
|
||||
let marker = target.lock().simplify_environment(marker);
|
||||
|
||||
// Add the dependency to the graph.
|
||||
if let Entry::Vacant(entry) = inverse.entry(&dist.id) {
|
||||
entry.insert(petgraph.add_node(Node::Package(dist)));
|
||||
}
|
||||
|
||||
// Add an edge from the root.
|
||||
let dep_index = inverse[&dist.id];
|
||||
petgraph.add_edge(
|
||||
root,
|
||||
dep_index,
|
||||
UniversalMarker::new(
|
||||
marker,
|
||||
// OK because we've verified above that we do not have any
|
||||
// conflicting extras/groups.
|
||||
//
|
||||
// So why use `UniversalMarker`? Because that's what
|
||||
// `marker_reachability` wants and it (probably) isn't
|
||||
// worth inventing a new abstraction so that it can accept
|
||||
// graphs with either `MarkerTree` or `UniversalMarker`.
|
||||
ConflictMarker::TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
// Push its dependencies on the queue.
|
||||
if seen.insert((&dist.id, None)) {
|
||||
queue.push_back((dist, None));
|
||||
}
|
||||
for extra in &requirement.extras {
|
||||
if seen.insert((&dist.id, Some(extra))) {
|
||||
queue.push_back((dist, Some(extra)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create all the relevant nodes.
|
||||
while let Some((package, extra)) = queue.pop_front() {
|
||||
let index = inverse[&package.id];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue