Skip to content

(PUP-11029) Fix pip package provider to query available versions #8675

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

Merged
merged 1 commit into from
Jul 6, 2021

Conversation

luchihoratiu
Copy link
Contributor

@luchihoratiu luchihoratiu commented Jul 5, 2021

Starting with version 20.3b1, pip removed available versions of a package from output when trying to install a wrong or unavailable version. Puppet is using this output to gather all available versions of a package and determine the latest one. Even though this regression got fixed in 21.1 version of pip, this commit adds the --use-deprecated=legacy-resolver argument when querying available versions of the managed package and also using any of the affected versions of pip.

Before fix:

puppet resource package ‘colorize’ ensure=latest provider=pip3
Error: Could not get latest version: [nil, nil, nil, nil]
Error: /Package[colorize]/ensure: change from ‘1.1.0’ to ‘latest’ failed: Could not get latest version: [nil, nil, nil, nil]
package { ‘colorize’:
  ensure   => ‘1.1.0’,
  provider => ‘pip3’,
}

After fix:

puppet resource package ‘colorize’ ensure=latest provider=pip3
Notice: /Package[colorize]/ensure: created
package { ‘colorize’:
  ensure   => ‘1.1.0’,
  provider => ‘pip3’,
}

Versions affected by this issue

pip3 v20.2.4 output:

pip3 install colorize==versionplease
ERROR: Could not find a version that satisfies the requirement colorize==versionplease (from versions: 0.2.0, 0.2.1, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0)
ERROR: No matching distribution found for colorize==versionplease

pip3 v20.3b1 output:

pip3 install colorize==versionplease
ERROR: Could not find a version that satisfies the requirement colorize==versionplease
ERROR: No matching distribution found for colorize==versionplease

...

pip3 v21.0.1 output:

pip3 install colorize==versionplease
ERROR: Could not find a version that satisfies the requirement colorize==versionplease
ERROR: No matching distribution found for colorize==versionplease

pip3 v21.1 output:

pip3 install colorize==versionplease
ERROR: Could not find a version that satisfies the requirement colorize==versionplease (from versions: 0.2.0, 0.2.1, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0)
ERROR: No matching distribution found for colorize==versionplease

Note: Fixed version also known from [pip3 changelog|https://pip.pypa.io/en/stable/news/].

Output with --use-deprecated=legacy-resolver argument

pip3 --version
pip 20.3b1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)pip3 install colorize==versionplease --use-deprecated=legacy-resolver
ERROR: Could not find a version that satisfies the requirement colorize==versionplease (from versions: 0.2.0, 0.2.1, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0)
ERROR: No matching distribution found for colorize==versionplease

Useful info for testing this fix

To get pip3 on a Ubuntu vm

apt-get update -yapt-get install python3-pip -y

To see current pip3 version

pip3 --version
pip 20.3 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)

To see available pip3 versions

pip3 install pip==versionplease
Collecting pip==versionplease
  Could not find a version that satisfies the requirement pip==versionplease (from versions: 0.2, 0.2.1, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.8.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1, 1.3, 1.3.1, 1.4, 1.4.1, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.1.0, 6.1.1, 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.1.0, 8.1.1, 8.1.2, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 10.0.0b1, 10.0.0b2, 10.0.0, 10.0.1, 18.0, 18.1, 19.0, 19.0.1, 19.0.2, 19.0.3, 19.1, 19.1.1, 19.2, 19.2.1, 19.2.2, 19.2.3, 19.3, 19.3.1, 20.0, 20.0.1, 20.0.2, 20.1b1, 20.1, 20.1.1, 20.2b1, 20.2, 20.2.1, 20.2.2, 20.2.3, 20.2.4, 20.3b1, 20.3, 20.3.1, 20.3.2, 20.3.3, 20.3.4, 21.0, 21.0.1, 21.1, 21.1.1, 21.1.2, 21.1.3)
No matching distribution found for pip==versionplease

To install a certain pip3 version

pip3 install pip==21.1.3
Collecting pip==21.1.3
  Using cached pip-21.1.3-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.3
    Uninstalling pip-20.3:
      Successfully uninstalled pip-20.3
Successfully installed pip-21.1.3

Note:

  • Some versions might change location of pip3 from /usr/bin/pip3 to /usr/local/bin/pip3.
  • If pip3 starts erroring out (due to known bugs of the installed version), use bellow commands to reinstall it:
apt-get install --reinstall python3-pip

or

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py

@luchihoratiu luchihoratiu requested review from a team July 5, 2021 07:02
@luchihoratiu luchihoratiu changed the base branch from main to 6.x July 5, 2021 07:40
@luchihoratiu luchihoratiu reopened this Jul 5, 2021
Starting with version `20.3b1`, `pip` removed available versions of a
package from output when trying to install a wrong or unavailable
version. Puppet is using this output to gather all available versions of
a package and determine the latest one. Even though this regression got
fixed in `21.1` version of `pip`, this commit adds the
`--use-deprecated=legacy-resolver` argument when querying available
versions of the managed package and also using any of the affected
versions of `pip`.
@gimmyxd gimmyxd requested a review from a team July 5, 2021 12:21
@ciprianbadescu ciprianbadescu merged commit c3f8458 into puppetlabs:6.x Jul 6, 2021
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 this pull request may close these issues.

None yet

3 participants