At 05:53 PM 2/4/2010 +0100, 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
Move mod1.py and mod2.py under package/, and delete the
subdirectories. If you need backward compatibility, leave the old
subdirectories and files in place, but have them import the new ones
instead of containing any code. Then delete them later.
Munging __path__ or using the package_dir options to setup() are both
bad ideas in this case, unless there are other requirements you haven't stated.
If you use the __path__ approach, you're going to make it more
difficult for the distutils to figure out what to include in your
source and binary distributions and installs, and if you use
package_dir, you're going to end up with a different installation
layout than your source layout. Both will likely lead to hassles
down the road, even if they appear to work in the short term.
_______________________________________________
Distutils-SIG maillist - Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig