-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Improve layered dependency workflow #1092
Comments
Hello @MartinAltmayer, Thanks for the feedback on the layered workflow! Actually, requirements can be compiled without # base.in
requests
# dev.in
-r base.txt
moto $ pip-compile base.in
$ pip-compile dev.in The only downside is # base.in
requests
# dev.in
-c base.txt
moto $ pip-compile base.in
$ pip-compile base.in --upgrade-package=idna==2.8 # pin manually to 2.8
$ pip-compile dev.in What do you think? Since |
Thanks for your quick response! Manually pinning the version to 2.8 would certainly work. However, in large projects that could mean pinning many different dependencies to compatible versions. Isn't this exactly the work pip-compile should do for us? I understand that you hesitate to add more options to pip-compile and would also be interested in other opinions or proposals. |
Another funny way to get constraints behavior is to compile the "outer" one, then copy its output over the (potential or existing) output of the inner one.
$ pip-compile dev.in
$ cp dev.txt base.txt
$ pip-compile base.in |
Thanks @MartinAltmayer for sharing this issue - it's good food for thought. The workflow for layered requirements operates "above" the scope and responsibility of In #398 we've been lucky enough to create a consensus that I recommend against implementing the feature suggested of adding Instead, here's an example of a solution using
Then this all:
rm -f system.in
echo "" > system.txt
cat *.in > system.in
# Build requirements for the whole system
pip-compile system.in
# Build requirements for each layer, constrained by the whole system
pip-compile base.in
pip-compile dev.in Therefore, my guess is that this issue should be closed - not because it's not a valid concern, because it is. Rather because it's outside of scope of My current wondering is whether this should be handled in documentation. 🤔 |
Thanks, @jamescooke, for an excellent explanation! Also, that
I would refrain from opinionating the documentation too much. |
Thanks @Ampretuzo 👍
I agree. Just to clarify my last comment - I'm not suggesting that the documentation should be opinionated about a single way that Even then, there isn't a one-shot recipe that will solve all scenarios - especially when it comes to updating requirements. As with most things there are trade-offs, but using the documentation to highlight potential pitfalls can make the tool more user friendly. |
@jamescooke IIUC, your solution above forgets the pinned versions of any previously existing base.txt and dev.txt, since system.txt is generated afresh each time. Now, suppose we have the following files:
Then we can do the following:
Of course it would be nicer if one could get rid of the
Any solution allowing pip to selectively see a |
Yep 👍🏻 - it's an omission on my part because I didn't state that I would have expected them to be actually deleted before updating. Sorry for that. Back when I suggested the workaround in the comment above, my experience was that leaving In the last two years since writing that workaround, I've not had a situation occur where I've needed to leave the |
A couple issues with using pip's constraint support:
|
It's not pretty, but this is currently working for me with # generate requirements.txt
pip-compile --generate-hashes --output-file requirements.txt --resolver backtracking --strip-extras pyproject.toml
# generate requirements-dev.txt for [dev] extras
echo "--constraint $(pwd)/requirements.txt" | \
pip-compile --generate-hashes --output-file requirements-dev.txt --extra dev --resolver backtracking - pyproject.toml |
Yet another workaround:
One problem with @ipmb approach is that the annotations will show as
which makes it hard to resolve. Instead, I simply put a
Commands:
|
This PR #1936 adds |
What's the problem this feature will solve?
I know this has been discussed a few times (e.g. #398), but the current solution for layered dependencies still doesn't work in all cases. For example the following simple files cannot be compiled:
Running
pip-compile base.in
results inNow
pip-compile dev.in
aborts with an error:A solution exists, though: Just use
idna==2.8
.Describe the solution you'd like
In my opinion, a solution to the layered dependencies problem requires to compile the outermost layer first: Then the resolver has a chance to find a solution for all dependencies. A working solution is the following:
Now I can generate correct dependency sets with
The
constraint.in
is necessary because otherwise the secondpip-compile
will generate versions that differ from those indev.txt
.What do you think of this solution? How about adding a
-c/--constrain
option topip-compile
, that acts like I added aconstraint.in
file above. Then I could runwith the same effect as above.
The text was updated successfully, but these errors were encountered: