From 4dbcd9042b975d4fe02e812f527ac282543a8ae7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 28 Jul 2015 20:44:06 -0400 Subject: Add support for un-named, environment-specific extras. --- CHANGES.txt | 5 +++++ ptr.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index da280f8..49fbee0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +2.6 +~~~ + +* Add support for un-named, environment-specific extras. + 2.5.1 ~~~~~ diff --git a/ptr.py b/ptr.py index 980b654..aa65e03 100644 --- a/ptr.py +++ b/ptr.py @@ -7,8 +7,10 @@ import shlex as _shlex import contextlib as _contextlib import sys as _sys +import pkg_resources import setuptools.command.test as orig + @_contextlib.contextmanager def _save_argv(repl=None): saved = _sys.argv[:] @@ -41,6 +43,18 @@ class PyTest(orig.test): if self.addopts: self.addopts = _shlex.split(self.addopts) + @staticmethod + def marker_passes(marker): + """ + Given an environment marker, return True if the marker is valid + and matches this environment. + """ + return ( + marker + and not pkg_resources.invalid_marker(marker) + and pkg_resources.evaluate_marker(marker) + ) + def run(self): """ Override run to ensure requirements are available in this session (but @@ -49,6 +63,11 @@ class PyTest(orig.test): self._build_egg_fetcher() if self.distribution.install_requires: self.distribution.fetch_build_eggs(self.distribution.install_requires) + # include environment-specific unnamed environment markers + for spec, reqs in self.distribution.extras_require.items(): + name, sep, marker = spec.partition(':') + if not name and self.marker_passes(marker): + self.distribution.fetch_build_eggs(reqs) if self.distribution.tests_require: self.distribution.fetch_build_eggs(self.distribution.tests_require) if self.distribution.extras_require and self.extras: -- cgit v1.2.1