-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add support for extras in editable requirements #1531
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,16 +160,8 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
// Determine all the editable requirements. | ||
let mut editables = FxHashMap::default(); | ||
for (editable_requirement, metadata) in &manifest.editables { | ||
// Convert the editable requirement into a distribution. | ||
let dist = Dist::from_editable(metadata.name.clone(), editable_requirement.clone()) | ||
.expect("This is a valid distribution"); | ||
|
||
// Mock editable responses. | ||
let package_id = dist.package_id(); | ||
index.distributions.register(package_id.clone()); | ||
index.distributions.done(package_id, metadata.clone()); | ||
editables.insert( | ||
dist.name().clone(), | ||
metadata.name.clone(), | ||
(editable_requirement.clone(), metadata.clone()), | ||
); | ||
} | ||
|
@@ -633,6 +625,16 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
} | ||
|
||
PubGrubPackage::Package(package_name, extra, None) => { | ||
// If the dist is an editable, return the version from the editable metadata. | ||
if let Some((_local, metadata)) = self.editables.get(package_name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only downside to all of this is that we now pay the cost of doing these lookups for all packages. |
||
let version = metadata.version.clone(); | ||
return if range.contains(&version) { | ||
Ok(Some(ResolverVersion::Available(version))) | ||
} else { | ||
Ok(None) | ||
}; | ||
} | ||
|
||
// Wait for the metadata to be available. | ||
let versions_response = self | ||
.index | ||
|
@@ -798,19 +800,15 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
// Add a dependency on each editable. | ||
for (editable, metadata) in self.editables.values() { | ||
constraints.insert( | ||
PubGrubPackage::Package( | ||
metadata.name.clone(), | ||
None, | ||
Some(editable.url().clone()), | ||
), | ||
PubGrubPackage::Package(metadata.name.clone(), None, None), | ||
Range::singleton(metadata.version.clone()), | ||
); | ||
for extra in &editable.extras { | ||
constraints.insert( | ||
PubGrubPackage::Package( | ||
metadata.name.clone(), | ||
Some(extra.clone()), | ||
Some(editable.url().clone()), | ||
None, | ||
), | ||
Range::singleton(metadata.version.clone()), | ||
); | ||
|
@@ -830,7 +828,37 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
return Ok(Dependencies::Available(DependencyConstraints::default())); | ||
} | ||
|
||
// Determine the distribution to lookup | ||
// Determine if the distribution is editable. | ||
if let Some((_local, metadata)) = self.editables.get(package_name) { | ||
let mut constraints = PubGrubDependencies::from_requirements( | ||
&metadata.requires_dist, | ||
&self.constraints, | ||
&self.overrides, | ||
Some(package_name), | ||
extra.as_ref(), | ||
self.markers, | ||
)?; | ||
|
||
for (package, version) in constraints.iter() { | ||
debug!("Adding transitive dependency: {package}{version}"); | ||
|
||
// Emit a request to fetch the metadata for this package. | ||
self.visit_package(package, priorities, request_sink) | ||
.await?; | ||
} | ||
|
||
// If a package has an extra, insert a constraint on the base package. | ||
if extra.is_some() { | ||
constraints.insert( | ||
PubGrubPackage::Package(package_name.clone(), None, None), | ||
Range::singleton(version.clone()), | ||
); | ||
} | ||
|
||
return Ok(Dependencies::Available(constraints.into())); | ||
} | ||
|
||
// Determine the distribution to lookup. | ||
let dist = match url { | ||
Some(url) => PubGrubDistribution::from_url(package_name, url), | ||
None => PubGrubDistribution::from_registry(package_name, version), | ||
|
@@ -984,6 +1012,11 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
|
||
// Pre-fetch the package and distribution metadata. | ||
Request::Prefetch(package_name, range) => { | ||
// Ignore editables. | ||
if self.editables.contains_key(&package_name) { | ||
return Ok(None); | ||
} | ||
|
||
// Wait for the package metadata to become available. | ||
let versions_response = self | ||
.index | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think removing this is good.