-
-
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
pip-compile -P PKGSPEC ignores pkgs not already parsed as constraints #1031
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1031 +/- ##
==========================================
+ Coverage 99.11% 99.33% +0.22%
==========================================
Files 34 34
Lines 2360 2397 +37
Branches 302 306 +4
==========================================
+ Hits 2339 2381 +42
+ Misses 11 8 -3
+ Partials 10 8 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @AndydeCleyre,
Thanks for the PR! Looks like these changes introduce a bug when pip-compile
wouldn't upgrade/downgrade a secondary package to a specific version, see:
$ cat requirements.in
jinja2
$ cat requirements.txt
jinja2==2.10.3
markupsafe==1.0 # via jinja2
$ pip-compile --no-header -P markupsafe==1.1.0
jinja2==2.10.3
markupsafe==1.1.1 # via jinja2
Note that markupsafe
has upgraded to the latest 1.1.1
version (not 1.1.0
as expected).
Thanks! I didn't think about user-managed versions of requirements not entered into the a) alter the resolver to handle an additional constraint variant which limits only if needed |
d) this also can be fixed by: if not upgrade and os.path.exists(output_file.name):
...
existing_pins_to_upgrade = {
key_from_req(ireq.req): ireq
for ireq in ireqs
if is_pinned_requirement(ireq)
and key_from_req(ireq.req) in upgrade_install_reqs
}
...
constraints.extend(
ireq for key, ireq in upgrade_install_reqs.items()
if key in primary_packages or key in existing_pins_to_upgrade
) But this fix doesn't handle the case when a user removes a package from requirements.in and wants to upgrade the removed package before recompiling the requirements.txt. We may ignore that because we can't protect people from shooting to the foot. |
379c413
to
c143fcf
Compare
Alright, so after your last comment I implemented your fix only slightly modified by populating But it drew my attention to the fact that I wasn't yet familiar with existing_pins = {
key_from_req(ireq.req): ireq
for ireq in ireqs
if is_pinned_requirement(ireq)
}
existing_pins.update(upgrade_install_reqs) At first I thought it was working, but then realized that it breaks when using So I've replaced this PR content with the modified version of your last-suggested solution. I tried to add a little extra to I still keep in my head as a fallback for "correct" (if inefficient) outcome: in the case of upgrades, resolve/pin/compile once with all constraints, and again without the to-upgrade ones. |
Ah, the star unpacking isn't py2 compatible, I'll update shortly. |
c143fcf
to
e9eb2df
Compare
Thanks for the updates! I've skimmed the PR but review it properly soon. Here is the PR AndydeCleyre#1 with tests. Also, I've added a test for downgrade deps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A few minor comments.
…exclude -P args not already pinned or primarily required; fixes jazzband#759 Co-Authored-By: Albert Tugushev <[email protected]> use long option style --upgrade-package in test exact line-matching in expected output more readable if/else instead of ternary
5be12e5
to
d1fb07e
Compare
e2e291f
to
2f0d80a
Compare
You're totally right about it naturally being a set rather than a dict, that was just a holdover from trying to more tightly combine the population of Thank you for your continued work on this project, and ensuring I don't muck it up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🎉 🎉 🎉
@AndydeCleyre thanks! |
|
Fixes #759
pip-compile -P <pkgspec>
When adding requested-to-upgrade pkgspecs (
ireq
s) to theconstraints
list, omit those whose key is not present among theprimary_packages
set.Changelog-friendly one-liner:
pip-compile --upgrade-package
silently ignores those passed packages not already required according to the *.in and *.txt files.Contributor checklist