[Distutils] setuptools: can I specify different install_requires for different python versions?
Sridhar Ratnakumar
SridharR at activestate.com
Tue Jul 28 21:38:37 CEST 2009
On Tue, 28 Jul 2009 12:26:52 -0700, P.J. Eby <pje at telecommunity.com> wrote:
> At 03:04 PM 7/28/2009 -0400, Matthew Wilson wrote:
> I have a package that depends on the multiprocessing package, which
> got added to the standard library as of 2.6.
> So, for only those people using python versions before 2.6, I want to
> require they install multiprocessing.
> Is this possible?
> Yes. Write your setup.py to check the Python version, and build up the
> requirements in a variable before calling setup().
I'm -1 on this solution. I'd rather have multiprocessing installed as
requirement - till [1] (or something equivalent) is implemented - and then
simply do a "import multiprocessing" which would pick up the stdlib
multiprocessing (if >2.6) or pickup the installed one. I noticed some
packages doing this already.
To explain - if developers begin to specify metadata in a conditional way
in their setup.py, then there is no point in keeping metadata (PKG-INFO,
requires.txt) within the sdist. Besides - it encourages tools (eg:
pkginfo/pypm) to parse those files in order to determine the package
metadata.
This is just another reason why I favor a standardized metadata (with
install_requires support) and a static setup.py metadata.
[1] One way to implement conditional requirements is to make use of
Requirement.extras. If setuptools/distribute supports builtin extras -
such as Py26, Py27, Py30 and so forth .. even Py3x to cover all 3.x
versions - then one can have a [<Py26] section in their install_requires
that would specify requirements specific to versions below 2.6.
-srid
PS: PyPM relies on these metadata files that are *already* part of the
sdist. This email is another reason to find ways to generate PKG-INFO
using setuptools' egg_info command .. which, however, means one has to run
setup.py with all its silly hacks (raw_input() anyone?).
More information about the Distutils-SIG
mailing list