Show More
@@ -68,6 +68,18 b' from distutils.errors import CCompilerEr' | |||||
68 | from distutils.sysconfig import get_python_inc |
|
68 | from distutils.sysconfig import get_python_inc | |
69 | from distutils.version import StrictVersion |
|
69 | from distutils.version import StrictVersion | |
70 |
|
70 | |||
|
71 | convert2to3 = '--c2to3' in sys.argv | |||
|
72 | if convert2to3: | |||
|
73 | try: | |||
|
74 | from distutils.command.build_py import build_py_2to3 as build_py | |||
|
75 | from lib2to3.refactor import get_fixers_from_package as getfixers | |||
|
76 | except ImportError: | |||
|
77 | if sys.version_info[0] < 3: | |||
|
78 | raise SystemExit("--c2to3 is only compatible with python3.") | |||
|
79 | raise | |||
|
80 | sys.path.append('contrib') | |||
|
81 | ||||
|
82 | ||||
71 | scripts = ['hg'] |
|
83 | scripts = ['hg'] | |
72 | if os.name == 'nt': |
|
84 | if os.name == 'nt': | |
73 | scripts.append('contrib/win32/hg.bat') |
|
85 | scripts.append('contrib/win32/hg.bat') | |
@@ -190,6 +202,11 b' class hgbuild(build):' | |||||
190 | # Insert hgbuildmo first so that files in mercurial/locale/ are found |
|
202 | # Insert hgbuildmo first so that files in mercurial/locale/ are found | |
191 | # when build_py is run next. |
|
203 | # when build_py is run next. | |
192 | sub_commands = [('build_mo', None), |
|
204 | sub_commands = [('build_mo', None), | |
|
205 | # We also need build_ext before build_py. Otherwise, when 2to3 is called (in | |||
|
206 | # build_py), it will not find osutil & friends, thinking that those modules are | |||
|
207 | # global and, consequently, making a mess, now that all module imports are | |||
|
208 | # global. | |||
|
209 | ('build_ext', build.has_ext_modules), | |||
193 | ] + build.sub_commands |
|
210 | ] + build.sub_commands | |
194 |
|
211 | |||
195 | class hgbuildmo(Command): |
|
212 | class hgbuildmo(Command): | |
@@ -235,6 +252,8 b' class hgdist(Distribution):' | |||||
235 | global_options = Distribution.global_options + \ |
|
252 | global_options = Distribution.global_options + \ | |
236 | [('pure', None, "use pure (slow) Python " |
|
253 | [('pure', None, "use pure (slow) Python " | |
237 | "code instead of C extensions"), |
|
254 | "code instead of C extensions"), | |
|
255 | ('c2to3', None, "(experimental!) convert " | |||
|
256 | "code with 2to3"), | |||
238 | ] |
|
257 | ] | |
239 |
|
258 | |||
240 | def has_ext_modules(self): |
|
259 | def has_ext_modules(self): | |
@@ -254,6 +273,9 b' class hgbuildext(build_ext):' | |||||
254 | ext.name) |
|
273 | ext.name) | |
255 |
|
274 | |||
256 | class hgbuildpy(build_py): |
|
275 | class hgbuildpy(build_py): | |
|
276 | if convert2to3: | |||
|
277 | fixer_names = sorted(set(getfixers("lib2to3.fixes") + | |||
|
278 | getfixers("hgfixes"))) | |||
257 |
|
279 | |||
258 | def finalize_options(self): |
|
280 | def finalize_options(self): | |
259 | build_py.finalize_options(self) |
|
281 | build_py.finalize_options(self) | |
@@ -344,7 +366,7 b' class hginstallscripts(install_scripts):' | |||||
344 | fp.close() |
|
366 | fp.close() | |
345 |
|
367 | |||
346 | # skip binary files |
|
368 | # skip binary files | |
347 | if '\0' in data: |
|
369 | if b('\0') in data: | |
348 | continue |
|
370 | continue | |
349 |
|
371 | |||
350 | data = data.replace('@LIBDIR@', libdir.encode('string_escape')) |
|
372 | data = data.replace('@LIBDIR@', libdir.encode('string_escape')) |
General Comments 0
You need to be logged in to leave comments.
Login now