[Distutils] proper use of use_2to3 with Distribute's test

Chris Jerdonek chris.jerdonek at gmail.com
Sat Apr 7 04:24:48 CEST 2012

On Fri, Apr 6, 2012 at 7:17 PM, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:
> I have a question regarding the proper use of the use_2to3 feature of
> Distribute's test, as described here:
> [1] http://packages.python.org/distribute/python3.html#distribute-as-help-during-porting
> My tests run correctly under Python 2.7 when running the following:
>    python setup.py test
> However, when I switch to Python 3, I get a syntax error when running
> this command.  The syntax error occurs in a module in a subdirectory
> of my working directory called "tests".  Modules in this directory
> don't seem to be converted to Python 3 when using the "use_2to3"
> keyword argument.
> When I manually convert everything to Python 3 using the following, I
> am able to run unit tests without that same syntax error:
>    2to3 --write --nobackups --no-diffs .
> What is the proper way to tell setup() which files to convert to
> Python 3?  Below is the relevant portion of my call to setup():
> setup(name='pystache',
>      ...
>      packages=['pystache'],
>      test_suite = 'tests',
> )

Sorry, this should have been the following (i.e. my call does include
the use_2to3 keyword)--

      test_suite ='tests',

Modules in my package's "pystache" directory are copied/converted to a
directory called "build/lib/pystache", but not modules in my package's
"test" directory.

> It might be worth expanding the documentation in the link [1] above
> with the additional information that an answer to my question will
> provide.
> Thanks,
> --Chris

More information about the Distutils-SIG mailing list