Your setup.py is just plain Python code, so you do the exact same thing you do in your source code in the setup script.
The documentation shows how to switch on sys.version_info for doing 3.x vs. 2.x code, but it works the same way for 2.7 vs. 2.6. So, if your code is doing this:
if sys.version_info < (2, 7);
from ordereddict import OrderedDict
else:
from collections import OrderedDict
… then your setup script can do this:
import sys
from setuptools import setup
extra_install_requires = []
if sys.version_info < (2, 7):
extra_install_requires.append('ordereddict>=1.1')
setup(
# ...
install_requires = [...] + extra_install_requires,
# ...
)
On the other hand, if your code is doing this:
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
… then, while you could use version_info, you might as well just do this:
extra_install_requires = []
try:
from collections import OrderedDict
except ImportError:
extra_install_requires.append('ordereddict>=1.1')
Either way, if you, e.g., pip-2.5 install this package, it'll download and install the ordereddict module (unless the user already has 1.1 or later); with 2.7, it won't do anthying.
If you're looking to distribute pre-built eggs, then yes, they will end up different for Python 2.6 and 2.7. For example, after python2.6 setup.py bdist_egg && python2.7 setup.py bdist_egg, you will end up with dist/Foo-0.1-py2.6.egg and dist/Foo-0.1-py2.7.egg, and you will have to distribute both of them.