本文整理匯總了Python中pkg_resources.evaluate_marker方法的典型用法代碼示例。如果您正苦於以下問題:Python pkg_resources.evaluate_marker方法的具體用法?Python pkg_resources.evaluate_marker怎麽用?Python pkg_resources.evaluate_marker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pkg_resources
的用法示例。
在下文中一共展示了pkg_resources.evaluate_marker方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_ordering
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def test_ordering(python_version_mock):
assert evaluate_marker("python_full_version > '2.7.3'") is True
示例2: marker_passes
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def marker_passes(marker):
"""
Given an environment marker, return True if the marker is valid
and matches this environment.
"""
return (
not marker
or not pkg_resources.invalid_marker(marker)
and pkg_resources.evaluate_marker(marker)
)
示例3: marker_passes
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def marker_passes(marker):
"""
Given an environment marker, return True if the marker is valid
and matches this environment.
"""
return (
not marker
or not pkg_resources.invalid_marker(marker)
and pkg_resources.evaluate_marker(marker)
)
示例4: dependencies
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def dependencies(self, extra=None):
"""Access the dependencies of this Wheel.
Args:
extra: if specified, include the additional dependencies
of the named "extra".
Yields:
the names of requirements from the metadata.json, in lexical order.
"""
# TODO(mattmoor): Is there a schema to follow for this?
dependency_set = set()
run_requires = self.metadata().get('run_requires', [])
for requirement in run_requires:
if requirement.get('extra') != extra:
# Match the requirements for the extra we're looking for.
continue
marker = requirement.get('environment')
if marker and not pkg_resources.evaluate_marker(marker):
# The current environment does not match the provided PEP 508 marker,
# so ignore this requirement.
continue
requires = requirement.get('requires', [])
for entry in requires:
# Strip off any trailing versioning data.
parts = re.split('[ ><=()]', entry)
dependency_set.add(parts[0])
return sorted(dependency_set)
示例5: dependencies
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def dependencies(self, extra=None):
"""Access the dependencies of this Wheel.
Args:
extra: if specified, include the additional dependencies
of the named "extra".
Yields:
the names of requirements from the metadata.json
"""
# TODO(mattmoor): Is there a schema to follow for this?
run_requires = self.metadata().get('run_requires', [])
for requirement in run_requires:
if requirement.get('extra') != extra:
# Match the requirements for the extra we're looking for.
continue
marker = requirement.get('environment')
if marker and not pkg_resources.evaluate_marker(marker):
# The current environment does not match the provided PEP 508 marker,
# so ignore this requirement.
continue
requires = requirement.get('requires', [])
for entry in requires:
# Strip off any trailing versioning data.
parts = re.split('[ ><=()]', entry)
yield parts[0]
示例6: run
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def run(self):
from pkg_resources import evaluate_marker
requirements = self.distribution.install_requires + ['mock>=2.0.0', 'pytest-cov', 'pytest'] +\
[v for k, v in self.distribution.extras_require.items() if not k.startswith(':') or evaluate_marker(k[1:])]
self.distribution.fetch_build_eggs(requirements)
self.run_tests()
示例7: pytest_configure
# 需要導入模塊: import pkg_resources [as 別名]
# 或者: from pkg_resources import evaluate_marker [as 別名]
def pytest_configure(config):
msgs = []
if not os.path.exists(_testdata):
msg = "testdata not available! "
if os.path.exists(os.path.join(_root, ".git")):
msg += ("Please run git submodule update --init --recursive " +
"and then run tests again.")
else:
msg += ("The testdata doesn't appear to be included with this package, " +
"so finding the right version will be hard. :(")
msgs.append(msg)
if config.option.update_xfail:
# Check for optional requirements
req_file = os.path.join(_root, "requirements-optional.txt")
if os.path.exists(req_file):
with open(req_file, "r") as fp:
for line in fp:
if (line.strip() and
not (line.startswith("-r") or
line.startswith("#"))):
if ";" in line:
spec, marker = line.strip().split(";", 1)
else:
spec, marker = line.strip(), None
req = pkg_resources.Requirement.parse(spec)
if marker and not pkg_resources.evaluate_marker(marker):
msgs.append("%s not available in this environment" % spec)
else:
try:
installed = pkg_resources.working_set.find(req)
except pkg_resources.VersionConflict:
msgs.append("Outdated version of %s installed, need %s" % (req.name, spec))
else:
if not installed:
msgs.append("Need %s" % spec)
# Check cElementTree
import xml.etree.ElementTree as ElementTree
try:
import xml.etree.cElementTree as cElementTree
except ImportError:
msgs.append("cElementTree unable to be imported")
else:
if cElementTree.Element is ElementTree.Element:
msgs.append("cElementTree is just an alias for ElementTree")
if msgs:
pytest.exit("\n".join(msgs))