Skip to content

Commit

Permalink
fix pypa#1419 PEP420: add find_namespace: directive
Browse files Browse the repository at this point in the history
  • Loading branch information
silkentrance authored and pganssle committed Aug 11, 2018
1 parent e0433cf commit e3005cb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions setuptools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from distutils.errors import DistutilsOptionError, DistutilsFileError
from setuptools.extern.packaging.version import LegacyVersion, parse
from setuptools.extern.six import string_types
from setuptools.extern.six import string_types, PY3


__metaclass__ = type
Expand Down Expand Up @@ -516,20 +516,30 @@ def _parse_packages(self, value):
:rtype: list
"""
find_directive = 'find:'
find_namespace_directive = 'find_namespace:'

findns = False
if not value.startswith(find_directive):
if value.startswith(find_namespace_directive):
if not PY3:
raise DistutilsOptionError('find_namespace directive is unsupported on Python < 3.3')
findns = True
else:
return self._parse_list(value)

# Read function arguments from a dedicated section.
find_kwargs = self.parse_section_packages__find(
self.sections.get('packages.find', {}))

from setuptools import find_packages
if findns:
from setuptools import find_packages_ns as find_packages
else:
from setuptools import find_packages

return find_packages(**find_kwargs)

def parse_section_packages__find(self, section_options):
"""Parses `packages.find` configuration file section.
"""Parses `packages.find[ns]` configuration file section.
To be used in conjunction with _parse_packages().
Expand Down

0 comments on commit e3005cb

Please sign in to comment.