-
Notifications
You must be signed in to change notification settings - Fork 648
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
Enable PEP 517 builds for unnamed requirements #2600
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
838a491
Enable PEP 517 builds for unnamed requirements
charliermarsh a0e48ff
Also remove name from wheel paths
charliermarsh 9f34ab2
Revert "Also remove name from wheel paths"
charliermarsh efd2d94
Fix cache
charliermarsh 19e34cd
Reverts
charliermarsh 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
use std::path::Path; | ||
|
||
use url::Url; | ||
|
||
use uv_normalize::PackageName; | ||
|
||
use crate::{GitSourceDist, Name, PathSourceDist, SourceDist}; | ||
|
||
/// A reference to a source that can be built into a built distribution. | ||
/// | ||
/// This can either be a distribution (e.g., a package on a registry) or a direct URL. | ||
/// | ||
/// Distributions can _also_ point to URLs in lieu of a registry; however, the primary distinction | ||
/// here is that a distribution will always include a package name, while a URL will not. | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum BuildableSource<'a> { | ||
Dist(&'a SourceDist), | ||
Url(SourceUrl<'a>), | ||
} | ||
|
||
impl BuildableSource<'_> { | ||
/// Return the [`PackageName`] of the source, if available. | ||
pub fn name(&self) -> Option<&PackageName> { | ||
match self { | ||
Self::Dist(dist) => Some(dist.name()), | ||
Self::Url(_) => None, | ||
} | ||
} | ||
|
||
/// Return the [`BuildableSource`] as a [`SourceDist`], if it is a distribution. | ||
pub fn as_dist(&self) -> Option<&SourceDist> { | ||
match self { | ||
Self::Dist(dist) => Some(dist), | ||
Self::Url(_) => None, | ||
} | ||
} | ||
} | ||
|
||
impl std::fmt::Display for BuildableSource<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::Dist(dist) => write!(f, "{dist}"), | ||
Self::Url(url) => write!(f, "{url}"), | ||
} | ||
} | ||
} | ||
|
||
/// A reference to a source distribution defined by a URL. | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum SourceUrl<'a> { | ||
Direct(DirectSourceUrl<'a>), | ||
Git(GitSourceUrl<'a>), | ||
Path(PathSourceUrl<'a>), | ||
} | ||
|
||
impl std::fmt::Display for SourceUrl<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::Direct(url) => write!(f, "{url}"), | ||
Self::Git(url) => write!(f, "{url}"), | ||
Self::Path(url) => write!(f, "{url}"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct DirectSourceUrl<'a> { | ||
pub url: &'a Url, | ||
} | ||
|
||
impl std::fmt::Display for DirectSourceUrl<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{url}", url = self.url) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct GitSourceUrl<'a> { | ||
pub url: &'a Url, | ||
} | ||
|
||
impl std::fmt::Display for GitSourceUrl<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{url}", url = self.url) | ||
} | ||
} | ||
|
||
impl<'a> From<&'a GitSourceDist> for GitSourceUrl<'a> { | ||
fn from(dist: &'a GitSourceDist) -> Self { | ||
Self { url: &dist.url } | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct PathSourceUrl<'a> { | ||
pub url: &'a Url, | ||
pub path: &'a Path, | ||
} | ||
|
||
impl std::fmt::Display for PathSourceUrl<'_> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{url}", url = self.url) | ||
} | ||
} | ||
|
||
impl<'a> From<&'a PathSourceDist> for PathSourceUrl<'a> { | ||
fn from(dist: &'a PathSourceDist) -> Self { | ||
Self { | ||
url: &dist.url, | ||
path: &dist.path, | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Hm.. this is an interesting caveat. We should probably mention this in the
--only-binary
docs?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.
Yeah I don’t really see any way around it. It was also already true for editables, interestingly.
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.
We could default to “false” here instead of true. That might be safer? At least for non-editables.
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.
That actually seems better since you can always add a package name to fix it.
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.
TIL that pip install does not enforce
--no-binary
for direct URL requirements. For example,pip install "anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz" --only-binary anyio --no-cache --force-reinstall
works fine.