[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: No __init__.py for namespaced module in Python 3.4



On Fri, Sep 05, 2014 at 11:16:53PM +0800, Thomas Goirand wrote:
> But in Python 3.4, there's no such a file. While this doesn't seem to be
> a problem with the packages once installed, it is breaking unit tests.
> For example, building python-oslo.serialization and running the unit
> tests, I get:
> 
>   File "<...>/tests/test_jsonutils.py", line 28, in <module>
>     from oslo.serialization import jsonutils
> ImportError: No module named 'oslo.serialization'

import oslo and check __file__ - it should give you an attribute error
(and printing it should result in:

<module 'oslo' (namespace)>

)

> Surprisingly, when I just do (as root):
> 
> echo "" >/usr/lib/python3/dist-packages/oslo/__init__.py

Hurm, this just turns from namespace package into a concrete package.
Not great :\

> then everything works again, and subunit under Python3.4 can find the
> local version of oslo.serialization.
> 
> So I am wondering: is there something wrong with dh_python3? Or should I
> manually maintain an empty __init__.py in the postinst of my Python3
> oslo packages, just for the unit tests to pass? Both of these sentences
> seems really wrong, so there may be something I'm missing.


Empty init is totally valid - http://legacy.python.org/dev/peps/pep-0420/

I love this feature (and I hate Python 2's lack of support here -
another reason to burn python 2 and never go back)

> Currently, I'm disabling the unit tests for Python 3.4 in
> oslo.serialization, but this really doesn't seem to be the way to go,
> and I would like to find a way to fix this.


Sounds like the namespace is getting busted up somehow.


Cheers,
  Paul

-- 
 .''`.  Paul Tagliamonte <paultag@debian.org>  |   Proud Debian Developer
: :'  : 4096R / 8F04 9AD8 2C92 066C 7352  D28A 7B58 5B30 807C 2A87
`. `'`  http://people.debian.org/~paultag
 `-     http://people.debian.org/~paultag/conduct-statement.txt

Attachment: signature.asc
Description: Digital signature


Reply to: