pipupgrade: pipupgrade incorrectly detects two pyenv-installed pip bins ('pip' & 'pip3'), from *single* Python install env, as from separate 'installed distributions'

i’ve installed python 3.8-dev via pyenv

	pyenv global
		3.8-dev
	python -V
		Python 3.8.2+

for this installed env, pip & pip3 are identical

	pip -V
		pip 20.0.2 from /usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pip (python 3.8)
	pip3 -V
		pip 20.0.2 from /usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pip (python 3.8)

and function identically.

i.e., they’re of the same ‘installed distribution’.

i’ve pip-installed 'pipupgrade`

	pip show pipupgrade
		Name: pipupgrade
		Version: 1.6.8
		Summary: UPGRADE ALL THE PIP PACKAGES!
		Home-page: https://github.com/achillesrasquinha/pipupgrade
		Author: Achilles Rasquinha
		Author-email: achillesrasquinha@gmail.com
		License: MIT
		Location: /usr/local/src/pyenv/versions/3.8-dev/lib/python3.8/site-packages
		Requires:
		Required-by:

on exec, pipupgrade sees TWO ‘installed distributions’, one for each of the two identical/redudndant pip/pip3 instances

e.g.,

pipupgrade --verbose --check
	2020-03-04 18:30:01,358 | INFO | Executing command: /usr/local/pyenv/versions/3.8-dev/bin/pip --version
	2020-03-04 18:30:01,477 | INFO | Executing command: /usr/local/pyenv/versions/3.8-dev/bin/pip3 --version
	2020-03-04 18:30:01,600 | INFO | Environment: {'version': '1.6.8', 'python_version': '3.8.2+', 'os': 'Linux-5.5.7-24.g1004bce-default-x86_64-with-glibc2.2.5', 'config': {'path': {'BASE': '/usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pipupgrade', 'DATA': '/usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pipupgrade/data', 'CACHE': '/root/.pipupgrade'}}, 'pip_executables': [{'executable': '/usr/local/pyenv/versions/3.8-dev/bin/pip', 'version': 'pip 20.0.2 from /usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pip (python 3.8)'}, {'executable': '/usr/local/pyenv/versions/3.8-dev/bin/pip3', 'version': 'pip 20.0.2 from /usr/local/pyenv/versions/3.8-dev/lib/python3.8/site-packages/pip (python 3.8)'}], 'settings': {'settings': {'version': '1.6.8', 'cache_timeout': '86400', 'jobs': '16'}}}
	2020-03-04 18:30:01,600 | INFO | Arguments Passed: {'packages': [], 'pip_path': None, 'requirements': None, 'pipfile': None, 'project': None, 'pull_request': False, 'git_username': None, 'git_email': None, 'github_access_token': None, 'github_reponame': None, 'github_username': None, 'target_branch': 'master', 'latest': 0, 'format': 'table', 'all': 0, 'pip': 0, 'self': False, 'jobs': 16, 'user': 0, 'check': True, 'interactive': 0, 'yes': 0, 'no_included_requirements': 0, 'no_cache': 0, 'no_color': 0, 'output': None, 'ignore_error': 0, 'force': 0, 'verbose': True}
	Checking...
	2020-03-04 18:30:01,604 | INFO | `pip` executables found: ['/usr/local/pyenv/versions/3.8-dev/bin/pip', '/usr/local/pyenv/versions/3.8-dev/bin/pip3']
	2020-03-04 18:30:01,604 | INFO | Using 16 jobs...
	2020-03-04 18:30:01,617 | INFO | Fetching installed packages for /usr/local/pyenv/versions/3.8-dev/bin/pip...
	2020-03-04 18:30:01,617 | INFO | Fetching installed packages for /usr/local/pyenv/versions/3.8-dev/bin/pip3...
	2020-03-04 18:30:01,618 | INFO | Executing command: /usr/local/pyenv/versions/3.8-dev/bin/pip list --outdated --format json
	2020-03-04 18:30:01,618 | INFO | Executing command: /usr/local/pyenv/versions/3.8-dev/bin/pip3 list --outdated --format json
	2020-03-04 18:30:16,038 | INFO | 6 packages found for /usr/local/pyenv/versions/3.8-dev/bin/pip.
	2020-03-04 18:30:16,051 | INFO | Initializing Package {'name': 'coveralls', 'version': '1.10.0', 'latest_version': '1.11.1', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Fetching package coveralls information from DB...
	2020-03-04 18:30:16,051 | INFO | Initializing Package {'name': 'base58', 'version': '1.0.3', 'latest_version': '2.0.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Fetching package base58 information from DB...
	2020-03-04 18:30:16,052 | INFO | Initializing Package {'name': 'flake8-2020', 'version': '1.5.0', 'latest_version': '1.6.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Fetching package flake8-2020 information from DB...
	2020-03-04 18:30:16,052 | INFO | Initializing Package {'name': 'pyupgrade', 'version': '1.26.2', 'latest_version': '2.1.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Initializing Package {'name': 'Sphinx', 'version': '2.3.1', 'latest_version': '2.4.3', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Initializing Package {'name': 'tox', 'version': '3.14.3', 'latest_version': '3.14.5', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,052 | INFO | Fetching package pyupgrade information from DB...
	2020-03-04 18:30:16,052 | INFO | Fetching package tox information from DB...
	2020-03-04 18:30:16,052 | INFO | Fetching package Sphinx information from DB...
	2020-03-04 18:30:16,052 | INFO | Using cached info for package <Package coveralls (1.10.0)>.
	2020-03-04 18:30:16,052 | INFO | Using cached info for package <Package base58 (1.0.3)>.
	2020-03-04 18:30:16,053 | INFO | Using cached info for package <Package flake8-2020 (1.5.0)>.
	2020-03-04 18:30:16,053 | INFO | Using cached info for package <Package pyupgrade (1.26.2)>.
	2020-03-04 18:30:16,053 | INFO | Using cached info for package <Package tox (3.14.3)>.
	2020-03-04 18:30:16,053 | INFO | Using cached info for package <Package Sphinx (2.3.1)>.
	2020-03-04 18:30:16,057 | INFO | Packages within `pip` /usr/local/pyenv/versions/3.8-dev/bin/pip found: [<Package base58 (1.0.3)>, <Package coveralls (1.10.0)>, <Package flake8-2020 (1.5.0)>, <Package pyupgrade (1.26.2)>, <Package Sphinx (2.3.1)>, <Package tox (3.14.3)>]...
	2020-03-04 18:30:16,289 | INFO | 6 packages found for /usr/local/pyenv/versions/3.8-dev/bin/pip3.
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'coveralls', 'version': '1.10.0', 'latest_version': '1.11.1', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'base58', 'version': '1.0.3', 'latest_version': '2.0.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'flake8-2020', 'version': '1.5.0', 'latest_version': '1.6.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,307 | INFO | Fetching package coveralls information from DB...
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'Sphinx', 'version': '2.3.1', 'latest_version': '2.4.3', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'tox', 'version': '3.14.3', 'latest_version': '3.14.5', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,308 | INFO | Fetching package base58 information from DB...
	2020-03-04 18:30:16,308 | INFO | Fetching package flake8-2020 information from DB...
	2020-03-04 18:30:16,308 | INFO | Fetching package tox information from DB...
	2020-03-04 18:30:16,308 | INFO | Fetching package Sphinx information from DB...
	2020-03-04 18:30:16,307 | INFO | Initializing Package {'name': 'pyupgrade', 'version': '1.26.2', 'latest_version': '2.1.0', 'latest_filetype': 'wheel'} of type <class 'dict'>...
	2020-03-04 18:30:16,308 | INFO | Fetching package pyupgrade information from DB...
	2020-03-04 18:30:16,308 | INFO | Using cached info for package <Package Sphinx (2.3.1)>.
	2020-03-04 18:30:16,308 | INFO | Using cached info for package <Package tox (3.14.3)>.
	2020-03-04 18:30:16,308 | INFO | Using cached info for package <Package flake8-2020 (1.5.0)>.
	2020-03-04 18:30:16,308 | INFO | Using cached info for package <Package coveralls (1.10.0)>.
	2020-03-04 18:30:16,309 | INFO | Using cached info for package <Package pyupgrade (1.26.2)>.
	2020-03-04 18:30:16,309 | INFO | Using cached info for package <Package base58 (1.0.3)>.
	2020-03-04 18:30:16,313 | INFO | Packages within `pip` /usr/local/pyenv/versions/3.8-dev/bin/pip3 found: [<Package base58 (1.0.3)>, <Package coveralls (1.10.0)>, <Package flake8-2020 (1.5.0)>, <Package pyupgrade (1.26.2)>, <Package Sphinx (2.3.1)>, <Package tox (3.14.3)>]...
	2020-03-04 18:30:16,318 | INFO | Updating registries: [<pipupgrade.model.registry.Registry object at 0x7f026a065190>, <pipupgrade.model.registry.Registry object at 0x7f026a0657c0>]...

	Source: Installed Distributions (/usr/local/pyenv/versions/3.8-dev/bin/pip)

	Name        Current Version Latest Version Home Page
	----------- --------------- -------------- ----------------------------------------------------
	base58      1.0.3           2.0.0          https://github.com/keis/base58
	coveralls   1.10.0          1.11.1         http://github.com/coveralls-clients/coveralls-python
	flake8-2020 1.5.0           1.6.0          https://github.com/asottile/flake8-2020
	pyupgrade   1.26.2          2.1.0          https://github.com/asottile/pyupgrade
	Sphinx      2.3.1           2.4.3          http://sphinx-doc.org/
	tox         3.14.3          3.14.5         http://tox.readthedocs.org


	Source: Installed Distributions (/usr/local/pyenv/versions/3.8-dev/bin/pip3)

	Name        Current Version Latest Version Home Page
	----------- --------------- -------------- ----------------------------------------------------
	base58      1.0.3           2.0.0          https://github.com/keis/base58
	coveralls   1.10.0          1.11.1         http://github.com/coveralls-clients/coveralls-python
	flake8-2020 1.5.0           1.6.0          https://github.com/asottile/flake8-2020
	pyupgrade   1.26.2          2.1.0          https://github.com/asottile/pyupgrade
	Sphinx      2.3.1           2.4.3          http://sphinx-doc.org/
	tox         3.14.3          3.14.5         http://tox.readthedocs.org

an upgrade will attempt, incorrectly, to install/upgrade for EACH of the detected pip instances – ‘pip’ & ‘pip3’

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@achillesrasquinha

it ain’t pretty, but hash checking

md5sum `pyenv which pip` `pyenv which pip3` `pyenv which pip3.8`
 3d2be0865f3d653a5d23eb25da06ba8b  /usr/local/pyenv/versions/3.8-dev/bin/pip
 3d2be0865f3d653a5d23eb25da06ba8b  /usr/local/pyenv/versions/3.8-dev/bin/pip3
 3d2be0865f3d653a5d23eb25da06ba8b  /usr/local/pyenv/versions/3.8-dev/bin/pip3.8

is at least conclusive for a given venv

EDIT: Looking at the environment variables

+1, thx 4 the ref

it does not appear that any of them have anything to do with the pip path. I believe that the --pip-path optional argument is not interchangeable with the PIP-PATH environment variable (though maybe it should?)

sure seems like it should – as most of the OTHER opt args’ values have env var equivalents …

Still leaves the question – should pipupgrade be ‘smarter’ in this case, where it’s ONE installed distribution, with two differently-named, but otherwise identical,

ls -al pip pip3
	-rwxr-xr-x 1 root root 255 Mar  1 19:02 pip*
	-rwxr-xr-x 1 root root 255 Mar  1 19:02 pip3*

sha1sum pip pip3
	d3e64ac5fe5a8cd5bfff2d52418250ea9b66a012  pip
	d3e64ac5fe5a8cd5bfff2d52418250ea9b66a012  pip3

pip instances?

in the meantime, a simple py3 workaround, in bash profile, after init’ing pyenv, adding an alias

	...
	eval "$(pyenv init - --no-rehash)"
+	alias pipupgrade="pipupgrade --pip-path=$( pyenv which pip3 )"

does the trick, using only the one pip* instance,

pipupgrade --check
	Checking...
	
	Source: Installed Distributions (/usr/local/pyenv/versions/3.8-dev/bin/pip3)
	
	Name      Current Version Latest Version Home Page
	--------- --------------- -------------- -------------------------------------
	base58    1.0.3           2.0.0          https://github.com/keis/base58
	pyupgrade 1.26.2          2.1.0          https://github.com/asottile/pyupgrade

where

alias pipupgrade
	alias pipupgrade='pipupgrade --pip-path=/usr/local/pyenv/versions/3.8-dev/bin/pip3'

switches cleanly after switching py3 versions, as long as you re-source the profile.