[Distutils] namespace packages question
mal at egenix.com
Fri Nov 21 14:26:12 CET 2008
On 2008-11-21 09:49, Chris Withers wrote:
> Hi All,
> I want to be able to do things such as:
> from mortar import content
> from mortar.sqlalchemy import storage
> ...but where mortar is distrubuted as one package and mortar.sqlalchemy
> (and a whole lot more like it...) are distributed as seperate packages.
> Is this possible?
Sure. We've been doing just that for years with our mx Base package
and the mxODBC and mx Experimental add-ons for it.
All you have to do is put the base package into the first setup.py
and the subpackages in all others.
When installing these, distutils and all the binary installers for it
will happily combine everything into the final version of your
package on the target machine.
An alternative would be creating separate packages for all
components and then having the base package import all of them
on demand using e.g. the LazyModule object we have in eGenix mx
Base (it's in mx.Misc.LazyModule).
Yet another way is using __path__ hacks such as the one from setuptools,
but that can have serious implications on the import and startup time
of your app.
Finally, you could add you own importer to go hunt for the
other installed subpackages and install that at base package
Professional Python Services directly from the Source (#1, Nov 21 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Distutils-SIG