From d5494571842c63e4b1903d8f455727e408464ff5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:25:03 -0400 Subject: Extract namespace handling into a separate module and mix-in class. --- setuptools/namespaces.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 setuptools/namespaces.py (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py new file mode 100755 index 00000000..13829521 --- /dev/null +++ b/setuptools/namespaces.py @@ -0,0 +1,63 @@ +import os +from distutils import log + +from setuptools.extern.six.moves import map + + +class Installer: + + def install_namespaces(self): + nsp = self._get_all_ns_packages() + if not nsp: + return + filename, ext = os.path.splitext(self.target) + filename += '-nspkg.pth' + self.outputs.append(filename) + log.info("Installing %s", filename) + lines = map(self._gen_nspkg_line, nsp) + + if self.dry_run: + # always generate the lines, even in dry run + list(lines) + return + + with open(filename, 'wt') as f: + f.writelines(lines) + + _nspkg_tmpl = ( + "import sys, types, os", + "pep420 = sys.version_info > (3, 3)", + "p = os.path.join(sys._getframe(1).f_locals['sitedir'], *%(pth)r)", + "ie = os.path.exists(os.path.join(p,'__init__.py'))", + "m = not ie and not pep420 and " + "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", + "mp = (m or []) and m.__dict__.setdefault('__path__',[])", + "(p not in mp) and mp.append(p)", + ) + "lines for the namespace installer" + + _nspkg_tmpl_multi = ( + 'm and setattr(sys.modules[%(parent)r], %(child)r, m)', + ) + "additional line(s) when a parent package is indicated" + + @classmethod + def _gen_nspkg_line(cls, pkg): + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) + pth = tuple(pkg.split('.')) + tmpl_lines = cls._nspkg_tmpl + parent, sep, child = pkg.rpartition('.') + if parent: + tmpl_lines += cls._nspkg_tmpl_multi + return ';'.join(tmpl_lines) % locals() + '\n' + + def _get_all_ns_packages(self): + """Return sorted list of all package namespaces""" + nsp = set() + for pkg in self.distribution.namespace_packages or []: + pkg = pkg.split('.') + while pkg: + nsp.add('.'.join(pkg)) + pkg.pop() + return sorted(nsp) -- cgit v1.2.1 From c50d4e37edb96b7e4d63101139591a007e5e7241 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:29:16 -0400 Subject: Extract variable --- setuptools/namespaces.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 13829521..4248d1fc 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -55,7 +55,8 @@ class Installer: def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" nsp = set() - for pkg in self.distribution.namespace_packages or []: + pkgs = self.distribution.namespace_packages or [] + for pkg in pkgs: pkg = pkg.split('.') while pkg: nsp.add('.'.join(pkg)) -- cgit v1.2.1 From 11a55e9c6849f9215ddc714d2ae41d47c34d4f46 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:36:11 -0400 Subject: Extract _pkg_names function and add test. --- setuptools/namespaces.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 4248d1fc..6a766eda 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -1,9 +1,13 @@ import os from distutils import log +import itertools from setuptools.extern.six.moves import map +flatten = itertools.chain.from_iterable + + class Installer: def install_namespaces(self): @@ -54,11 +58,20 @@ class Installer: def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" - nsp = set() pkgs = self.distribution.namespace_packages or [] - for pkg in pkgs: - pkg = pkg.split('.') - while pkg: - nsp.add('.'.join(pkg)) - pkg.pop() - return sorted(nsp) + return sorted(flatten(map(self._pkg_names, pkgs))) + + @staticmethod + def _pkg_names(pkg): + """ + Given a namespace package, yield the components of that + package. + + >>> names = Installer._pkg_names('a.b.c') + >>> set(names) == set(['a', 'a.b', 'a.b.c']) + True + """ + parts = pkg.split('.') + while parts: + yield '.'.join(parts) + parts.pop() -- cgit v1.2.1 From 3617c2b2626d6d02df40436e788becb088e6b0e8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:42:00 -0400 Subject: Allow the extension to be overridden. --- setuptools/namespaces.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 6a766eda..40938d60 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -10,12 +10,14 @@ flatten = itertools.chain.from_iterable class Installer: + nspkg_ext = '-nspkg.pth' + def install_namespaces(self): nsp = self._get_all_ns_packages() if not nsp: return filename, ext = os.path.splitext(self.target) - filename += '-nspkg.pth' + filename += self.nspkg_ext self.outputs.append(filename) log.info("Installing %s", filename) lines = map(self._gen_nspkg_line, nsp) -- cgit v1.2.1 From 3d71f8b9ce3f8d48a9f63a095a54088828d39950 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:49:13 -0400 Subject: Allow the root to be overridden --- setuptools/namespaces.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 40938d60..9389dc69 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -33,7 +33,7 @@ class Installer: _nspkg_tmpl = ( "import sys, types, os", "pep420 = sys.version_info > (3, 3)", - "p = os.path.join(sys._getframe(1).f_locals['sitedir'], *%(pth)r)", + "p = os.path.join(%(root)s, *%(pth)r)", "ie = os.path.exists(os.path.join(p,'__init__.py'))", "m = not ie and not pep420 and " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", @@ -47,15 +47,18 @@ class Installer: ) "additional line(s) when a parent package is indicated" - @classmethod - def _gen_nspkg_line(cls, pkg): + def _get_root(self): + return "sys._getframe(1).f_locals['sitedir']" + + def _gen_nspkg_line(self, pkg): # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) pth = tuple(pkg.split('.')) - tmpl_lines = cls._nspkg_tmpl + root = self._get_root() + tmpl_lines = self._nspkg_tmpl parent, sep, child = pkg.rpartition('.') if parent: - tmpl_lines += cls._nspkg_tmpl_multi + tmpl_lines += self._nspkg_tmpl_multi return ';'.join(tmpl_lines) % locals() + '\n' def _get_all_ns_packages(self): -- cgit v1.2.1 From 5951f62664b85b4bd751e955c16ea06ff6931701 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:49:49 -0400 Subject: Also allow the target to be overridden. --- setuptools/namespaces.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 9389dc69..8451a06c 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -16,7 +16,7 @@ class Installer: nsp = self._get_all_ns_packages() if not nsp: return - filename, ext = os.path.splitext(self.target) + filename, ext = os.path.splitext(self._get_target()) filename += self.nspkg_ext self.outputs.append(filename) log.info("Installing %s", filename) @@ -30,6 +30,9 @@ class Installer: with open(filename, 'wt') as f: f.writelines(lines) + def _get_target(self): + return self.target + _nspkg_tmpl = ( "import sys, types, os", "pep420 = sys.version_info > (3, 3)", -- cgit v1.2.1 From 12eba181398860ae741eda4affadcd4d75f11ae3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:53:45 -0400 Subject: Create DevelopInstaller, inspired by the code in #789. --- setuptools/namespaces.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 8451a06c..cc934b7e 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -83,3 +83,11 @@ class Installer: while parts: yield '.'.join(parts) parts.pop() + + +class DevelopInstaller(Installer): + def _get_root(self): + return repr(str(self.egg_path)) + + def _get_target(self): + return self.egg_link -- cgit v1.2.1 From 355603259aa37e424cf7466c3de6518375a935e3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Nov 2016 16:41:23 -0500 Subject: Add uninstall support for namespace packages --- setuptools/namespaces.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index cc934b7e..a6371c99 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -30,6 +30,14 @@ class Installer: with open(filename, 'wt') as f: f.writelines(lines) + def uninstall_namespaces(self): + filename, ext = os.path.splitext(self._get_target()) + filename += self.nspkg_ext + if not os.path.exists(filename): + return + log.info("Removing %s", filename) + os.remove(filename) + def _get_target(self): return self.target -- cgit v1.2.1 From 712a6d85e47979ac50a1fb32d2cc76dc61acade8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 7 Nov 2016 04:18:56 -0500 Subject: In -nspkg.pth, always add the path to the namespace package, even if a __init__ exists, allowing for better cooperation between PEP 420 packages and older, __init__ namespace packages. --- setuptools/namespaces.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index a6371c99..93d358a2 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -45,8 +45,7 @@ class Installer: "import sys, types, os", "pep420 = sys.version_info > (3, 3)", "p = os.path.join(%(root)s, *%(pth)r)", - "ie = os.path.exists(os.path.join(p,'__init__.py'))", - "m = not ie and not pep420 and " + "m = not pep420 and " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", -- cgit v1.2.1 From 2268fb9887cfea2e28e156bd2c8314132261402f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 13 Nov 2016 09:21:40 -0500 Subject: Provisionally revert the -nspkg.pth suppression on PEP 420 Pythons. Ref #250. --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 93d358a2..9c1f0243 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -45,7 +45,7 @@ class Installer: "import sys, types, os", "pep420 = sys.version_info > (3, 3)", "p = os.path.join(%(root)s, *%(pth)r)", - "m = not pep420 and " + "m = " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", -- cgit v1.2.1 From 7e25fd910d1ff5259c0768d3b54a9bf03bce4279 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 7 Dec 2016 20:51:36 -0500 Subject: Consider using module_from_spec to create the module. --- setuptools/namespaces.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index cc934b7e..b6720609 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -34,12 +34,15 @@ class Installer: return self.target _nspkg_tmpl = ( - "import sys, types, os", + "import sys, types, os, importlib.util, importlib.machinery", "pep420 = sys.version_info > (3, 3)", "p = os.path.join(%(root)s, *%(pth)r)", "ie = os.path.exists(os.path.join(p,'__init__.py'))", "m = not ie and not pep420 and " - "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", + "sys.modules.setdefault(%(pkg)r, " + "importlib.util.module_from_spec(" + "importlib.machinery.PathFinder.find_spec(%(pkg)r, " + "[os.path.dirname(p)])))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", ) -- cgit v1.2.1 From 41a9da1833b1f55b4a3da0d427e9b569075f0cc7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 7 Dec 2016 20:57:11 -0500 Subject: module_from_spec is only available on Python 3.5 --- setuptools/namespaces.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index b6720609..9266860f 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -1,4 +1,5 @@ import os +import sys from distutils import log import itertools @@ -42,7 +43,10 @@ class Installer: "sys.modules.setdefault(%(pkg)r, " "importlib.util.module_from_spec(" "importlib.machinery.PathFinder.find_spec(%(pkg)r, " - "[os.path.dirname(p)])))", + "[os.path.dirname(p)])))" + if sys.version_info >= (3, 5) else + "m = not ie and not pep420 and " + "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", ) -- cgit v1.2.1 From 17f72f5bc7031accc037b377ced5a0b411520bfb Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 7 Dec 2016 21:24:21 -0500 Subject: Always check at run time as some builds share files across Python versions. --- setuptools/namespaces.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 9266860f..2399dae5 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -37,15 +37,15 @@ class Installer: _nspkg_tmpl = ( "import sys, types, os, importlib.util, importlib.machinery", "pep420 = sys.version_info > (3, 3)", + "has_mfs = sys.version_info > (3, 5)", "p = os.path.join(%(root)s, *%(pth)r)", "ie = os.path.exists(os.path.join(p,'__init__.py'))", - "m = not ie and not pep420 and " + "m = not ie and not pep420 and has_mfs and " "sys.modules.setdefault(%(pkg)r, " "importlib.util.module_from_spec(" "importlib.machinery.PathFinder.find_spec(%(pkg)r, " - "[os.path.dirname(p)])))" - if sys.version_info >= (3, 5) else - "m = not ie and not pep420 and " + "[os.path.dirname(p)])))", + "m = not ie and not pep420 and not has_mfs and " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", -- cgit v1.2.1 From 27b7d4e47a4d80f5f377cefb87f91aa0e0110246 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 7 Dec 2016 21:38:16 -0500 Subject: Only rely on pep420 for Python 3.3 and 3.4 where method_from_spec isn't available. --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 2399dae5..ce16286f 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -36,7 +36,7 @@ class Installer: _nspkg_tmpl = ( "import sys, types, os, importlib.util, importlib.machinery", - "pep420 = sys.version_info > (3, 3)", + "pep420 = (3, 3) < sys.version_info < (3, 5)", "has_mfs = sys.version_info > (3, 5)", "p = os.path.join(%(root)s, *%(pth)r)", "ie = os.path.exists(os.path.join(p,'__init__.py'))", -- cgit v1.2.1 From 6070cc15ed234a71777747c4cdd55f228f3d7b90 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 11 Dec 2016 15:58:49 -0500 Subject: Don't nullify module when has_mfs --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 96aa20e7..69debe4b 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -51,7 +51,7 @@ class Installer: "importlib.util.module_from_spec(" "importlib.machinery.PathFinder.find_spec(%(pkg)r, " "[os.path.dirname(p)])))", - "m = not has_mfs and " + "m = m or not has_mfs and " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", -- cgit v1.2.1 From 8fa9a8640eb85e7250b8e3ca15124e74ce6014e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 11 Dec 2016 16:02:14 -0500 Subject: Only import modules when they're expected to be present --- setuptools/namespaces.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 69debe4b..0a889f22 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -43,9 +43,11 @@ class Installer: return self.target _nspkg_tmpl = ( - "import sys, types, os, importlib.util, importlib.machinery", + "import sys, types, os", "has_mfs = sys.version_info > (3, 5)", "p = os.path.join(%(root)s, *%(pth)r)", + "importlib = has_mfs and __import__('importlib.util')", + "has_mfs and __import__('importlib.machinery')", "m = has_mfs and " "sys.modules.setdefault(%(pkg)r, " "importlib.util.module_from_spec(" -- cgit v1.2.1 From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 0a889f22..ba907439 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -3,7 +3,7 @@ import sys from distutils import log import itertools -from setuptools.extern.six.moves import map +from six.moves import map flatten = itertools.chain.from_iterable -- cgit v1.2.1 From b9ca305f48b5da7cfe0f831fdc32dc0aa3890035 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 16 Jan 2017 14:37:02 -0500 Subject: Remove unused imports --- setuptools/namespaces.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 0a889f22..bd17d9e7 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -1,5 +1,4 @@ import os -import sys from distutils import log import itertools -- cgit v1.2.1 From 9406d8fe002605af0f76f2de6c1e2fa1f44522fa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 21 Feb 2017 09:53:05 -0500 Subject: Remove redundant test from -nspkg.pth. If m is non-true, then has_mfs must have been False. --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 556b5dd2..7c24a566 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -52,7 +52,7 @@ class Installer: "importlib.util.module_from_spec(" "importlib.machinery.PathFinder.find_spec(%(pkg)r, " "[os.path.dirname(p)])))", - "m = m or not has_mfs and " + "m = m or " "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", -- cgit v1.2.1 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- setuptools/namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 7c24a566..dc16106d 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -2,7 +2,7 @@ import os from distutils import log import itertools -from six.moves import map +from setuptools.extern.six.moves import map flatten = itertools.chain.from_iterable -- cgit v1.2.1 From 760e2e1df9c9c9d1fc072e7b6ad9df4c32bfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 27 Jul 2018 14:36:34 +0200 Subject: Remove spurious executable permissions --- setuptools/namespaces.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/namespaces.py (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py old mode 100755 new mode 100644 -- cgit v1.2.1 From 3d4d8b9dde61b87271861b8c7ebeb168ac4fa72b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Jan 2020 12:46:30 -0500 Subject: =?UTF-8?q?=F0=9F=91=B9=20Feed=20the=20hobgoblins=20(delint).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setuptools/namespaces.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index dc16106d..5f403c96 100644 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -47,13 +47,17 @@ class Installer: "p = os.path.join(%(root)s, *%(pth)r)", "importlib = has_mfs and __import__('importlib.util')", "has_mfs and __import__('importlib.machinery')", - "m = has_mfs and " + ( + "m = has_mfs and " "sys.modules.setdefault(%(pkg)r, " - "importlib.util.module_from_spec(" - "importlib.machinery.PathFinder.find_spec(%(pkg)r, " - "[os.path.dirname(p)])))", - "m = m or " - "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", + "importlib.util.module_from_spec(" + "importlib.machinery.PathFinder.find_spec(%(pkg)r, " + "[os.path.dirname(p)])))" + ), + ( + "m = m or " + "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))" + ), "mp = (m or []) and m.__dict__.setdefault('__path__',[])", "(p not in mp) and mp.append(p)", ) -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- setuptools/namespaces.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'setuptools/namespaces.py') diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 5f403c96..44939e1c 100644 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -2,8 +2,6 @@ import os from distutils import log import itertools -from setuptools.extern.six.moves import map - flatten = itertools.chain.from_iterable @@ -72,8 +70,6 @@ class Installer: return "sys._getframe(1).f_locals['sitedir']" def _gen_nspkg_line(self, pkg): - # ensure pkg is not a unicode string under Python 2.7 - pkg = str(pkg) pth = tuple(pkg.split('.')) root = self._get_root() tmpl_lines = self._nspkg_tmpl -- cgit v1.2.1