Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying optional dependencies in pypi python setup.py

How do I specify optional dependencies in python's setup.py ?

Here's my stab at specifying an optional dependency for an open source library of mine but it doesn't seem to do much.

https://github.com/od-eon/django-cherrypy/blob/master/setup.py

Specifically extra_requires in this snippet:

setup(     name='django-cherrypy',     version='0.1',     packages=packages,     license='LICENSE',     description='cherrypy, running under django',     long_description=open('README.md').read(),     author='Calvin Cheng',     author_email='[email protected]',     install_requires=['cherrypy-wsgiserver'],     extra_requires=['newrelic'],     url='https://github.com/od-eon/django-cherrypy', ) 

Suggestions?

like image 490
Calvin Cheng Avatar asked May 13 '12 14:05

Calvin Cheng


People also ask

What are optional dependencies in python?

Optional dependenciesSetuptools allows you to declare dependencies that are not installed by default. This effectively means that you can create a “variant” of your package with a set of extra functionalities.

What is Setup_requires in setup py?

The items listed in setup_requires get implicitly installed whenever you execute the setup.py but one of the common ways that the setup.py is executed is via another tool, such as pip , who is already managing dependencies.

What is the difference between setup py and requirements txt?

The short answer is that requirements. txt is for listing package requirements only. setup.py on the other hand is more like an installation script. If you don't plan on installing the python code, typically you would only need requirements.

What is Package_dir in setup py?

package_dir = {'': 'lib'} in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root.


1 Answers

You've got an incorrect keyword. It's extras_require, and it's supposed to be a dict.

setup(     name="django-cherrypy",     ...     extras_require = {         'mysterious_feature_x':  ["newrelic"]     } ) 
like image 80
voithos Avatar answered Oct 13 '22 19:10

voithos