Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optional dependencies in distutils / pip

When installing my python package, I want to be able to tell the user about various optional dependencies. Ideally I would also like to print out a message about these optional requirements and what each of them do.

I haven't seen anything yet in the docs of either pip or docutils. Do tools these support optional dependencies?

like image 212
Mike Cooper Avatar asked Jun 04 '11 16:06

Mike Cooper


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.

Where is pip requirements txt?

Typically the requirements. txt file is located in the root directory of your project. Notice we have a line for each package, then a version number. This is important because as you start developing your python applications, you will develop the application with specific versions of the packages in mind.

What is setup CFG used for?

setup. cfg is a file which might be used to specify such options in addition to reading the command line when calling python setup.py <somecommand> . The documentation for setup.


1 Answers

These are called extras, here is how to use them in your setup.py.

The base support is in pkg_resources. You need to enable distribute in your setup.py. pip will also understand them:

pip install 'package[extras]' 
like image 119
Tobu Avatar answered Oct 04 '22 10:10

Tobu