Skip to content

Support unnamed requirements in uv add #4237

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

Closed
wants to merge 1 commit into from

Conversation

ibraheemdev
Copy link
Member

Summary

Support unnamed URL requirements in uv add. For example, uv add git+https://github.com/pallets/flask.

Part of #3959.

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Jun 11, 2024

I'm not 100% sure about all the CLI arguments here, would appreciate a more thorough audit of those. For example, I didn't add --only-binary because that doesn't seem very useful.

origin: requirement.origin,
version_or_url: match requirement.source {
RequirementSource::Registry { specifier, .. } => {
Some(VersionOrUrl::VersionSpecifier(specifier))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little weird because we lose the distinction between empty version specifiers and None, but that doesn't seem relevant for formatting at least.

let requirements = requirements
.into_iter()
.map(RequirementsSource::Package)
.collect_vec();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more conventional for this piece to be in main.rs (or, at least, we do that for the other commands).

let flat_index = {
let client = FlatIndexClient::new(&client, cache);
let entries = client.fetch(index_locations.flat_index()).await?;
FlatIndex::from_entries(entries, Some(&tags), &hasher, &no_build, &NoBinary::None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define this NoBinary as let no_binary = NoBinary::default(), and put it with all the other defaults below? Like, move that block up to line 75 or so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have something that looks like the // TODO(charlie): Respect project configuration. block in do_lock, just so we have consistency and it's easier to fix them all later.

/// "dependency confusion" attacks, whereby an attack can upload a malicious package under the
/// same name to a secondary
#[arg(long, value_enum, env = "UV_INDEX_STRATEGY")]
pub(crate) index_strategy: Option<IndexStrategy>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could feasibly omit this, keyring_provider, python_version, python_platform, link_mode, build_isolation, ... We don't support them in lock or sync or run yet and need to tackle the problem holistically. Honestly, it might be best to omit them for now so we don't tie ourselves to them.

charliermarsh added a commit that referenced this pull request Jun 12, 2024
## Summary

Stealing this from @ibraheemdev's
#4237 because it's a nice, isolated
change and I'm about to build atop it.
@ibraheemdev
Copy link
Member Author

Moved to #4326 (switched to a local branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants