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.

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top