Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip wheel conditional dependencies

While working on a virtualenv for developing a python package, I use to issue a "pip wheel ." to generate all wheel archives needed for the package. I start using conditional dependencies by listing them in the setuptools extras_require parameter. Is it possible to generage the wheel archives of a specific conditional dependency?

Something like: pip wheel ".[conditional_feature]" is not supported. (at least on python-2.7) Note that I can install these dependencies in the virtualenv with: pip install -e ".[conditional_feature]"

like image 545
yorjo Avatar asked Jun 17 '14 04:06

yorjo


People also ask

Does a wheel file include dependencies?

whl) files. Wheels are a binary installable format that includes the package and its dependencies. If both sdisk and wheel formats are available on PyPI, pip will prefer a compatible wheel. If pip does not find a wheel to install, it will automatically build a wheel and install it for you.

Do Python wheels include dependencies?

Python package installed with pip , e.g. WheelPython dependencies can be specified as dependencies in your packaging, and automatically installed by pip . You can include third party C libraries in wheels, but for sufficiently complex dependencies that won't work.

Does pip check for dependencies?

The pip install <package> command always looks for the latest version of the package and installs it. It also searches for dependencies listed in the package metadata and installs them to ensure that the package has all the requirements that it needs.

How do I resolve dependencies in pip?

Pip does not provide true dependency resolution, but this can be solved by using it in conjunction with a requirements. txt file. Requirements. txt files can be used to make pip resolve dependency conflicts between different packages.


1 Answers

See my answer and this script that helps you doing exactly that with a different approach using multiple requirements files and a condition to use one or the other.

Update

Note also that with the latest version (2017) of the pypa trio (pip,setuptools, wheel) you can now use conditional requirements directly. Here is an example with extra_requires that install various versions of lxml on different OSes:

extras_require={
        ':platform_system == "Windows"': ['lxml == 3.6.0'],
        ':platform_system == "Linux"': ['lxml == 3.6.4'],
        ':platform_system == "Darwin"': ['lxml == 3.6.4'],

},

You can do a lot more than this of course with even more complex expressions.

like image 177
Philippe Ombredanne Avatar answered Oct 20 '22 21:10

Philippe Ombredanne