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

Support for the pip-compile-multi use case? #5487

Open
mistercrunch opened this issue Jul 26, 2024 · 8 comments
Open

Support for the pip-compile-multi use case? #5487

mistercrunch opened this issue Jul 26, 2024 · 8 comments
Labels
needs-design Needs discussion, investigation, or design wish Not on the immediate roadmap

Comments

@mistercrunch
Copy link

For Apache Superset, we have fairly complex dependency management and have to use pip-compile-multi as a result.

pip-compile-multi is pretty much simply pip-compile with support for .in files to reference other .in files, making it such that you can create say a base.in file and build say a ci.in file or dev.in file that references that base file, allowing use to do a bit of composition with dependencies and keeping things DRY.

The main issue with pip-compile-multi are that 1. it's slow, 2. it's not compatible with dependabot and 3. I don't think it's actively maintained

I'm curious whether uv has support for this use case and/or whether it may be on the roadmap.

@charliermarsh
Copy link
Member

We support those kinds of -r references in .in files. Is the benefit of pip-compile-multi that the output file also contains a -r, to avoid duplicating the dependencies?

@charliermarsh charliermarsh added the question Asking for clarification or support label Jul 26, 2024
@mistercrunch
Copy link
Author

Yes that's exactly it.

@mistercrunch
Copy link
Author

Hey, so say in the simple/common case where I want to manage a prod and dev setup (as documented here https://docs.astral.sh/uv/pip/compile/#locking-requirements):

So presumably I would do both

# for prod
uv pip compile pyproject.toml -o requirements-dev.txt
# and for dev
uv pip compile pyproject.toml requirements-dev.in -o requirements-dev.txt

That's all dandy, but now how do i guarantee that dev stays aligned with prod for the dependencies that they have in common? Presumably if i run both at the same time, with a little bit of luck they should stay aligned, though that's unless there's a conflict between the two. Say dev may have a sub-dependency that forces an older version of a shared/common dependency.

It's not a simple problem to solve, but it's a common/important use case.

Any way to provide these guarantees using uv currently? Any hope that'd get on the roadmap? Also what would be the best solution?

@charliermarsh
Copy link
Member

@mistercrunch -- I think the common solution here would be to do something like this:

# For prod...
uv pip compile pyproject.toml -o requirements-prod.txt
# For dev
uv pip compile pyproject.toml requirements-dev.in -c requirements-prod.txt -o requirements-dev.txt

So, you use the output of the first command as a constraint for the second command. Then the versions will be kept in sync.

@mistercrunch
Copy link
Author

Oh, smart! I should have thought of that. Is it guaranteed to produce matching version for all common libs and fail if somehow it can't find a match? I guess if it's not 100% guaranteed I could write a simple script to assert that common libs match as part of our CI.

@adRn-s
Copy link

adRn-s commented Oct 11, 2024

I'm going through some effort myself trying to adopt uv in my workflow. It would be great if there was a uv pip compile-multi -d ./requirements/ available that one could use as drop-in... I was having multiple requirements folders, preparing the requirements.txt for multiple python versions (here) (Yes, in the past I was bitten by the fact that a requirements.txt wouldn't "compile" in a given python version that I wasn't using but thought it was supporting, hence this workflow..).

@mistercrunch
Copy link
Author

mistercrunch commented Oct 11, 2024

One thing on my side is ensuring my future uv setup is going to work nicely with @dependabot. Related to this I found this here -> dependabot/dependabot-core#10039. In the past, with pip-compile-multi, I had to write my own dependabot replacement to account for our pip-compile-multi setup.

Clearly there's more traction with uv (I think pip-compile-multi is on life-support and the dependabot integration ticket doesn't have traction). So it makes more sense to push for a uv/dependabot integration as opposed to a pip-compile-multi/dependabot integration. From my understanding, in its current state, dependabot is probably going to look at our pyproject.toml in isolation while running a pip-compile behind the scene (it simply doesn't know about our specific needs around pinning multiple package sets)

Ideally the dependency management system would have semantics/conventions about supporting different setups (while keeping common libs on the same version). Ideally uv would understand those semantics and dependabot would integrate deeply enough with uv to support those requirements.

Stepping back, it seems like this should be a very common need and arguably should be in-scope for uv (?) Does anyone know how it works in other mature languages/dependency-management tools? Maybe we could get some inspiration from other ecosystems (?)

@mistercrunch
Copy link
Author

mistercrunch commented Oct 11, 2024

Taking a deeper look into the PR adding uv support to dependabot (open Pr as of the time of this comment), it looks like it's set up to have dependabot run a simple uv pip compile command. So if we add semantics in uv about supporting "atomic multi-outputs", dependabot should do the right thing. Here there any existing config file or env vars we could use to make it such that uv would run a series of commands (as suggested in the comment above #5487 (comment))?

@zanieb zanieb added wish Not on the immediate roadmap needs-design Needs discussion, investigation, or design and removed question Asking for clarification or support labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-design Needs discussion, investigation, or design wish Not on the immediate roadmap
Projects
None yet
Development

No branches or pull requests

4 participants