[Distutils] Specifying Python version as part of requirements

Daniel Holth dholth at gmail.com
Sun Jul 6 18:23:32 CEST 2014


Something like

extras_require = ':python_version=="2.6"': ['argparse'],
          'example_extra_name:another == "4"': ['keyring'],

See if it works to define a test extra in extras_require, and make
your tests_require reference mypackagename[test]:

extras_require = { 'test:python_version=="2.6"': ['argparse'],
'test':['other', 'dependencies'] },
test_requires = [ 'mypackagename[test]' ]


On Sun, Jul 6, 2014 at 12:19 PM, Daniel Holth <dholth at gmail.com> wrote:
> Sorry it only works for install requires via the extras syntax.
>
> On Jul 6, 2014 12:18 PM, "Brett Cannon" <bcannon at gmail.com> wrote:
>>
>>
>>
>> On Sat Jul 05 2014 at 9:26:26 AM, Daniel Holth <dholth at gmail.com> wrote:
>>>
>>> Setuptools supports it even without wheel.
>>
>> How do you specify that since PEP 426 is oriented towards JSON metadata.
>> Would it be:
>>
>>   test_requires = ["unittest2;python_version < '3.0'"]
>>
>> ?
>>
>>
>>>
>>> On Jul 5, 2014 9:25 AM, "Brett Cannon" <bcannon at gmail.com> wrote:
>>>>
>>>>
>>>>
>>>> On Fri Jul 04 2014 at 10:38:58 PM, Daniel Holth <dholth at gmail.com>
>>>> wrote:
>>>>>
>>>>> The next wheel release and the wheel code in revision control will
>>>>> support the setuptools conditional requirements syntax. See wheel's own
>>>>> setup.py in mercurial tip. 🐙
>>>>
>>>> Glad this will work eventually, but unfortunately not all of my
>>>> dependencies have wheels yet, so I will have to stick with my setup.py 'if'
>>>> statements.
>>>>
>>>> -Brett
>>>>
>>>>>
>>>>> On Jul 4, 2014 7:48 PM, "Donald Stufft" <donald at stufft.io> wrote:
>>>>>>
>>>>>> So this is in PEP uh, 426 I think. It’s not final yet but it kinda
>>>>>> works right now for Wheels.
>>>>>>
>>>>>> Basically you do a conditional include to install_requires in your
>>>>>> setup.py, and then if
>>>>>> you’re creating wheels you do something like ->
>>>>>> https://github.com/dstufft/twine/blob/master/setup.cfg#L9-L13
>>>>>>
>>>>>> That will overwrite install_requires, but only for Wheels.
>>>>>>
>>>>>> On Jul 4, 2014, at 6:51 PM, Brett Cannon <bcannon at gmail.com> wrote:
>>>>>>
>>>>>> > I just checked PEP 440 and pip doesn't seem to have anything
>>>>>> > specific, so I thought I would ask if there is any way now or in the future
>>>>>> > to specify that a dependency is only needed for certain versions of Python?
>>>>>> >
>>>>>> > My current use case is I want to use unittest2, but pip errors out
>>>>>> > during installation under Python 3 of it since unittest2 imports itself and
>>>>>> > triggers a syntax error. Instead of having to hack around this by making it
>>>>>> > a conditional include in my setup.py I would like to declare that I only
>>>>>> > need it in Python 2.x in a requirements.txt file or something.
>>>>>> > _______________________________________________
>>>>>> > Distutils-SIG maillist  -  Distutils-SIG at python.org
>>>>>> > https://mail.python.org/mailman/listinfo/distutils-sig
>>>>>>
>>>>>>
>>>>>> -----------------
>>>>>> Donald Stufft
>>>>>> PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9
>>>>>> 3372 DCFA
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Distutils-SIG maillist  -  Distutils-SIG at python.org
>>>>>> https://mail.python.org/mailman/listinfo/distutils-sig
>>>>>>
>


More information about the Distutils-SIG mailing list