From 57b4b8456508a65861aaf46e8a17c2d7361daed7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 15:11:24 -0400 Subject: Adding setuptools.command.py36compat module with functionality copied from distutils.command.sdist in 6d5603e41569 --- setuptools/command/py36compat.py | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 setuptools/command/py36compat.py (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py new file mode 100644 index 00000000..d92b9d48 --- /dev/null +++ b/setuptools/command/py36compat.py @@ -0,0 +1,114 @@ +import os +from glob import glob +from distutils.util import convert_path +from distutils.command import sdist + + +class sdist_add_defaults: + """ + Mix-in providing forward-compatibility for functionality as found in + distutils on Python 3.7. + """ + + def add_defaults(self): + """Add all the default files to self.filelist: + - README or README.txt + - setup.py + - test/test*.py + - all pure Python modules mentioned in setup script + - all files pointed by package_data (build_py) + - all files defined in data_files. + - all files defined as scripts. + - all C sources listed as part of extensions or C libraries + in the setup script (doesn't catch C headers!) + Warns if (README or README.txt) or setup.py are missing; everything + else is optional. + """ + self._add_defaults_standards() + self._add_defaults_optional() + self._add_defaults_python() + self._add_defaults_data_files() + self._add_defaults_ext() + self._add_defaults_c_libs() + self._add_defaults_scripts() + + def _add_defaults_standards(self): + standards = [self.READMES, self.distribution.script_name] + for fn in standards: + if isinstance(fn, tuple): + alts = fn + got_it = False + for fn in alts: + if os.path.exists(fn): + got_it = True + self.filelist.append(fn) + break + + if not got_it: + self.warn("standard file not found: should have one of " + + ', '.join(alts)) + else: + if os.path.exists(fn): + self.filelist.append(fn) + else: + self.warn("standard file '%s' not found" % fn) + + def _add_defaults_optional(self): + optional = ['test/test*.py', 'setup.cfg'] + for pattern in optional: + files = filter(os.path.isfile, glob(pattern)) + self.filelist.extend(files) + + def _add_defaults_python(self): + # build_py is used to get: + # - python modules + # - files defined in package_data + build_py = self.get_finalized_command('build_py') + + # getting python files + if self.distribution.has_pure_modules(): + self.filelist.extend(build_py.get_source_files()) + + # getting package_data files + # (computed in build_py.data_files by build_py.finalize_options) + for pkg, src_dir, build_dir, filenames in build_py.data_files: + for filename in filenames: + self.filelist.append(os.path.join(src_dir, filename)) + + def _add_defaults_data_files(self): + # getting distribution.data_files + if self.distribution.has_data_files(): + for item in self.distribution.data_files: + if isinstance(item, str): + # plain file + item = convert_path(item) + if os.path.isfile(item): + self.filelist.append(item) + else: + # a (dirname, filenames) tuple + dirname, filenames = item + for f in filenames: + f = convert_path(f) + if os.path.isfile(f): + self.filelist.append(f) + + def _add_defaults_ext(self): + if self.distribution.has_ext_modules(): + build_ext = self.get_finalized_command('build_ext') + self.filelist.extend(build_ext.get_source_files()) + + def _add_defaults_c_libs(self): + if self.distribution.has_c_libraries(): + build_clib = self.get_finalized_command('build_clib') + self.filelist.extend(build_clib.get_source_files()) + + def _add_defaults_scripts(self): + if self.distribution.has_scripts(): + build_scripts = self.get_finalized_command('build_scripts') + self.filelist.extend(build_scripts.get_source_files()) + + +if hasattr(sdist.sdist, '_add_defaults_standards'): + # disable the functionality already available upstream + class sdist_add_defaults: + pass -- cgit v1.2.1 From 36bcc35f0cf0d99d20fe9610f4001c513d851cfd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 15:43:01 -0400 Subject: Update sdist_add_defaults to match CPython db8bb1bd6ac5 --- setuptools/command/py36compat.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index d92b9d48..883221da 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -3,6 +3,8 @@ from glob import glob from distutils.util import convert_path from distutils.command import sdist +from setuptools.extern.six.moves import filter + class sdist_add_defaults: """ @@ -32,6 +34,23 @@ class sdist_add_defaults: self._add_defaults_c_libs() self._add_defaults_scripts() + @staticmethod + def _cs_path_exists(fspath): + """ + Case-sensitive path existence check + + >>> sdist._cs_path_exists(__file__) + True + >>> sdist._cs_path_exists(__file__.upper()) + False + """ + if not os.path.exists(fspath): + return False + # make absolute so we always have a directory + abspath = os.path.abspath(fspath) + directory, filename = os.path.split(abspath) + return filename in os.listdir(directory) + def _add_defaults_standards(self): standards = [self.READMES, self.distribution.script_name] for fn in standards: @@ -39,7 +58,7 @@ class sdist_add_defaults: alts = fn got_it = False for fn in alts: - if os.path.exists(fn): + if self._cs_path_exists(fn): got_it = True self.filelist.append(fn) break @@ -48,7 +67,7 @@ class sdist_add_defaults: self.warn("standard file not found: should have one of " + ', '.join(alts)) else: - if os.path.exists(fn): + if self._cs_path_exists(fn): self.filelist.append(fn) else: self.warn("standard file '%s' not found" % fn) -- cgit v1.2.1 From e704747721609fcb25267041292c14493751b61c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 15:49:20 -0400 Subject: Update doctest to pass --- setuptools/command/py36compat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index 883221da..def5906a 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -39,9 +39,9 @@ class sdist_add_defaults: """ Case-sensitive path existence check - >>> sdist._cs_path_exists(__file__) + >>> sdist_add_defaults._cs_path_exists(__file__) True - >>> sdist._cs_path_exists(__file__.upper()) + >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False """ if not os.path.exists(fspath): -- cgit v1.2.1 From 6b175fcf513fa98f03b4c529cccfa3d256e91e19 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 15:52:50 -0400 Subject: Add note about editing the code --- setuptools/command/py36compat.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index def5906a..61063e75 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -10,6 +10,9 @@ class sdist_add_defaults: """ Mix-in providing forward-compatibility for functionality as found in distutils on Python 3.7. + + Do not edit the code in this class except to update functionality + as implemented in distutils. Instead, override in the subclass. """ def add_defaults(self): -- 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/command/py36compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index 61063e75..a2c74b2d 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -3,7 +3,7 @@ from glob import glob from distutils.util import convert_path from distutils.command import sdist -from setuptools.extern.six.moves import filter +from six.moves import filter class sdist_add_defaults: -- 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/command/py36compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index a2c74b2d..61063e75 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -3,7 +3,7 @@ from glob import glob from distutils.util import convert_path from distutils.command import sdist -from six.moves import filter +from setuptools.extern.six.moves import filter class sdist_add_defaults: -- 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/command/py36compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index 61063e75..28860558 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -132,5 +132,5 @@ class sdist_add_defaults: if hasattr(sdist.sdist, '_add_defaults_standards'): # disable the functionality already available upstream - class sdist_add_defaults: + class sdist_add_defaults: # noqa pass -- 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/command/py36compat.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/command/py36compat.py') diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index 28860558..343547a4 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -3,8 +3,6 @@ from glob import glob from distutils.util import convert_path from distutils.command import sdist -from setuptools.extern.six.moves import filter - class sdist_add_defaults: """ -- cgit v1.2.1