[Distutils] Installing subpackages under common superpackage
Jonathan Ballet
jon at multani.info
Tue Apr 3 18:41:21 CEST 2012
On Tue, Apr 03, 2012 at 04:35:17PM +0100, Otto Maddox wrote:
> Hi,
>
> I have a Python project which follows a client-server architecture. It
> is natural to develop it as two different projects and in two different
> source distributions, myproject-server.tar.gz and
> myproject-client.tar.gz.
>
> Neither package depends on the other, but because they are part of a
> larger, overarching project, I want install each of them so that they
> appear as subpackages (myproject.server and myproject.client) under a
> common superpackage (myproject). I am looking for the cleanest and most
> correct way to do this using distutils and setup.py, so that I can end
> up with a structure like this:
>
> site-packages/myproject
> site-packages/myproject/__init__.py
>
> site-packages/myproject/server/__init__.py
> site-packages/myproject/server/file1.py
> site-packages/myproject/server/file2.py
>
> site-packages/myproject/client/__init__.py
> site-packages/myproject/client/file3.py
> site-packages/myproject/client/file4.py
>
> and so that any of the following commands (and their standard
> variations) work:
>
> import myproject
> import myproject.server
> import myproject.client
>
> Is there a way to write distutils/setup.py to do this?
You would probably interested about setuptools' namespace support for
doing this, you can have a look at
http://packages.python.org/distribute/setuptools.html#namespace-packages
Additionnaly, if you are looking for examples, the Zope community is
well known for the use of namespaced packages - have a look at the
zope., zc., z3c., collective., plone., etc. namespaces.
Jonathan
More information about the Distutils-SIG
mailing list