Search code examples
pythonpython-2.7setuptoolsdistutilsleveldb

setup.py "nice to have" dependency modules


I'm looking at a setup.py file that looks a bit like this one:

#!/usr/bin/env python
from setuptools import setup, find_packages
import sys

if sys.argv[1] == 'test':
    import multiprocessing, logging
    from billiard import util

with open('requirements.txt') as f:
    required = f.read().splitlines()

if sys.version_info < (2, 7, 0):
    required.append('importlib')

setup(
    version='0.1',
    name='...',
    description='...',
    author='...',
    author_email='...',
    packages=find_packages(),
    package_data={},
    install_requires=required,
    include_package_data=True,
    tests_require=[
        'billiard',
        'nose==1.3'
    ],
    test_suite='nose.collector'
)

I am trying to install the module on windows. It would appear that the module has been developed on another OS as it fails to compile one of the modules (leveldb) in requirements.txt.

Looking at the code, it looks like it might work without leveldb (though perhaps with poorer performance). Is there any easy way to change the status of the leveldb library so its failure to install doesn't stop the main module from installing?

Clearly I could remove the dependency from requirements.txt, but I'm considering how the libary might be edited to accomodate windows.


Solution

  • You can declare optional dependencies as extras in your setup.py