distutils question: different projects under same namespace

Q

Qiangning Hong

To avoid namespace confliction with other Python packages, I want all
my projects to be put into a specific namespace, e.g. 'hongqn' package,
so that I can use "from hongqn.proj1 import module1", "from
hongqn.proj2.subpack1 import module2", etc.

These projects are developed and maintained and distributed seperately,
so I should not make a whole 'hongqn' package with one setup.py. I
must write setup.py scripts for each project. I meet a problem here.

For instance, I am writing setup.py script for proj1. I use the
following parameters when calling distutils.core.setup:

setup(
...
package_dir = {'hongqn.proj1': 'proj1'},
packages = ['hongqn.proj1'],
...
)

"python setup.py install" will create /usr/lib/python2.3/hongqn/proj1
directory and copy proj1/*.py there. But this is UNUSABLE! There is
NO __init__.py file under /usr/lib/python2.3/hongqn/ so that import
hongqn.proj1 will fail!

I am considering manually create this __init__.py by hacking the
install_lib command. But before making my hands dirty, I want to know
if there is an "official" solution exists or others have already
success stories on this matter.

As a note, I wish the solution can handle setup.py bdist and
bdist_wininst well.
 
F

F. Petitjean

Le 16 Apr 2005 01:20:34 -0700, Qiangning Hong a écrit :
To avoid namespace confliction with other Python packages, I want all
my projects to be put into a specific namespace, e.g. 'hongqn' package,
so that I can use "from hongqn.proj1 import module1", "from
hongqn.proj2.subpack1 import module2", etc. That makes sense

These projects are developed and maintained and distributed seperately,
so I should not make a whole 'hongqn' package with one setup.py. I
must write setup.py scripts for each project. I meet a problem here.

For instance, I am writing setup.py script for proj1. I use the
following parameters when calling distutils.core.setup:

setup(
...
package_dir = {'hongqn.proj1': 'proj1'},
packages = ['hongqn.proj1'],
...
)

"python setup.py install" will create /usr/lib/python2.3/hongqn/proj1
directory and copy proj1/*.py there. But this is UNUSABLE! There is
NO __init__.py file under /usr/lib/python2.3/hongqn/ so that import
hongqn.proj1 will fail!
You can detect if there is __init__.py in the hongqn directory.
I am considering manually create this __init__.py by hacking the
install_lib command. But before making my hands dirty, I want to know
if there is an "official" solution exists or others have already
success stories on this matter.
It seems that this problem is tackled in the logilab packages : for
example, you install first the logilab common libraries and then pylint.
So the problem is to define the dependencies of your projects and hence
the order of installation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top