Skip to content

pip check does not check extra requirements #4204

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

Closed
augurar opened this issue Dec 24, 2016 · 2 comments
Closed

pip check does not check extra requirements #4204

augurar opened this issue Dec 24, 2016 · 2 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@augurar
Copy link

augurar commented Dec 24, 2016

  • Pip version: 9.0.1
  • Python version: Python 2.7.3
  • Operating System: Ubuntu 12.04.5 LTS

Description:

Based on the description pip check is intended to check for unsatisfied dependencies in installed packages. However, this does not seem to catch dependency issues related to extras.

Reproducing the issue:

Create packages a, b, c, and d.

.
├── a
│   ├── a
│   └── __init__.py
│   └── setup.py
├── b
│   ├── b
│   │   └── __init__.py
│   └── setup.py
├── c
│   ├── c
│   │   └── __init__.py
│   └── setup.py
└── d
    ├── d
    │   └── __init__.py
    └── setup.py
from setuptools import setup, find_packages

setup(
    name="a",
    version="1.0",
    packages=find_packages(),
)
from setuptools import setup, find_packages

setup(
    name="b",
    version='1.0',
    packages=find_packages(),
    extras_require={
        'a': ['a'],
    },
)
from setuptools import setup, find_packages

setup(
    name="c",
    version="1.0",
    packages=find_packages(),
    install_requires=[
        'b',
    ],
)
from setuptools import setup, find_packages

setup(
    name="d",
    version="1.0",
    packages=find_packages(),
    install_requires=[
        'b[a]',
    ],
)

Create dists for all four packages and install to a local pypi. Then (assuming the local pypi is running on localhost port 8080):

$ pip install -i http://localhost:8080 c d
$ pip uninstall a

Now we have an issue, since c --> b[a] --> a, but a is not installed. However, pip check does not catch this issue.

$ pip check
No broken requirements found.

The following script detects the problem:

import pip
import pkg_resources

pkg_resources.require(str(dep.as_requirement())
                      for dep in pip.get_installed_distributions())
$ python check_dependencies.py 
Traceback (most recent call last):
  File "check_dependencies.py", line 5, in <module>
    for dep in pip.get_installed_distributions())
  File ".../venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 963, in require
    needed = self.resolve(parse_requirements(requirements))
  File ".../venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'a; extra == "a"' distribution was not found and is required by b
@augurar augurar changed the title pip check does not check extra requirements pip check does not check extra requirements Dec 24, 2016
@xavfernandez
Copy link
Member

Duplicate of #4086

@augurar
Copy link
Author

augurar commented Dec 24, 2016

@xavfernandez Agreed, sorry. Closing.

@augurar augurar closed this as completed Dec 24, 2016
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

2 participants