Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use common routines for pip install and pip sync #3737

Merged
merged 2 commits into from
May 22, 2024
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
5 changes: 5 additions & 0 deletions crates/distribution-types/src/requirement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,9 @@ impl RequirementSource {
},
}
}

/// Returns `true` if the source is editable.
pub fn is_editable(&self) -> bool {
matches!(self, Self::Path { editable: true, .. })
}
}
11 changes: 2 additions & 9 deletions crates/distribution-types/src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,9 @@ impl Resolution {
self.0.is_empty()
}

/// Return the set of [`Requirement`]s that this resolution represents, exclusive of any
/// editable requirements.
/// Return the set of [`Requirement`]s that this resolution represents.
pub fn requirements(&self) -> Vec<Requirement> {
let mut requirements: Vec<_> = self
.0
.values()
// Remove editable requirements
.filter(|dist| !dist.is_editable())
.map(Requirement::from)
.collect();
let mut requirements: Vec<_> = self.0.values().map(Requirement::from).collect();
requirements.sort_unstable_by(|a, b| a.name.cmp(&b.name));
requirements
}
Expand Down
3 changes: 2 additions & 1 deletion crates/uv-configuration/src/package_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ impl Reinstall {
}

/// Whether to allow package upgrades.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub enum Upgrade {
/// Prefer pinned versions from the existing lockfile, if possible.
#[default]
None,

/// Allow package upgrades for all packages, ignoring the existing lockfile.
Expand Down
7 changes: 6 additions & 1 deletion crates/uv-resolver/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Manifest {

// Include direct requirements, with constraints and overrides applied.
DependencyMode::Direct => Either::Right(
self.overrides.apply(& self.requirements)
self.overrides.apply(&self.requirements)
.chain(self.constraints.requirements())
.chain(self.overrides.requirements())
.filter(move |requirement| requirement.evaluate_markers(markers, &[]))),
Expand Down Expand Up @@ -210,4 +210,9 @@ impl Manifest {
) -> impl Iterator<Item = &Requirement> {
self.constraints.apply(self.overrides.apply(requirements))
}

/// Returns the number of input requirements.
pub fn num_requirements(&self) -> usize {
self.requirements.len() + self.editables.len()
}
}
16 changes: 14 additions & 2 deletions crates/uv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ pub(crate) struct PipSyncArgs {
/// WARNING: When specified, uv will select wheels that are compatible with the _target_
/// platform; as a result, the installed distributions may not be compatible with the _current_
/// platform. Conversely, any distributions that are built from source may be incompatible with
/// the the _target_ platform, as they will be built for the _current_ platform. The
/// the _target_ platform, as they will be built for the _current_ platform. The
/// `--python-platform` option is intended for advanced use cases.
#[arg(long)]
pub(crate) python_platform: Option<TargetTriple>,
Expand All @@ -932,6 +932,18 @@ pub(crate) struct PipSyncArgs {
#[arg(long, overrides_with("strict"), hide = true)]
pub(crate) no_strict: bool,

/// Limit candidate packages to those that were uploaded prior to the given date.
///
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same
/// format (e.g., `2006-12-02`).
#[arg(long)]
pub(crate) exclude_newer: Option<ExcludeNewer>,

/// Perform a dry run, i.e., don't actually install anything but resolve the dependencies and
/// print the resulting plan.
#[arg(long)]
pub(crate) dry_run: bool,

#[command(flatten)]
pub(crate) compat_args: compat::PipSyncCompatArgs,
}
Expand Down Expand Up @@ -1301,7 +1313,7 @@ pub(crate) struct PipInstallArgs {
/// WARNING: When specified, uv will select wheels that are compatible with the _target_
/// platform; as a result, the installed distributions may not be compatible with the _current_
/// platform. Conversely, any distributions that are built from source may be incompatible with
/// the the _target_ platform, as they will be built for the _current_ platform. The
/// the _target_ platform, as they will be built for the _current_ platform. The
/// `--python-platform` option is intended for advanced use cases.
#[arg(long)]
pub(crate) python_platform: Option<TargetTriple>,
Expand Down
Loading
Loading