question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editable installs do not satisfy dependencies when using pip>=20.2 and Python 2.7

See original GitHub issue

Environment

  • pip version: 20.2.1
  • Python version: 2.7.17
  • OS: Ubuntu 18.04 64-bit

Description

Regression in dependency resolution (not the new resolver) where already installed “editable” packages are no longer taken into account when satisfying dependencies. Only happens with the combination of pip>=20.2 and Python 2.7; older pip or using Python 3.x doesn’t give the same issue. Happens with both path and VCS editable installs.

Expected behavior

Already installed editable packages should satisfy dependencies when installing another package, consistent with behaviour when using older pip versions or newer Python versions.

How to Reproduce

  1. Create two basic packages: package-a which has no dependencies, and package-b which depends only on package-a
  2. Create and activate a Python 2.7 virtualenv
  3. Perform an editable install of package-a, see a successful installation
  4. Perform an editable install of package-b, see Could not find a version that satisfies the requirement package-a
  5. Observe that pip freeze definitely contains package-a
  6. Observe that pkg_resources.get_distribution("package-a") gives a valid result
  7. Downgrade pip to an earlier version, repeat editable install of package-b, see a successful installation

Output

$ mkdir -p package_a package_b

$ cat > package_a/setup.py <<EOF
from setuptools import setup, find_packages

setup(
    name="package-a",
    version="0.1",
    packages=find_packages(),
)
EOF

$ cat > package_b/setup.py <<EOF
from setuptools import setup, find_packages

setup(
    name="package-b",
    version="0.1",
    packages=find_packages(),
    install_requires=["package-a"],
)
EOF

$ virtualenv -p python2.7 venv
Running virtualenv with interpreter /usr/bin/python2.7
Already using interpreter /usr/bin/python2.7
New python executable in /home/alanb/tmp/venv/bin/python2.7
Also creating executable in /home/alanb/tmp/venv/bin/python
Installing setuptools, pip, wheel...
done.

$ source venv/bin/activate

$ pip --version
pip 20.2.1 from /home/alanb/tmp/venv/local/lib/python2.7/site-packages/pip (python 2.7)

$ pip install -e package_a/
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Obtaining file:///home/alanb/tmp/package_a
Installing collected packages: package-a
  Running setup.py develop for package-a
Successfully installed package-a

$ pip install -e package_b/
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Obtaining file:///home/alanb/tmp/package_b
ERROR: Could not find a version that satisfies the requirement package-a (from package-b==0.1) (from versions: none)
ERROR: No matching distribution found for package-a (from package-b==0.1)

$ pip freeze
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
# Editable install with no version control (package-a==0.1)
-e /home/alanb/tmp/package_a

$ python -c 'import pkg_resources; print(pkg_resources.get_distribution("package-a"))'
package-a 0.1

$ pip install 'pip<20.2'
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pip<20.2
  Using cached pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.1
    Uninstalling pip-20.2.1:
      Successfully uninstalled pip-20.2.1
Successfully installed pip-20.1.1

$ pip install -e package_b/
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Obtaining file:///home/alanb/tmp/package_b
Requirement already satisfied: package-a in ./package_a (from package-b==0.1) (0.1)
Installing collected packages: package-b
  Running setup.py develop for package-b
Successfully installed package-b
WARNING: You are using pip version 20.1.1; however, version 20.2.1 is available.
You should consider upgrading via the '/home/alanb/tmp/venv/bin/python2.7 -m pip install --upgrade pip' command.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alanbriolatcommented, Aug 5, 2020

@sbidoul Thanks, #8702 seems to fix the issue and give the expected behaviour:

$ pip install -U "pip @ git+https://github.com/pypa/pip@refs/pull/8702/head"
[...]
Successfully installed pip-20.3.dev0

$ pip install  -e package_a/
[...]
Obtaining file:///home/alanb/tmp/pip-bug/package_a
Installing collected packages: package-a
  Running setup.py develop for package-a
Successfully installed package-a

$ pip install  -e package_b/
[...]
Obtaining file:///home/alanb/tmp/pip-bug/package_b
Requirement already satisfied: package-a in ./package_a (from package-b==0.1) (0.1)
Installing collected packages: package-b
  Running setup.py develop for package-b
Successfully installed package-b

$ pip freeze
[...]
# Editable install with no version control (package-a==0.1)
-e /home/alanb/tmp/pip-bug/package_a
# Editable install with no version control (package-b==0.1)
-e /home/alanb/tmp/pip-bug/package_b
0reactions
sbidoulcommented, Aug 11, 2020

I think we can close this issue as the root cause is tracked in #5193.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 518 and editable mode: don't install already-satisfied ...
We maintain a package (scikit-learn) that has Cython and numpy as build dependencies. Cython compiles .pyx files to .c which are then compiled ......
Read more >
Changelog - pip documentation v22.3.1
Fix pip install --pre for packages with pre-release build dependencies defined both ... version cannot be retrieved when Requires-Python is not satisfied.
Read more >
Releasing pip 20.3, featuring new dependency resolver
When users use pip 20.3 in a Python 2 environment, the old dependency resolver is still the default. For more info or to...
Read more >
User Guide - 《pip v20.3.3 documentation》 - 书栈网
The most common scenario is to install from PyPI using ... only-if-needed : upgrades a dependency only if it does not satisfy the...
Read more >
How to Install Python Pip on Ubuntu 20.04 - Linuxize
Pip for Python 2 is not included in the Ubuntu 20.04 repositories. We'll be installing pip for Python 2 using the get-pip.py script....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found