text
stringlengths
0
888
>>> from pkg_resources import compatible_platforms as cp
>>> reqd = 'macosx-10.4-ppc'
>>> cp(reqd, reqd)
True
>>> cp("win32", reqd)
False
Distributions made on other machine types are not compatible::
>>> cp("macosx-10.4-i386", reqd)
False
Distributions made on earlier versions of the OS are compatible, as
long as they are from the same top-level version. The patchlevel version
number does not matter::
>>> cp("macosx-10.4-ppc", reqd)
True
>>> cp("macosx-10.3-ppc", reqd)
True
>>> cp("macosx-10.5-ppc", reqd)
False
>>> cp("macosx-9.5-ppc", reqd)
False
Backwards compatibility for packages made via earlier versions of
setuptools is provided as well::
>>> cp("darwin-8.2.0-Power_Macintosh", reqd)
True
>>> cp("darwin-7.2.0-Power_Macintosh", reqd)
True
>>> cp("darwin-8.2.0-Power_Macintosh", "macosx-10.3-ppc")
False
Environment Markers
-------------------
>>> from pkg_resources import invalid_marker as im, evaluate_marker as em
>>> import os
>>> print(im("sys_platform"))
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
sys_platform
^
>>> print(im("sys_platform=="))
Expected a marker variable or quoted string
sys_platform==
^
>>> print(im("sys_platform=='win32'"))
False
>>> print(im("sys=='x'"))
Expected a marker variable or quoted string
sys=='x'
^
>>> print(im("(extra)"))
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
(extra)
^
>>> print(im("(extra"))
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
(extra
^
>>> print(im("os.open('foo')=='y'"))
Expected a marker variable or quoted string
os.open('foo')=='y'
^
>>> print(im("'x'=='y' and os.open('foo')=='y'")) # no short-circuit!
Expected a marker variable or quoted string
'x'=='y' and os.open('foo')=='y'
^
>>> print(im("'x'=='x' or os.open('foo')=='y'")) # no short-circuit!
Expected a marker variable or quoted string
'x'=='x' or os.open('foo')=='y'
^
>>> print(im("r'x'=='x'"))
Expected a marker variable or quoted string
r'x'=='x'
^
>>> print(im("'''x'''=='x'"))
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
'''x'''=='x'
^
>>> print(im('"""x"""=="x"'))
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
"""x"""=="x"
^