Skip to content
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

Passing a version range to -P results in no updates #392

Closed
PeterJCLaw opened this issue May 3, 2023 · 3 comments · Fixed by #394
Closed

Passing a version range to -P results in no updates #392

PeterJCLaw opened this issue May 3, 2023 · 3 comments · Fixed by #394

Comments

@PeterJCLaw
Copy link
Contributor

It seems that passing a package range to -P causes it pip-compile-multi to not upgrade the package in question at all, even when upgrades are available.

This is reproducible with:

# requirements/base.in
markupsafe
# requirements/base.txt
markupsafe==2.0.1
    # via -r requirements/base.in
$ pip-compile-multi  -P 'markupsafe<2.1.2'
Locking requirements/prod.in to requirements/prod.txt. References: []

Observing that while markupsafe has plenty of versions between 2.0.1 and 2.1.2, none are upgraded to.

Am I misunderstanding how -P is expected to work? I had thought I'd seen this work sometimes, but now can't actually reproduce that. -P seems to be documented to work the same as the equivalent pip-tools option, which does accept ranges and works with them.

@peterdemin
Copy link
Owner

Looks like there's a gap. Currently pip-compile-multi doesn't support the version, and always upgrades to the latest. You can only pass a package name. I didn't know pip-tools supports versions.
Would you be open to contributing a fix?

@PeterJCLaw
Copy link
Contributor Author

Sure, I can have a go. From a quick look it seems like the missing piece is that UpgradeSelected compares the input text to the package names directly, though there may be more to it.

Do you have a suggestion for how the input string should be parsed to extract the package name? (I guess I'm asking if there's a known util somewhere that can do that, rather than me trying to write one)

@peterdemin
Copy link
Owner

peterdemin commented May 3, 2023

Yeah, we need to use just the package name everywhere except when passing down the CLI options to pip-tools:
https://github.com/peterdemin/pip-compile-multi/blob/master/pipcompilemulti/features/upgrade.py#LL91C11-L91C11
To extract the package name, I guess, you could use a basic regex like this one:
https://github.com/peterdemin/pip-compile-multi/blob/master/pipcompilemulti/dependency.py#LL78C9-L78C37

PeterJCLaw added a commit to PeterJCLaw/pip-compile-multi that referenced this issue May 4, 2023
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
PeterJCLaw added a commit to PeterJCLaw/pip-compile-multi that referenced this issue May 4, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants