diff options
Diffstat (limited to 'setuptools/command/build_py.py')
-rw-r--r-- | setuptools/command/build_py.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index a01e2843..8751acd4 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -28,13 +28,8 @@ try: if not files: return log.info("Fixing "+" ".join(files)) - if not self.fixer_names: - self.fixer_names = [] - for p in setuptools.lib2to3_fixer_packages: - self.fixer_names.extend(get_fixers_from_package(p)) - if self.distribution.use_2to3_fixers is not None: - for p in self.distribution.use_2to3_fixers: - self.fixer_names.extend(get_fixers_from_package(p)) + self.__build_fixer_names() + self.__exclude_fixers() if doctests: if setuptools.run_2to3_on_doctests: r = DistutilsRefactoringTool(self.fixer_names) @@ -42,6 +37,23 @@ try: else: _Mixin2to3.run_2to3(self, files) + def __build_fixer_names(self): + if self.fixer_names: return + self.fixer_names = [] + for p in setuptools.lib2to3_fixer_packages: + self.fixer_names.extend(get_fixers_from_package(p)) + if self.distribution.use_2to3_fixers is not None: + for p in self.distribution.use_2to3_fixers: + self.fixer_names.extend(get_fixers_from_package(p)) + + def __exclude_fixers(self): + excluded_fixers = getattr(self, 'exclude_fixers', []) + if self.distribution.use_2to3_exclude_fixers is not None: + excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) + for fixer_name in excluded_fixers: + if fixer_name in self.fixer_names: + self.fixer_names.remove(fixer_name) + except ImportError: class Mixin2to3: def run_2to3(self, files, doctests=True): @@ -201,8 +213,8 @@ class build_py(_build_py, Mixin2to3): else: return init_py - f = open(init_py,'rU') - if 'declare_namespace' not in f.read(): + f = open(init_py,'rbU') + if 'declare_namespace'.encode() not in f.read(): from distutils import log log.warn( "WARNING: %s is a namespace package, but its __init__.py does\n" |