summaryrefslogtreecommitdiff
path: root/src/distutils2/command/build_py.py
diff options
context:
space:
mode:
authorZubin Mithra <zubin.mithra@gmail.com>2010-08-08 14:12:31 +0530
committerZubin Mithra <zubin.mithra@gmail.com>2010-08-08 14:12:31 +0530
commit88ff0ecac509c386fb2317a45d3deb6e70839df0 (patch)
tree672df525e3409398d88d82ff4c7ce947da525c9a /src/distutils2/command/build_py.py
parent760df097438dff3b81fc0d12a4cddcf723dbf6c4 (diff)
parent9b3c8821ec4f8332a28583fee0e121ba918cf784 (diff)
downloaddisutils2-88ff0ecac509c386fb2317a45d3deb6e70839df0.tar.gz
longopt_xlate removed. merged with tarek
Diffstat (limited to 'src/distutils2/command/build_py.py')
-rw-r--r--src/distutils2/command/build_py.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/distutils2/command/build_py.py b/src/distutils2/command/build_py.py
index 1a9d18b..d0fbd3c 100644
--- a/src/distutils2/command/build_py.py
+++ b/src/distutils2/command/build_py.py
@@ -20,6 +20,7 @@ __all__ = ['Mixin2to3', 'build_py']
try:
from distutils2.util import Mixin2to3 as _Mixin2to3
+ from distutils2 import run_2to3_on_doctests
from lib2to3.refactor import get_fixers_from_package
_CONVERT = True
_KLASS = _Mixin2to3
@@ -34,13 +35,16 @@ class Mixin2to3(_KLASS):
yet does nothing in particular with it.
"""
if _CONVERT:
- def _run_2to3(self, files, doctests=[]):
+ def _run_2to3(self, files, doctests=[], fixers=[]):
""" Takes a list of files and doctests, and performs conversion
on those.
- First, the files which contain the code(`files`) are converted.
- Second, the doctests in `files` are converted.
- Thirdly, the doctests in `doctests` are converted.
"""
+ # if additional fixers are present, use them
+ if fixers:
+ self.fixer_names = fixers
# Convert the ".py" files.
logging.info("Converting Python code")
@@ -57,12 +61,12 @@ class Mixin2to3(_KLASS):
# containing doctests. It is set as
# distutils2.run_2to3_on_doctests
- if doctests != [] and distutils2.run_2to3_on_doctests:
+ if doctests != [] and run_2to3_on_doctests:
logging.info("Converting text files which contain doctests")
_KLASS.run_2to3(self, doctests, doctests_only=True)
else:
# If run on Python 2.x, there is nothing to do.
- def _run_2to3(self, files, doctests=[]):
+ def _run_2to3(self, files, doctests=[], fixers=[]):
pass
class build_py(Command, Mixin2to3):
@@ -77,6 +81,12 @@ class build_py(Command, Mixin2to3):
"also compile with optimization: -O1 for \"python -O\", "
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
('force', 'f', "forcibly build everything (ignore file timestamps)"),
+ ('use-2to3', None,
+ "use 2to3 to make source python 3.x compatible"),
+ ('convert-2to3-doctests', None,
+ "use 2to3 to convert doctests in seperate text files"),
+ ('use-2to3-fixers', None,
+ "list additional fixers opted for during 2to3 conversion"),
]
boolean_options = ['compile', 'force']
@@ -93,7 +103,10 @@ class build_py(Command, Mixin2to3):
self.force = None
self._updated_files = []
self._doctests_2to3 = []
-
+ self.use_2to3 = False
+ self.convert_2to3_doctests = []
+ self.use_2to3_fixers = []
+
def finalize_options(self):
self.set_undefined_options('build', 'build_lib', 'force')
@@ -145,8 +158,9 @@ class build_py(Command, Mixin2to3):
self.build_packages()
self.build_package_data()
- if self.distribution.use_2to3 and self_updated_files:
- self.run_2to3(self._updated_files, self._doctests_2to3)
+ if self.use_2to3 and self._updated_files:
+ self.run_2to3(self._updated_files, self._doctests_2to3,
+ self.distribution.use_2to3_fixers)
self.byte_compile(self.get_outputs(include_bytecode=0))