summaryrefslogtreecommitdiff
path: root/setuptools/command/build_py.py
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2021-07-18 09:27:21 +0100
committerJason R. Coombs <jaraco@jaraco.com>2021-09-04 12:14:35 -0400
commitca296ca8663a376f3c36c9f8fd86b10ba81366c2 (patch)
tree651ddc60721245c136be867432039509bc06e4c1 /setuptools/command/build_py.py
parentd989cdb36f50785d23b07939ba8b4fc2b68cf02a (diff)
downloadpython-setuptools-git-ca296ca8663a376f3c36c9f8fd86b10ba81366c2.tar.gz
remove lib2to3 usage
Diffstat (limited to 'setuptools/command/build_py.py')
-rw-r--r--setuptools/command/build_py.py44
1 files changed, 12 insertions, 32 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index df6fd323..6a615433 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -10,20 +10,12 @@ import itertools
import stat
from setuptools.extern.more_itertools import unique_everseen
-try:
- from setuptools.lib2to3_ex import Mixin2to3
-except Exception:
-
- class Mixin2to3:
- def run_2to3(self, files, doctests=True):
- "do nothing"
-
def make_writable(target):
os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE)
-class build_py(orig.build_py, Mixin2to3):
+class build_py(orig.build_py):
"""Enhanced 'build_py' command that includes data files with packages
The data files are specified via a 'package_data' argument to 'setup()'.
@@ -36,12 +28,10 @@ class build_py(orig.build_py, Mixin2to3):
def finalize_options(self):
orig.build_py.finalize_options(self)
self.package_data = self.distribution.package_data
- self.exclude_package_data = (self.distribution.exclude_package_data or
- {})
+ self.exclude_package_data = self.distribution.exclude_package_data or {}
if 'data_files' in self.__dict__:
del self.__dict__['data_files']
self.__updated_files = []
- self.__doctests_2to3 = []
def run(self):
"""Build modules, packages, and copy data files to build directory"""
@@ -55,10 +45,6 @@ class build_py(orig.build_py, Mixin2to3):
self.build_packages()
self.build_package_data()
- self.run_2to3(self.__updated_files, False)
- self.run_2to3(self.__updated_files, True)
- self.run_2to3(self.__doctests_2to3, True)
-
# Only compile actual .py files, using our base class' idea of what our
# output files are.
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0))
@@ -71,8 +57,7 @@ class build_py(orig.build_py, Mixin2to3):
return orig.build_py.__getattr__(self, attr)
def build_module(self, module, module_file, package):
- outfile, copied = orig.build_py.build_module(self, module, module_file,
- package)
+ outfile, copied = orig.build_py.build_module(self, module, module_file, package)
if copied:
self.__updated_files.append(outfile)
return outfile, copied
@@ -123,9 +108,6 @@ class build_py(orig.build_py, Mixin2to3):
outf, copied = self.copy_file(srcfile, target)
make_writable(target)
srcfile = os.path.abspath(srcfile)
- if (copied and
- srcfile in self.distribution.convert_2to3_doctests):
- self.__doctests_2to3.append(outf)
def analyze_manifest(self):
self.manifest_files = mf = {}
@@ -202,18 +184,11 @@ class build_py(orig.build_py, Mixin2to3):
package,
src_dir,
)
- match_groups = (
- fnmatch.filter(files, pattern)
- for pattern in patterns
- )
+ match_groups = (fnmatch.filter(files, pattern) for pattern in patterns)
# flatten the groups of matches into an iterable of matches
matches = itertools.chain.from_iterable(match_groups)
bad = set(matches)
- keepers = (
- fn
- for fn in files
- if fn not in bad
- )
+ keepers = (fn for fn in files if fn not in bad)
# ditch dupes
return list(unique_everseen(keepers))
@@ -241,12 +216,17 @@ def assert_relative(path):
return path
from distutils.errors import DistutilsSetupError
- msg = textwrap.dedent("""
+ msg = (
+ textwrap.dedent(
+ """
Error: setup script specifies an absolute path:
%s
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
- """).lstrip() % path
+ """
+ ).lstrip()
+ % path
+ )
raise DistutilsSetupError(msg)