pip-tools icon indicating copy to clipboard operation
pip-tools copied to clipboard

Treat --upgrade-packages PKGSPECs as constraints (not just minimums), consistently

Open AndydeCleyre opened this issue 3 years ago • 3 comments

Fixes #1550

This aims to address two problems:

  • When --upgrade and --upgrade-packages PKGSPEC are used together, and PKGSPEC's package is not in the input file (but is a subdependency), then that package is upgraded beyond PKGSPEC
  • When --upgrade-packages PKGSPEC is used, and PKGSPEC's package is in neither the input file nor a preexisting output file (but is a subdependency), then that package is upgraded beyond PKGSPEC

In other words:

--upgrade-packages fails to constrain subdeps, if either absent from a preexisting output file, or if --upgrade is 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, docs or skip-changelog as they determine changelog listing.
  • [ ] Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

AndydeCleyre avatar Feb 09 '22 06:02 AndydeCleyre

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

AndydeCleyre avatar Feb 09 '22 06:02 AndydeCleyre

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.

AndydeCleyre avatar Feb 10 '22 04:02 AndydeCleyre

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.

AndydeCleyre avatar Feb 10 '22 04:02 AndydeCleyre