Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I include Sphinx and/or Nose in my module's requirements.txt?

I've created a Python module on Github that uses Nose for unit testing and Sphinx for generating documentation. I have two questions:

  • Should I include Sphinx and/or Nose in my module's dependencies in setup.py (install_requires), as they are not required for basic module functionality, only if you want to build the documentation/run tests yourself?

  • Should I include Sphinx and/or Nose in my module's requirements.txt on Github, for the same reasons but users that download my project from Github might be more likely to build docs/run tests?

This is my first Python module, so a bit of best practices/standards advice would be appreciated.

like image 788
goldsmith Avatar asked Aug 25 '13 06:08

goldsmith


People also ask

How do you freeze requirements?

The most common command is pip freeze > requirements. txt , which records an environment's current package list into requirements. txt. If you want to install the dependencies in a virtual environment, create and activate that environment first, then use the Install from requirements.


2 Answers

If nose and/or sphinx are not required for the basic functionality of your package then don't include them in setup.py. There's no point in forcing users to install packages that they might not ever use. If they eventually want to help you develop your package they can install the requisite packages themselves.

requirements.txt files should also not include development-required packages, though there's some wiggle room there.

For example, over at pandas we use requirements files for our Travis-CI builds. You can check them out here.

One thing we are considering is building our documentation on Travis-CI, as sometimes a failed doc build catches bugs that the test suite doesn't. In that case we would put sphinx in the requirements file of the Python version we use to build the documentation.

like image 84
Phillip Cloud Avatar answered Sep 23 '22 04:09

Phillip Cloud


Don't include those nice-to-haves in your setup.py. You can write a requirements file for developers if you like; users won't need one. For example, call one file reqs.development:

-e . # include the package defined by setup.py in editable (development) mode
nose
sphinx

Users can pip install yourmodule or pip install https://your/tarball, developers can fork, clone and pip install -r reqs.development.

like image 24
Tobu Avatar answered Sep 21 '22 04:09

Tobu