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

universal-lock: Lock with all extras, trim down on installation #3700

Closed
konstin opened this issue May 21, 2024 · 8 comments · Fixed by #3913
Closed

universal-lock: Lock with all extras, trim down on installation #3700

konstin opened this issue May 21, 2024 · 8 comments · Fixed by #3913
Assignees
Labels
preview Experimental behavior

Comments

@konstin
Copy link
Member

konstin commented May 21, 2024

The lockfile needs to be built on a resolution with all extras of the root project and workspace requirements, but when installing we only want the extras and workspace packages the user requested. The need to trim the resolution, probably by a DAG traversal. This includes mapping unnamed requirements to their named counterpart in the resolution map.

@konstin konstin added the preview Experimental behavior label May 21, 2024
@BurntSushi
Copy link
Member

The lockfile needs to be built on a resolution with all extras and workspace requirements

I think there is a hitch here right? Because some packages will have "dev" extras, and we specifically don't want to bring those into the lock file right? Basically that a package shouldn't inherit the dev dependencies of its dependencies. How do we deal with that?

@zanieb
Copy link
Member

zanieb commented May 21, 2024

Development dependencies are separate from extras, technically. They can be placed in an extra, but generally they are separate and not a part of the standard metadata (i.e. it's project management tool specific).

@zanieb
Copy link
Member

zanieb commented May 21, 2024

There's a bigger problem here though... extras can conflict with each other. Are we going to solve with them all turned on and ban conflicts? Are we going to lock all combinations?

@konstin
Copy link
Member Author

konstin commented May 21, 2024

If we want to support conflicting extras, the user needs to specify which those are and we apply the same split-resolve-merge as for conflicting disjoint markers. The ensures that extras are generally unified and conflict free and avoids combinatorial explosion.

@zanieb
Copy link
Member

zanieb commented May 21, 2024

Do we know how they're going to express the conflict? Can you just do it with <self-name>[extra] markers?

@konstin
Copy link
Member Author

konstin commented May 21, 2024

We need additional tool.uv metadata for this, i don't think any other tool covers this yet. I've heard that some large complex frameworks had trouble adopting poetry due to this.

@charliermarsh
Copy link
Member

I can take this if we want to start by "including all extras, then trimming at install time".

@olivier-lacroix
Copy link

You may want to take inspiration from pixi, which handles this via features (equivalent to a group of extra), that are included in environment(s).
Environments are included in the lock-file, and sometimes solved together when requested.
This avoids combinatorial explosion and is pretty flexible.

@konstin konstin mentioned this issue May 26, 2024
5 tasks
konstin added a commit that referenced this issue May 28, 2024
Add workspace support when using `-r <path>/pyproject.toml` or `-e
<path>` in the pip interface. It is limited to all-editable
static-metadata workspaces, and tests only include a single main
workspace, ignoring path dependencies in another workspace. This can be
considered the MVP for workspace support: You can create a workspace,
you can install from it, but some options and conveniences are still
missing. I'll file follow-up tickets (support in lockfiles, support path
deps in other workspace, #3625)

There is also support in `uv run`, but we need
#3700 first to properly support
using different current projects in the bluejay interface, currently the
resolution and therefore the lockfile depends on the current project.
I'd do this change first (it's big enough already), then #3700, and then
add workspace support properly to bluejay.

Fixes #3404
charliermarsh added a commit that referenced this issue May 29, 2024
## Summary

This PR adds extras to the lockfile, and enables users to selectively
sync extras in `uv sync` and `uv run`. The end result here was fairly
simple, though it required a few refactors to get here. The basic idea
is that `DistributionId` now includes `extra: Option<ExtraName>`, so we
effectively treat extras as separate packages. Generating the lockfile,
and generating the resolution from the lockfile, fall out of this
naturally with no special-casing or additional changes.

The main downside here is that it bloats the lockfile significantly.
Specifically:

- We include _all_ distribution URLs and hashes for _every_ extra
variant.
- We include all dependencies for the extra variant, even though that
are dependencies of the base package.

We could normalize this representation by changing each distribution
have an `optional-dependencies` hash map that keys on extras, but we
actually don't have the information we need to create that right now
(specifically, we can't differentiate between dependencies that
_require_ the extra and dependencies on the base package).

Closes #3700.
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 a pull request may close this issue.

5 participants