[Distutils] 'markerlib' (environment markers) is ready

Daniel Holth dholth at gmail.com
Wed Jul 25 15:33:48 CEST 2012


I'm happy with markerlib, my implementation of environment markers. In
markerlib, a marker is a function

def marker(environment=None, override=None)

where environment is the environment and override updates the
environment; if environment is None then it's the default environment.
So marker(override={'python_version':'2.6'}) evaluates the marker with
the python version changed to 2.6. The API is two functions compile()
(recommended) and interpret() (compatible with packaging API).

The implementation takes advantage of the fact that variables can
contain "." at the interpreter level, and then implements markers as
Python with only (Compare, BoolOp, Attribute, Name, Load, Str, cmpop,
boolop) AST nodes allowed.

On CPython 2.7 it is a little bit slower than the distutils2
implementation for a single compilation+evaluation of a statement like
"a == 'a' or b == 'b'" but is much faster for repeated evaluation. It
works for Python >= 2.5. It has 100% code coverage.

Would you be interested in folding this into packaging, or distribute
(yes, the setuptools fork) since markers are needed to properly
support .dist-info, perhaps as a different top-level name 'markers' or
'envmarkers'?


More information about the Distutils-SIG mailing list