8

I know that pip install . will install the dependencies defined in install_requires, but what pip command(s) will install the dependencies defined in setuptools.setup's setup_requires and tests_require?

Simple setup.py:

import setuptools

setuptools.setup(
    name="my_app",
    version="0.1.0",
    url="http://me.com",
    install_requires=['openpyxl'],
    setup_requires=['pytest-runner'],
    tests_require=['lxml'],
    classifiers=[
        # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
        'Development Status :: 2 - Pre-Alpha',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3.6',
    ],
)

I created a new temp virtualenv, using virtualenvwrapper's mktmpenv, and then executed the following:

$ pip list --format=columns
Package    Version
---------- -------
pip        9.0.1
setuptools 36.2.7
wheel      0.29.0

$ pip install .
Processing ...
Collecting openpyxl (from my-app==0.1.0)
Collecting jdcal (from openpyxl->my-app==0.1.0)
Collecting et-xmlfile (from openpyxl->my-app==0.1.0)
Building wheels for collected packages: my-app
  Running setup.py bdist_wheel for my-app: started
  Running setup.py bdist_wheel for my-app: finished with status 'done'
  Stored in directory: C:\Users\nahawk\AppData\Local\pip\Cache\wheels\49\e2\8d\340d2b19ba48f1a84011f0e649fe957c19efaf34500f0edada
Successfully built my-app
Installing collected packages: jdcal, et-xmlfile, openpyxl, my-app
Successfully installed et-xmlfile-1.0.1 jdcal-1.3 my-app-0.1.0 openpyxl-2.4.8

$ pip list --format=columns
Package    Version
---------- -------
et-xmlfile 1.0.1
jdcal      1.3
my-app     0.1.0
openpyxl   2.4.8
pip        9.0.1
setuptools 36.2.7
wheel      0.29.0
(tmp-60bebb2a3e1151e0) /c/Users/nahawk/code/coke/nsr/nsr-automated-deployment master

Note that lxml defined in tests_require and pytest-runner defined in setup_requires were not installed. So, how do I install them using pip? (Obviously, I'm not looking for pip install lxml pytest-runner)

successhawk
  • 3,071
  • 3
  • 28
  • 44
  • `pip install -r --user` just point to the system file location, unless I misunderstand your question. – Noqomo Aug 11 '17 at 15:48
  • Possible duplicate of [pip install test dependencies for tox from setup.py](https://stackoverflow.com/questions/29870629/pip-install-test-dependencies-for-tox-from-setup-py) – Jack Evans Aug 11 '17 at 15:49
  • Why don't you use `install_requires` in `setup.py`? – Avihoo Mamka Aug 11 '17 at 15:50
  • 1
    @AvihooMamka because my app doesn't depend on pytest-runner or lxml, only the tests do. – successhawk Aug 11 '17 at 15:56
  • @Noqomo I purposefully didn't mention a requirements file. I know that I could list all of the dependencies in a requirements file, but I'm looking for a cleaner approach that clearly separates app dependencies from test dependencies. – successhawk Aug 11 '17 at 16:00
  • 1
    @JackEvans I don't think this is a duplicate of that question, but the answer https://stackoverflow.com/a/41398850/2789445 does provide me a workaround if there isn't a direct answer to my question. Thanks! – successhawk Aug 11 '17 at 16:14
  • 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

0 Answers0