Commit b8129358 authored by Jason R. Coombs's avatar Jason R. Coombs

Consolidate logic around a 'simple' requirement

parent f464c4b8
...@@ -16,7 +16,7 @@ from distutils.errors import ( ...@@ -16,7 +16,7 @@ from distutils.errors import (
from distutils.util import rfc822_escape from distutils.util import rfc822_escape
from setuptools.extern import six from setuptools.extern import six
from setuptools.extern.six.moves import map from setuptools.extern.six.moves import map, filter, filterfalse
from pkg_resources.extern import packaging from pkg_resources.extern import packaging
from setuptools.depends import Require from setuptools.depends import Require
...@@ -379,17 +379,21 @@ class Distribution(Distribution_parse_config_files, _Distribution): ...@@ -379,17 +379,21 @@ class Distribution(Distribution_parse_config_files, _Distribution):
Move requirements in `install_requires` that are using environment Move requirements in `install_requires` that are using environment
markers or extras to `extras_require`. markers or extras to `extras_require`.
""" """
def is_simple_req(req):
return not req.marker and not req.extras
spec_inst_reqs = getattr(self, 'install_requires', None) or () spec_inst_reqs = getattr(self, 'install_requires', None) or ()
self.install_requires = list( self.install_requires = list(
str(req) str(req)
for req in pkg_resources.parse_requirements(spec_inst_reqs) for req in filter(
if not req.marker and not req.extras is_simple_req,
pkg_resources.parse_requirements(spec_inst_reqs),
)
) )
markers_or_extras_reqs = ( markers_or_extras_reqs = filterfalse(
req is_simple_req,
for req in pkg_resources.parse_requirements(spec_inst_reqs) pkg_resources.parse_requirements(spec_inst_reqs),
if req.marker or req.extras
) )
for r in markers_or_extras_reqs: for r in markers_or_extras_reqs:
suffix = ':' + str(r.marker) if r.marker else '' suffix = ':' + str(r.marker) if r.marker else ''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment