Allow prereleases, locals, and URLs in non-editable path requirements (#2671)

## Summary

This PR enables the resolver to "accept" URLs, prereleases, and local
version specifiers for direct dependencies of path dependencies. As a
result, `uv pip install .` and `uv pip install -e .` now behave
identically, in that neither has a restriction on URL dependencies and
the like.

Closes https://github.com/astral-sh/uv/issues/2643.
Closes https://github.com/astral-sh/uv/issues/1853.
This commit is contained in:
Charlie Marsh 2024-03-27 18:17:09 -04:00 committed by GitHub
parent 4b69ad4281
commit cf30932831
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 484 additions and 77 deletions

View file

@ -4,6 +4,7 @@ pub use config_settings::*;
pub use downloads::*;
pub use name_specifiers::*;
pub use package_options::*;
pub use requirements::*;
pub use traits::*;
mod build_options;
@ -11,4 +12,5 @@ mod config_settings;
mod downloads;
mod name_specifiers;
mod package_options;
mod requirements;
mod traits;

View file

@ -0,0 +1,35 @@
use pep508_rs::Requirement;
use uv_normalize::ExtraName;
/// A set of requirements as requested by a parent requirement.
///
/// For example, given `flask[dotenv]`, the `RequestedRequirements` would include the `dotenv`
/// extra, along with all of the requirements that are included in the `flask` distribution
/// including their unevaluated markers.
#[derive(Debug, Clone)]
pub struct RequestedRequirements {
/// The set of extras included on the originating requirement.
extras: Vec<ExtraName>,
/// The set of requirements that were requested by the originating requirement.
requirements: Vec<Requirement>,
}
impl RequestedRequirements {
/// Instantiate a [`RequestedRequirements`] with the given `extras` and `requirements`.
pub fn new(extras: Vec<ExtraName>, requirements: Vec<Requirement>) -> Self {
Self {
extras,
requirements,
}
}
/// Return the extras that were included on the originating requirement.
pub fn extras(&self) -> &[ExtraName] {
&self.extras
}
/// Return the requirements that were included on the originating requirement.
pub fn requirements(&self) -> &[Requirement] {
&self.requirements
}
}