9

We are using pip -e . to install our package in editable/development mode, instead of using python setup.py develop. (We have to do so, because we pull packages from the public PyPi server and a private one. This did not worked for us using python setup.py develop.)

But pip -e . does not install test dependencies and I could not find some flag to force it to do so. How do I install test dependencies using pip?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Achim
  • 15,415
  • 15
  • 80
  • 144
  • Have you tried `python setup.py test`? If properly set up, this will install test-specific dependencies and run all tests. – jonrsharpe Jan 09 '15 at 13:55
  • For anyone only coming across this question now, please see my comment [here](https://stackoverflow.com/questions/29870629/pip-install-test-dependencies-for-tox-from-setup-py#comment122181805_29870629) on the recent deprecation of `tests_require`. – smheidrich Sep 10 '21 at 09:54

2 Answers2

5

I use extra_require in the setup.py as specified here. For example:

setup(
    name="Project-A",
    ...
    extras_require={
        'develop':  ["mock==2.0.0"],
    }
)

And to execute it using pip install:

pip install -e .[develop]

Or as suggested below the expanded version:

python -m pip install --editable '.[develop]'
aitorhh
  • 2,331
  • 1
  • 23
  • 35
1

For anyone coming later with zsh as their default shell this may save you some grief.

Turns out zsh interprets the dot as a special character so this won't work:

python -m pip install --editable .[develop]

You need to quote the extras like so:

python -m pip install --editable '.[develop]'
sinoroc
  • 18,409
  • 2
  • 39
  • 70