7

My setup.py looks something like this:

from distutils.core import setup

setup(
    [...]
    install_requires=['gevent', 'ssl', 'configobj', 'simplejson', 'mechanize'],
    [...]
)

Under Python 2.6 (or higher) the installation of the ssl module fails with:

ValueError: This extension should not be used with Python 2.6 or later (already built in), and has not been tested with Python 2.3.4 or earlier.

Is there a standard way to define dependencies only for specific python versions? Of course I could do it with if float(sys.version[:3]) < 2.6: but maybe there is a better way to do it.

1

1 Answer 1

12

It's just a list, so somewhere above you have to conditionally build a list. Something like to following is commonly done.

import sys

if sys.version_info < (2 , 6):
    REQUIRES = ['gevent', 'ssl', 'configobj', 'simplejson', 'mechanize'],
else:
    REQUIRES = ['gevent', 'configobj', 'simplejson', 'mechanize'],

setup(
# [...]
    install_requires=REQUIRES,
# [...]
)
Sign up to request clarification or add additional context in comments.

1 Comment

There is now a better way, described in this answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.