##// END OF EJS Templates
contrib/setup3k.py: added script to build hg with py3k...
Renato Cunha -
r11948:88d49119 default
parent child Browse files
Show More
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
@@ -1,10 +1,13 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # This is the mercurial setup script.
3 # This is an experimental py3k-enabled mercurial setup script.
4 #
4 #
5 # 'python setup.py install', or
5 # 'python setup.py install', or
6 # 'python setup.py --help' for more options
6 # 'python setup.py --help' for more options
7
7
8 from distutils.command.build_py import build_py_2to3
9 from lib2to3.refactor import get_fixers_from_package as getfixers
10
8 import sys
11 import sys
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
12 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
10 raise SystemExit("Mercurial requires Python 2.4 or later.")
13 raise SystemExit("Mercurial requires Python 2.4 or later.")
@@ -218,6 +221,11 b' class hgbuildmo(build):'
218 # Insert hgbuildmo first so that files in mercurial/locale/ are found
221 # Insert hgbuildmo first so that files in mercurial/locale/ are found
219 # when build_py is run next.
222 # when build_py is run next.
220 build.sub_commands.insert(0, ('build_mo', None))
223 build.sub_commands.insert(0, ('build_mo', None))
224 # We also need build_ext before build_py. Otherwise, when 2to3 is called (in
225 # build_py), it will not find osutil & friends, thinking that those modules are
226 # global and, consequently, making a mess, now that all module imports are
227 # global.
228 build.sub_commands.insert(1, ('build_ext', None))
221
229
222 Distribution.pure = 0
230 Distribution.pure = 0
223 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
231 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
@@ -234,7 +242,9 b' class hgbuildext(build_ext):'
234 log.warn("Failed to build optional extension '%s' (skipping)",
242 log.warn("Failed to build optional extension '%s' (skipping)",
235 ext.name)
243 ext.name)
236
244
237 class hgbuildpy(build_py):
245 class hgbuildpy(build_py_2to3):
246 fixer_names = sorted(set(getfixers("lib2to3.fixes") +
247 getfixers("hgfixes")))
238
248
239 def finalize_options(self):
249 def finalize_options(self):
240 build_py.finalize_options(self)
250 build_py.finalize_options(self)
@@ -256,6 +266,27 b' class hgbuildpy(build_py):'
256 else:
266 else:
257 yield module
267 yield module
258
268
269 def run(self):
270 # In the build_py_2to3 class, self.updated_files = [], but I couldn't
271 # see when that variable was updated to point to the updated files, as
272 # its names suggests. Thus, I decided to just find_all_modules and feed
273 # them to 2to3. Unfortunately, subsequent calls to setup3k.py will
274 # incur in 2to3 analysis overhead.
275 self.updated_files = [i[2] for i in self.find_all_modules()]
276
277 # Base class code
278 if self.py_modules:
279 self.build_modules()
280 if self.packages:
281 self.build_packages()
282 self.build_package_data()
283
284 # 2to3
285 self.run_2to3(self.updated_files)
286
287 # Remaining base class code
288 self.byte_compile(self.get_outputs(include_bytecode=0))
289
259 cmdclass = {'build_mo': hgbuildmo,
290 cmdclass = {'build_mo': hgbuildmo,
260 'build_ext': hgbuildext,
291 'build_ext': hgbuildext,
261 'build_py': hgbuildpy}
292 'build_py': hgbuildpy}
General Comments 0
You need to be logged in to leave comments. Login now