|In Brief||Ever wish you could give a choice between prerequisites in your setup.py file? Now you can.... more|
1from setuptools import setup, find_packages
2from pkg_resources import require, DistributionNotFound
4# Load the PreferedDist only unless the LessPreferedDist is already installed
9 required = 'PreferedDist'
Ever wish you could give a choice between prerequisites in your setup.py file? Now you can.
This code checks to see if your less preferred distribution is already installed. If it is, it is set as the required distribution, and if not your more preferred package is set as the required distribution.
The result of this is that if either is installed, it will be set as the required distribution, and installation will proceed. If neither is, the more preferred distribution will be set as the required distribution and be installed.