mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-28 10:50:29 +00:00
Implement pip compatible --no-binary and --only-binary options (#1268)
Updates our `--no-binary` option and adds a `--only-binary` option for compatibility with `pip` which uses `:all:`, `:none:` and `<name>` for specifying packages. This required adding support for `--only-binary <name>` into our resolver, previously it was only a boolean toggle. Retains`--no-build` which is equivalent to `--only-binary :all:`. This is common enough for safety that I would prefer it is available without pip's awkward `:all:` syntax. --------- Co-authored-by: konsti <konstin@mailbox.org>
This commit is contained in:
parent
d98b3c3070
commit
a37b08808e
17 changed files with 440 additions and 141 deletions
|
|
@ -27,7 +27,7 @@ use puffin_cache::{
|
|||
use puffin_client::{CacheControl, CachedClient, CachedClientError, DataWithCachePolicy};
|
||||
use puffin_fs::{write_atomic, LockedFile};
|
||||
use puffin_git::{Fetch, GitSource};
|
||||
use puffin_traits::{BuildContext, BuildKind, SourceBuildTrait};
|
||||
use puffin_traits::{BuildContext, BuildKind, NoBuild, SourceBuildTrait};
|
||||
use pypi_types::Metadata21;
|
||||
|
||||
use crate::error::Error;
|
||||
|
|
@ -823,7 +823,13 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
|
|||
) -> Result<(String, WheelFilename, Metadata21), Error> {
|
||||
debug!("Building: {dist}");
|
||||
|
||||
if self.build_context.no_build() {
|
||||
// Guard against build of source distributions when disabled
|
||||
let no_build = match self.build_context.no_build() {
|
||||
NoBuild::All => true,
|
||||
NoBuild::None => false,
|
||||
NoBuild::Packages(packages) => packages.contains(dist.name()),
|
||||
};
|
||||
if no_build {
|
||||
return Err(Error::NoBuild);
|
||||
}
|
||||
|
||||
|
|
@ -837,6 +843,7 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
|
|||
source_dist,
|
||||
subdirectory,
|
||||
&dist.to_string(),
|
||||
Some(dist),
|
||||
BuildKind::Wheel,
|
||||
)
|
||||
.await
|
||||
|
|
@ -878,6 +885,7 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
|
|||
source_dist,
|
||||
subdirectory,
|
||||
&dist.to_string(),
|
||||
Some(dist),
|
||||
BuildKind::Wheel,
|
||||
)
|
||||
.await
|
||||
|
|
@ -923,6 +931,7 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
|
|||
&editable.path,
|
||||
None,
|
||||
&editable.to_string(),
|
||||
None,
|
||||
BuildKind::Editable,
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue