Add --no-emit-project and friends to uv export (#7110)

## Summary

Like `uv sync`, you can omit the current project (`--no-emit-project`),
a specific package (`--no-emit-package`), or the entire workspace
(`--no-emit-workspace`).

Closes https://github.com/astral-sh/uv/issues/6960.

Closes #6995.
This commit is contained in:
Charlie Marsh 2024-09-05 21:01:46 -04:00 committed by GitHub
parent d0f9016eda
commit 6ae005b0d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 231 additions and 21 deletions

View file

@ -80,4 +80,29 @@ impl InstallOptions {
resolution.filter(|dist| !no_install_packages.contains(dist.name()))
}
/// Returns `true` if a package passes the install filters.
pub fn include_package(
&self,
package: &PackageName,
project_name: &PackageName,
members: &BTreeSet<PackageName>,
) -> bool {
// If `--no-install-project` is set, remove the project itself.
if self.no_install_project && package == project_name {
return false;
}
// If `--no-install-workspace` is set, remove the project and any workspace members.
if self.no_install_workspace && members.contains(package) {
return false;
}
// If `--no-install-package` is provided, remove the requested packages.
if self.no_install_package.contains(package) {
return false;
}
true
}
}