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

Fail to resolve dependency when install_requires and extras_require have same package with different extras. #7714

Closed
ymd-h opened this issue Feb 10, 2020 · 4 comments
Labels
C: dependency resolution About choosing which dependencies to install

Comments

@ymd-h
Copy link

ymd-h commented Feb 10, 2020

Environment

  • pip version: 20.0.2
  • Python version: 3.8.1
  • OS: Linux

Docker image python:latest

Description

If I specify same package with different extras at install_requires and extras_require,
pip fails to resolve dependancy.

For example, install_require=['pandas'] and extras_require={'dev': ['pandas[test]']}

pip install .[dev] never install extra dependancies defined by pandas[test] (aka. pytest etc.)

Expected behavior

pip install . -> Same result with pip install pandas && pip install .

pip install .[dev] -> Same result with pip install pandas[test] && pip install .

How to Reproduce

docker run -it --rm python bash
mkdir -p pkg
cd pkg
echo "from setuptools import setup; setup(name='test',install_requires=['pandas'],extras_require={'dev': ['pandas[test]']})" >>  setup.py
pip install .[dev]

Output

Successfully installed numpy-1.18.1 pandas-1.0.1 python-dateutil-2.8.1 pytz-2019.3 six-1.14.0 test-0.0.0

Info
If I remove install_requires='pandas', then pandas['test'] dependancies are installed by pip install .[dev] correctly.

docker run -it --rm python bash
mkdir -p pkg
cd pkg
echo "from setuptools import setup; setup(name='test',extras_require={'dev': ['pandas[test]']})" >>  setup.py
pip install .[dev]
Successfully installed apipkg-1.5 attrs-19.3.0 execnet-1.7.1 hypothesis-5.5.1 more-itertools-8.2.0 numpy-1.18.1 packaging-20.1 pandas-1.0.1 pluggy-0.13.1 py-1.8.1 pyparsing-2.4.6 pytest-5.3.5 pytest-forked-1.1.3 pytest-xdist-1.31.0 python-dateutil-2.8.1 pytz-2019.3 six-1.14.0 sortedcontainers-2.1.0 test-0.0.0 wcwidth-0.1.8
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Feb 10, 2020
@uranusjr
Copy link
Member

uranusjr commented Feb 10, 2020

Similar to #7096, but one with extras and one without, instead of with different extras.

@ymd-h
Copy link
Author

ymd-h commented Apr 26, 2020

@uranusjr
Hi.

I've read the announcement of pip 20.1b1 release including the new resolver.

Since this issue 7714 is checked at this comment, I tested by my self, however, I couldn't confirm.

docker run -it --rm python:3.7 bash
pip install -U pip --pre #  pip-20.1b1
cd pkg
echo "from setuptools import setup; setup(name='test',install_requires=['pandas'],extras_require={'dev': ['pandas[test]']})" >>  setup.py
pip install .[dev] --unstable-feature=resolver

Result;

Successfully installed numpy-1.18.3 pandas-1.0.3 python-dateutil-2.8.1 pytz-2019.3 six-1.14.0 test-0.0.0

Still pandas[test] is ignored.

@uranusjr
Copy link
Member

Thanks for testing. I have identified the problem: the new resolver does not handle extras correctly when you install a requirement directly by path. This is because we are not passing extras correctly with ExplicitRequirement, so .[dev] lost the [dev] and was turned into ..

@uranusjr uranusjr added C: new resolver type: bug A confirmed bug or unintended behavior labels Apr 26, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Apr 26, 2020
@uranusjr
Copy link
Member

I’ve proposed a PR to fix the new resolver, and the progress will be tracked there. Meanwhile I think this can be closed with the same reasoning as #7096.

@uranusjr uranusjr added C: dependency resolution About choosing which dependencies to install and removed C: new resolver type: bug A confirmed bug or unintended behavior labels Apr 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: dependency resolution About choosing which dependencies to install
Projects
None yet
Development

No branches or pull requests

2 participants