'markerlib' (environment markers) is ready

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'?

On 7/25/12 3:33 PM, Daniel Holth wrote:
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'? _______________________________________________
cool ! +1
Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
participants (2)
-
Daniel Holth
-
Tarek Ziadé