[Numpy-discussion] numpydoc for python 3?

Jaakko Luttinen jaakko.luttinen@aalto...
Mon Jan 14 04:35:43 CST 2013

On 01/14/2013 12:53 AM, Matthew Brett wrote:
> On Sun, Jan 13, 2013 at 10:46 PM, Jaakko Luttinen
> <jaakko.luttinen@aalto.fi> wrote:
>> I'm a bit stuck trying to make numpydoc Python 3 compatible. I made
>> setup.py try to use distutils.command.build_py.build_py_2to3 in order to
>> transform installed code automatically to Python 3. However, the tests
>> (in tests folder) are not part of the package but rather package_data,
>> so they won't get transformed. How can I automatically transform the
>> tests too? Probably there is some easy and "right" solution to this, but
>> I haven't been able to figure out a nice and simple solution.. Any
>> ideas? Thanks.
> Can you add tests as a package 'numpydoc.tests' and add an __init__.py
> file to the 'tests' directory?

I thought there is some reason why the 'tests' directory is not added as
a package 'numpydoc.tests', so I didn't want to take that route.

> You might be able to get away without 2to3, using the kind of stuff
> that Pauli has used for scipy recently:
> https://github.com/scipy/scipy/pull/397

Ok, thanks, maybe I'll try to make the tests valid in all Python
versions. It seems there's only one line which I'm not able to transform.

In doc/sphinxext/tests/test_docscrape.py, on line 559:
    assert doc['Summary'][0] == u'öäöäöäöäöåååå'.encode('utf-8')

This is invalid in Python 3.0-3.2. How could I write this in such a way
that it is valid in all Python versions? I'm a bit lost with these
unicode encodings in Python (and in general).. And I didn't want to add
dependency on 'six' package.


More information about the NumPy-Discussion mailing list