I have a requirements.txt
file that I'm using with Travis-CI. It seems silly to duplicate the requirements in both requirements.txt
and setup.py
, so I was hoping to pass a file handle to the install_requires
kwarg in setuptools.setup
.
Is this possible? If so, how should I go about doing it?
Here is my requirements.txt
file:
guessit>=0.5.2
tvdb_api>=1.8.2
hachoir-metadata>=1.3.3
hachoir-core>=1.3.3
hachoir-parser>=1.3.4
If you don't want to force your users to install pip, you can emulate its behavior with this:
I created a reusable function for this. It actually parses an entire directory of requirements files and sets them to extras_require.
Latest always available here: https://gist.github.com/akatrevorjay/293c26fefa24a7b812f5
Using
parse_requirements
is problematic because the pip API isn't publicly documented and supported. In pip 1.6, that function is actually moving, so existing uses of it are likely to break.A more reliable way to eliminate duplication between
setup.py
andrequirements.txt
is to specific your dependencies insetup.py
and then put-e .
into yourrequirements.txt
file. Some information from one of thepip
developers about why that's a better way to go is available here: https://caremad.io/blog/setup-vs-requirement/BEWARE OF
parse_requirements
BEHAVIOUR!Please note that
pip.req.parse_requirements
will change underscores to dashes. This was enraging me for a few days before I discovered it. Example demonstrating:produces