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

Jim Fulton jim at zope.com
Wed Jan 30 15:36:55 CET 2013

On Wed, Jan 30, 2013 at 9:00 AM, Philippe Ombredanne
<pombredanne at nexb.com> wrote:
> 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.....

I hadn't noticed that you were exposing the platform module already.
Sorry. I should have checked.

The PEP's treatment of the platform module is unfortunate.
I was going to mention this before, but I didn't think we were
exposing platform module and though "whatever".

> 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

I have no interest in supporting a Python expression subset.

I'd rather stick with what you did originally and just expose the
modules.  This is simpler and easier for people to remember.


Jim Fulton
Jerky is better than bacon! http://zo.pe/Kqm

More information about the Distutils-SIG mailing list