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

Add support for development dependencies #4036

Merged
merged 2 commits into from
Jun 6, 2024
Merged

Add support for development dependencies #4036

merged 2 commits into from
Jun 6, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jun 5, 2024

Summary

Externally, development dependencies are currently structured as a flat list of PEP 580-compatible requirements:

[tool.uv]
dev-dependencies = ["werkzeug"]

When locking, we lock all development dependencies; when syncing, users can provide --dev.

Internally, though, we model them as dependency groups, similar to Poetry, PDM, and PEP 735. This enables us to change out the user-facing frontend without changing the internal implementation, once we've decided how these should be exposed to users.

A few important decisions encoded in the implementation (which we can change later):

  1. Groups are enabled globally, for all dependencies. This differs from extras, which are enabled on a per-requirement basis. Note, however, that we'll only discover groups for uv-enabled packages anyway.
  2. Installing a group requires installing the base package. We rely on this in PubGrub to ensure that we resolve to the same version (even though we only expect groups to come from workspace dependencies anyway, which are unique). But anyway, that's encoded in the resolver right now, just as it is for extras.

@charliermarsh charliermarsh added the preview Experimental behavior label Jun 5, 2024
@charliermarsh charliermarsh force-pushed the charlie/dev branch 8 times, most recently from 36652ba to cae2046 Compare June 5, 2024 03:19
@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2024 03:19
@@ -28,6 +36,7 @@ pub struct Metadata {
pub requires_dist: Vec<pypi_types::Requirement>,
pub requires_python: Option<VersionSpecifiers>,
pub provides_extras: Vec<ExtraName>,
pub dependency_groups: BTreeMap<ExtraName, Vec<pypi_types::Requirement>>,
Copy link
Member Author

Choose a reason for hiding this comment

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

I find the terminology here really confusing -- that we have both extras and dependency groups -- but, what can we do? I'm honestly considering using dev_dependencies everywhere internally instead of dependency groups.

crates/uv-resolver/src/lock.rs Outdated Show resolved Hide resolved
crates/uv-resolver/src/resolution/graph.rs Outdated Show resolved Hide resolved
crates/uv/tests/lock.rs Outdated Show resolved Hide resolved
@charliermarsh charliermarsh force-pushed the charlie/dev branch 5 times, most recently from da22d23 to bccdad9 Compare June 5, 2024 16:46
@charliermarsh
Copy link
Member Author

I decided to rework the terminology (internally) to center on development dependencies (even though it still supports groups internally), since that's the only thing they're actually used for right now.

@charliermarsh charliermarsh force-pushed the charlie/dev branch 2 times, most recently from f3897ad to c49007b Compare June 6, 2024 01:23
@charliermarsh charliermarsh enabled auto-merge (squash) June 6, 2024 01:39
@charliermarsh charliermarsh merged commit 0acae9b into main Jun 6, 2024
46 checks passed
@charliermarsh charliermarsh deleted the charlie/dev branch June 6, 2024 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants