Permalink
Browse files

Merge pull request #508 from erosennin/master

Add support for converting the sources with 2to3 to nosetests setuptools command
  • Loading branch information...
2 parents 3983ae3 + 12740ca commit 551ffe92ebd8f8d0c834779bb808e2e0db15b2a0 @jpellerin jpellerin committed Apr 9, 2012
Showing with 27 additions and 5 deletions.
  1. +5 −0 doc/index.rst
  2. +22 −5 nose/commands.py
View
@@ -60,6 +60,11 @@ nose supports python3. Building from source on python3 requires
have distribute installed, ``python3 setup.py install`` will install
it via distribute's bootstrap script.
+Additionally, if your project is using `2to3
+<http://docs.python.org/library/2to3.html>`_, ``python3 setup.py nosetests``
+command will automatically convert your sources with 2to3 and then the
+tests with python 3.
+
.. warning ::
nose itself supports python 3, but many 3rd-party plugins do not!
View
@@ -113,11 +113,27 @@ def finalize_options(self):
def run(self):
"""ensure tests are capable of being run, then
run nose.main with a reconstructed argument list"""
- self.run_command('egg_info')
+ if getattr(self.distribution, 'use_2to3', False):
+ # If we run 2to3 we can not do this inplace:
- # Build extensions in-place
- self.reinitialize_command('build_ext', inplace=1)
- self.run_command('build_ext')
+ # Ensure metadata is up-to-date
+ self.reinitialize_command('build_py', inplace=0)
+ self.run_command('build_py')
+ bpy_cmd = self.get_finalized_command("build_py")
+ build_path = bpy_cmd.build_lib
+
+ # Build extensions
+ self.reinitialize_command('egg_info', egg_base=build_path)
+ self.run_command('egg_info')
+
+ self.reinitialize_command('build_ext', inplace=0)
+ self.run_command('build_ext')
+ else:
+ self.run_command('egg_info')
+
+ # Build extensions in-place
+ self.reinitialize_command('build_ext', inplace=1)
+ self.run_command('build_ext')
if self.distribution.install_requires:
self.distribution.fetch_build_eggs(
@@ -126,7 +142,8 @@ def run(self):
self.distribution.fetch_build_eggs(
self.distribution.tests_require)
- argv = ['nosetests']
+ ei_cmd = self.get_finalized_command("egg_info")
+ argv = ['nosetests', ei_cmd.egg_base]
for (option_name, cmd_name) in self.option_to_cmds.items():
if option_name in option_blacklist:
continue

0 comments on commit 551ffe9

Please sign in to comment.