pip-tools
pip-tools copied to clipboard
Treat --upgrade-packages PKGSPECs as constraints (not just minimums), consistently
Fixes #1550
This aims to address two problems:
- When
--upgradeand--upgrade-packages PKGSPECare used together, andPKGSPEC's package is not in the input file (but is a subdependency), then that package is upgraded beyondPKGSPEC - When
--upgrade-packages PKGSPECis used, andPKGSPEC's package is in neither the input file nor a preexisting output file (but is a subdependency), then that package is upgraded beyondPKGSPEC
In other words:
--upgrade-packagesfails to constrain subdeps, if either absent from a preexisting output file, or if--upgradeis also passed
Some of the current behavior was informed by discussion at #759.
However my understanding now is that it's useful, expected, and without significant cost to additionally treat --upgrade-packages specs as constraints, thereby resolving the above cases.
Contributor checklist
- [ ] Provided the tests for the changes.
- [ ] Assure PR title is short, clear, and good to be included in the user-oriented changelog
Maintainer checklist
- [ ] Assure one of these labels is present:
backwards incompatible,feature,enhancement,deprecation,bug,dependency,docsorskip-changelogas they determine changelog listing. - [ ] Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).
This currently has at least one bug:
requirements.in:
ptrender
requirements.txt:
sqlparse==0.4.0
$ pip-compile --upgrade-package 'sqlparse<=0.4.0' requirements.in
requirements.txt:
plumbum==1.7.2
# via ptrender
ptrender==0.0.3
# via -r requirements.in
pyratemp==0.3.2
# via ptrender
sqlparse==0.4.0
Thank you @jammie19 !
I'm refining my understanding of what we're solving here, and have tried to articulate it as two problem cases, bulleted above.
In terms of tests, I think the second bullet is now covered by a simple change to the existing test_upgrade_packages_option_subdependency.
I'm going to have a look and see if a similar tiny test adjustment will be appropriate for the first bullet as well.
OK I think the new parametrization for test_upgrade_packages_version_option_and_upgrade covers the first bullet, so I'm going to promote this out of draft state.