[Distutils] modules in different folders but under same namespace
Riccardo-Maria BIANCHI
riccardo.maria.bianchi at cern.ch
Thu Feb 4 18:23:41 CET 2010
Thanks Robert and Tarek for your answer,
I implemented the __path__ solution, and it works perfectly. Thanks!
and sorry if I was off-topic: I thought that distutils had options for
multi-folders setup, for "package_dir" and "packages" variables.
Best regards,
Ric.
Robert Kern wrote:
> On 2010-02-04 11:06 AM, Robert Kern wrote:
>> On 2010-02-04 10:53 AM, Riccardo-Maria BIANCHI wrote:
>>>
>>> Hi,
>>>
>>> I have a package structured like this:
>>>
>>>
>>> package/__init__.py
>>> src/ __init__.py
>>> mod1.py
>>> share/__init__.py
>>> mod2.py
>>>
>>>
>>> Now I can import them as:
>>> package.src.mod1
>>> package.share.mod2
>>>
>>> How can I use Distutils to be able to import both of them under the
>>> same
>>> "package" namespace as:
>>>
>>> import package.mod1
>>> import package.mod2
>>>
>>> ?
>>>
>>> Thanks a lot in advance for your kind help!
>>
>> Remove the package/src/__init__.py and package/share/__init__.py . In
>> your package/__init__.py, append the src/ and share/ directories to the
>> __path__ list.
>
> See this essay for more documentation on this feature:
>
> http://www.python.org/doc/essays/packages.html
>
More information about the Distutils-SIG
mailing list