Skip to content

Commit

Permalink
Merge pull request #508 from erosennin/master
Browse files Browse the repository at this point in the history
Add support for converting the sources with 2to3 to nosetests setuptools command
  • Loading branch information
jpellerin committed Apr 9, 2012
2 parents 3983ae3 + 12740ca commit 551ffe9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions doc/index.rst
Expand Up @@ -60,6 +60,11 @@ nose supports python3. Building from source on python3 requires
have distribute installed, ``python3 setup.py install`` will install have distribute installed, ``python3 setup.py install`` will install
it via distribute's bootstrap script. 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 :: .. warning ::
nose itself supports python 3, but many 3rd-party plugins do not! nose itself supports python 3, but many 3rd-party plugins do not!
Expand Down
27 changes: 22 additions & 5 deletions nose/commands.py
Expand Up @@ -113,11 +113,27 @@ def finalize_options(self):
def run(self): def run(self):
"""ensure tests are capable of being run, then """ensure tests are capable of being run, then
run nose.main with a reconstructed argument list""" 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 # Ensure metadata is up-to-date
self.reinitialize_command('build_ext', inplace=1) self.reinitialize_command('build_py', inplace=0)
self.run_command('build_ext') 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: if self.distribution.install_requires:
self.distribution.fetch_build_eggs( self.distribution.fetch_build_eggs(
Expand All @@ -126,7 +142,8 @@ def run(self):
self.distribution.fetch_build_eggs( self.distribution.fetch_build_eggs(
self.distribution.tests_require) 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(): for (option_name, cmd_name) in self.option_to_cmds.items():
if option_name in option_blacklist: if option_name in option_blacklist:
continue continue
Expand Down

0 comments on commit 551ffe9

Please sign in to comment.