If designing a setup.py and there are requirements that can be fulfilled through two different modules, i.e. only one of the two needs to be installed, how do I express that in the install_requires line?
E.g. the setup.py looks like this:
setup(
name='my_module',
version='0.1.2',
url='...',
...,
install_requires=['numpy', 'tensorflow']
)
When doing pip install my_module this will install tensorflow (CPU) as a requirement, even though tensorflow-gpu is installed (which would meet the requirement as well, but doesn't, since it's named differently).
Can I do something like:
install_requires=['numpy', 'tensorflow' or 'tensorflow-gpu']
You need an extras_require in your setup function:
extras_require = {
'gpu': ['tensorflow-gpu'],
'cpu': ['tensorflow']
},
Which then can be installed with:
pip install your_package[gpu] or pip install your_package[cpu]
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With