[Distutils] distribute 0.6.10 and convert_2to3_doctests

Lennart Regebro regebro at gmail.com
Thu Jan 7 12:09:05 CET 2010

On Thu, Jan 7, 2010 at 00:17, Barry Warsaw <barry at python.org> wrote:
> Hash: SHA256
> I have a Python package called 'munepy' <https://launchpad.net/munepy> which
> provides yet another flavor of enums.  I'm working on the code for various
> reasons and I thought I'd take the opportunity to learn how to support both
> Python 2 and 3 from the same code base.
> I've updated the code so that it supports Python 2.6 at a minimum, and made it
> 'python -3' clean.  I've switched it from using setuptools to using
> distribute.  I was looking at this page:
>    http://packages.python.org/distribute/python3.html
> and it seems very cool that distribute can help make my life easier by
> allowing me to support both Python 2 and 3 from the same code base.  I set
> use_2to3=True in my setup.py and indeed
>    % python3 setup.py test
> (On Ubuntu 9.10) runs 2to3 over my .py files.  However, my doctests are in
> separate .txt files and I cannot seem to get the right incantation for
> convert_2to3_doctests.
> In the root of my source directory, my doctest lives at
> munepy/docs/README.txt, so I put this in my setup.py:
>    ...
>    use_2to3 = True,
>    convert_2to3_doctests = [
>        'munepy/docs/README.txt',
>        ],
>    ...
> but I never see that the README.txt is ever 'fixed'.  Indeed, the test fails
> because of a syntax error when the doctest tries to print something using
> Python 2 syntax.  I'm clearly not using this setup argument correctly, but I
> can't tell where I'm going wrong.
> How do you use convert_2to3_doctests?

Exactly like this. Note, however, that Distribute doesn't know that
the file isn't already converted. It will look at the timestamps of
the files, notice it hasn't changed, and do nothing. So you need to
delete the target file in build/ and rerun the tests to have it run
the conversion.
Lennart Regebro: Python, Zope, Plone, Grok
+33 661 58 14 64

More information about the Distutils-SIG mailing list