pypa/pip

extras_require isn't honored if a package is already installed without them

kkellyy opened this issue · 10 comments

  • Pip version: 8.1.2
  • Python version: 3.4
  • Operating System: Ubuntu 10.04

Description:

I want to install pre-commit and bravado-core into my virtualenv. If I install pre-commit first, the format extras (link) that bravado-core requires from the jsonschema package are ignored (claims that requirement already satisfied if you run the commands separately).

What I've run:

This exactly recreates skipping jsonschema[format] extras that are required by bravado-core.

$ virtualenv venv --python=python3.4 && . venv/bin/activate
Running virtualenv with interpreter /usr/bin/python3.4
Using base prefix '/usr'
New python executable in venv/bin/python3.4
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799bd798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl#md5=0570520434c5b600d89ec95393b2650b
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.5
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...
$ pip install pre-commit bravado-core
Collecting pre-commit
  Downloading pre_commit-0.8.2-py2.py3-none-any.whl (102kB)
    100% |████████████████████████████████| 112kB 6.9MB/s
Collecting bravado-core
  Downloading bravado-core-4.3.1.tar.gz
Collecting aspy.yaml (from pre-commit)
  Downloading aspy.yaml-0.2.2-py2.py3-none-any.whl
Collecting virtualenv (from pre-commit)
  Downloading virtualenv-15.0.3-py2.py3-none-any.whl (3.5MB)
    100% |████████████████████████████████| 3.5MB 389kB/s
Collecting cached-property (from pre-commit)
  Downloading cached_property-1.3.0-py2.py3-none-any.whl
Collecting nodeenv>=0.11.1 (from pre-commit)
  Downloading nodeenv-0.13.6.tar.gz
Collecting jsonschema (from pre-commit)
  Downloading jsonschema-2.5.1-py2.py3-none-any.whl
Collecting pyyaml (from pre-commit)
  Downloading PyYAML-3.11.zip (371kB)
    100% |████████████████████████████████| 378kB 3.8MB/s
Collecting pyterminalsize (from pre-commit)
  Downloading pyterminalsize-0.1.0.tar.gz
Collecting python-dateutil (from bravado-core)
  Downloading python_dateutil-2.5.3-py2.py3-none-any.whl (201kB)
    100% |████████████████████████████████| 204kB 5.1MB/s
Collecting simplejson (from bravado-core)
  Downloading simplejson-3.8.2.tar.gz (76kB)
    100% |████████████████████████████████| 81kB 9.9MB/s
Collecting six (from bravado-core)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting swagger-spec-validator>=2.0.1 (from bravado-core)
  Downloading swagger_spec_validator-2.0.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./venv/lib/python3.4/site-packages (from swagger-spec-validator>=2.0.1->bravado-core)
Installing collected packages: pyyaml, aspy.yaml, virtualenv, cached-property, nodeenv, jsonschema, pyterminalsize, pre-commit, six, python-dateutil, simplejson, swagger-spec-validator, bravado-core
  Running setup.py install for pyyaml ... done
  Running setup.py install for nodeenv ... done
  Running setup.py install for pyterminalsize ... done
  Running setup.py install for simplejson ... done
  Running setup.py install for swagger-spec-validator ... done
  Running setup.py install for bravado-core ... done
Successfully installed aspy.yaml-0.2.2 bravado-core-4.3.1 cached-property-1.3.0 jsonschema-2.5.1 nodeenv-0.13.6 pre-commit-0.8.2 pyterminalsize-0.1.0 python-dateutil-2.5.3 pyyaml-3.11 simplejson-3.8.2 six-1.10.0 swagger-spec-validator-2.0.2 virtualenv-15.0.3

Expected behavior:

This should install rfc3987, strict-rfc3339, and webcolors, but it does not. Install order should not matter.

pre-commit requires 'jsonschema',
bravado-core requires "jsonschema[format]>=2.5.1"

You're saying it also fails if you pip install bravado-core as a second command, any time after pre-commit (or jsonschema) has been installed?

Yes, if you run pip install bravado-core again (or if you just run two separate pip install commands) it outputs:

Requirement already satisfied (use --upgrade to upgrade): jsonschema[format]>=2.5.1 in ./venv/lib/python3.4/site-packages (from bravado-core)
  Installing extra requirements: 'format'

It never actually installs those extra requirements, though. It never mentions the extras packages by name and they're never installed in site-packages

Here's some additional discussion about this issue: Yelp/bravado-core#96

+1

I get the same issue as well. I have 2 packages listed in my requirements.txt that depend on requests and requests[security] respectively. If both are installed in one go i.e. pip install -r requirements.txt, requests[security] will not be resolved in my dependency graph. I solve this by explicitly listing requests[security] in my requirements.txt

There's some work in pull #3878 for this.

Closing this, I can't reproduce this. If you're still having issues please open a new issue with reproduction steps.

pre-commit no longer depends on jsonschema, probably why this isn't reproducing. I'll make a new set of reproduction steps and open a new ticket :)

I tried it with requests:

$ pip install requests
Collecting requests
  Using cached requests-2.13.0-py2.py3-none-any.whl
Installing collected packages: requests
Successfully installed requests-2.13.0

$ pip install 'requests[security]'
Requirement already satisfied: requests[security] in ./lib/python3.6/site-packages
Collecting cryptography>=1.3.4; extra == "security" (from requests[security])
  Using cached cryptography-1.8.1-cp36-cp36m-macosx_10_10_x86_64.whl
Collecting pyOpenSSL>=0.14; extra == "security" (from requests[security])
  Using cached pyOpenSSL-16.2.0-py2.py3-none-any.whl
Collecting idna>=2.0.0; extra == "security" (from requests[security])
  Using cached idna-2.5-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; extra == "security"->requests[security])
  Using cached asn1crypto-0.22.0-py2.py3-none-any.whl
Requirement already satisfied: packaging in ./lib/python3.6/site-packages (from cryptography>=1.3.4; extra == "security"->requests[security])
Requirement already satisfied: six>=1.4.1 in ./lib/python3.6/site-packages (from cryptography>=1.3.4; extra == "security"->requests[security])
Requirement already satisfied: setuptools>=11.3 in ./lib/python3.6/site-packages (from cryptography>=1.3.4; extra == "security"->requests[security])
Collecting cffi>=1.4.1 (from cryptography>=1.3.4; extra == "security"->requests[security])
  Using cached cffi-1.10.0-cp36-cp36m-macosx_10_6_intel.whl
Requirement already satisfied: pyparsing in ./lib/python3.6/site-packages (from packaging->cryptography>=1.3.4; extra == "security"->requests[security])
Requirement already satisfied: appdirs>=1.4.0 in ./lib/python3.6/site-packages (from setuptools>=11.3->cryptography>=1.3.4; extra == "security"->requests[security])
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.3.4; extra == "security"->requests[security])
Installing collected packages: asn1crypto, idna, pycparser, cffi, cryptography, pyOpenSSL
Successfully installed asn1crypto-0.22.0 cffi-1.10.0 cryptography-1.8.1 idna-2.5 pyOpenSSL-16.2.0 pycparser-2.17

I've opened #4391