[Distutils] PEP-426 environment markers [was: Re: Support for condition to include or exclude a buildout sections based on a Python expression]

Philippe Ombredanne pombredanne at nexb.com
Wed Jan 30 15:00:55 CET 2013


On Wed, Jan 30, 2013 at 1:39 PM, Jim Fulton <jim at zope.com> wrote:
> On Tue, Jan 29, 2013 at 6:25 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Wed, Jan 30, 2013 at 12:02 AM, Philippe Ombredanne
>> <pombredanne at nexb.com> wrote:
>>> All:
>>>
>>> I prepared a pull request https://github.com/buildout/buildout/pull/51
>>> to add support in Buildout 2 for conditional sections expressions.
>>
>> If you're going to do something like this, it would be good to base it
>> on PEP 345/426 style "environment markers", which are basically the
>> same idea applied to dependency definitions in the package metadata:
>> http://www.python.org/dev/peps/pep-0426/#environment-markers
>
> I think it makes sense to support these markers.

This is rather easy with a caveat:
http://www.python.org/dev/peps/pep-0426/#environment-markers
defines markers EXPR as one of these:

    python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
    python_full_version = sys.version.split()[0]
    os.name = os.name
    sys.platform = sys.platform
    platform.version = platform.version()
    platform.machine = platform.machine()
    platform.python_implementation = platform.python_implementation()
    a free string, like '2.4', or 'win32'
    extra = (name of requested feature) or None

A python implementation of the proposed draft would have to monkey
patch standard functions (platform.version, platform.machine and
platform.python_implementation) with their invocation results or would
require rather complex parsing.....

Since this is a draft, could we instead avoid a module-like syntax for
all EXPR and instead use this:

    python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
    python_full_version = sys.version.split()[0]
    os_name = os.name
    sys_platform = sys.platform
    platform_version = platform.version()
    platform_machine = platform.machine()
    platform_python_implementation = platform.python_implementation()
    a free string, like '2.4', or 'win32'
    extra = (name of requested feature) or None

This sounds more consistent to me to replace the dots with _
consistently the same way the original python_version has been
specified

Also, platform.python_implementation() is new in Python 2.6 .... so
this could not run on 2.5 or 2.5  .... even though the PEP alludes to
support of 2.4 and 2.5
This is not an issue for Buildout 2.0, but could be for the PEP
-- 
Philippe Ombredanne

+1 650 799 0949 | pombredanne at nexB.com
DejaCode Enterprise at http://www.dejacode.com
nexB Inc. at http://www.nexb.com


More information about the Distutils-SIG mailing list