1010import stat
1111from setuptools .extern .more_itertools import unique_everseen
1212
13- try :
14- from setuptools .lib2to3_ex import Mixin2to3
15- except Exception :
16-
17- class Mixin2to3 :
18- def run_2to3 (self , files , doctests = True ):
19- "do nothing"
20-
2113
2214def make_writable (target ):
2315 os .chmod (target , os .stat (target ).st_mode | stat .S_IWRITE )
2416
2517
26- class build_py (orig .build_py , Mixin2to3 ):
18+ class build_py (orig .build_py ):
2719 """Enhanced 'build_py' command that includes data files with packages
2820
2921 The data files are specified via a 'package_data' argument to 'setup()'.
@@ -36,12 +28,10 @@ class build_py(orig.build_py, Mixin2to3):
3628 def finalize_options (self ):
3729 orig .build_py .finalize_options (self )
3830 self .package_data = self .distribution .package_data
39- self .exclude_package_data = (self .distribution .exclude_package_data or
40- {})
31+ self .exclude_package_data = self .distribution .exclude_package_data or {}
4132 if 'data_files' in self .__dict__ :
4233 del self .__dict__ ['data_files' ]
4334 self .__updated_files = []
44- self .__doctests_2to3 = []
4535
4636 def run (self ):
4737 """Build modules, packages, and copy data files to build directory"""
@@ -55,10 +45,6 @@ def run(self):
5545 self .build_packages ()
5646 self .build_package_data ()
5747
58- self .run_2to3 (self .__updated_files , False )
59- self .run_2to3 (self .__updated_files , True )
60- self .run_2to3 (self .__doctests_2to3 , True )
61-
6248 # Only compile actual .py files, using our base class' idea of what our
6349 # output files are.
6450 self .byte_compile (orig .build_py .get_outputs (self , include_bytecode = 0 ))
@@ -71,8 +57,7 @@ def __getattr__(self, attr):
7157 return orig .build_py .__getattr__ (self , attr )
7258
7359 def build_module (self , module , module_file , package ):
74- outfile , copied = orig .build_py .build_module (self , module , module_file ,
75- package )
60+ outfile , copied = orig .build_py .build_module (self , module , module_file , package )
7661 if copied :
7762 self .__updated_files .append (outfile )
7863 return outfile , copied
@@ -123,9 +108,6 @@ def build_package_data(self):
123108 outf , copied = self .copy_file (srcfile , target )
124109 make_writable (target )
125110 srcfile = os .path .abspath (srcfile )
126- if (copied and
127- srcfile in self .distribution .convert_2to3_doctests ):
128- self .__doctests_2to3 .append (outf )
129111
130112 def analyze_manifest (self ):
131113 self .manifest_files = mf = {}
@@ -202,18 +184,11 @@ def exclude_data_files(self, package, src_dir, files):
202184 package ,
203185 src_dir ,
204186 )
205- match_groups = (
206- fnmatch .filter (files , pattern )
207- for pattern in patterns
208- )
187+ match_groups = (fnmatch .filter (files , pattern ) for pattern in patterns )
209188 # flatten the groups of matches into an iterable of matches
210189 matches = itertools .chain .from_iterable (match_groups )
211190 bad = set (matches )
212- keepers = (
213- fn
214- for fn in files
215- if fn not in bad
216- )
191+ keepers = (fn for fn in files if fn not in bad )
217192 # ditch dupes
218193 return list (unique_everseen (keepers ))
219194
@@ -241,12 +216,17 @@ def assert_relative(path):
241216 return path
242217 from distutils .errors import DistutilsSetupError
243218
244- msg = textwrap .dedent ("""
219+ msg = (
220+ textwrap .dedent (
221+ """
245222 Error: setup script specifies an absolute path:
246223
247224 %s
248225
249226 setup() arguments must *always* be /-separated paths relative to the
250227 setup.py directory, *never* absolute paths.
251- """ ).lstrip () % path
228+ """
229+ ).lstrip ()
230+ % path
231+ )
252232 raise DistutilsSetupError (msg )
0 commit comments