Skip to content

Commit

Permalink
Handle upgrades of packages within ranges
Browse files Browse the repository at this point in the history
The underlying functionality for this was already present within
`pip-tool`s, however `pip-compile-multi` wasn't aware of it and
thus made assumptions about the nature of the spec argument which
turned out to be false.

The fix here is to teach `pip-compile-multi` how to interpret these
package specs to extract the names for the places it needs them
while still passing the full spaces through to `pip-tools` for the
actual upgrade.

Fixes peterdemin#392
  • Loading branch information
PeterJCLaw committed May 4, 2023
1 parent eb0859a commit f8c3e69
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pipcompilemulti/features/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
https://github.com/jazzband/pip-tools#updating-requirements
"""

import re

from .base import BaseFeature, ClickOption
from .forward import ForwardOption

Expand Down Expand Up @@ -78,10 +80,19 @@ def reset(self):
"""Clear cached packages."""
self._env_packages_cache = {}

@property
def package_specs(self):
"""List of package specs to upgrade."""
return self.value or []

@property
def package_names(self):
"""List of package names to upgrade."""
return self.value or []
def name_from_spec(name):
match = re.match(r'(?P<package>[a-z0-9-_.]+)', name)
assert match is not None
return match.group(0)
return [name_from_spec(x) for x in self.package_specs]

@property
def active(self):
Expand All @@ -92,7 +103,7 @@ def pin_options(self):
"""Pin command options for upgrading specific packages."""
return [
'--upgrade-package=' + package
for package in self.package_names
for package in self.package_specs
]

def has_package(self, in_path, package_name):
Expand Down

0 comments on commit f8c3e69

Please sign in to comment.