distutils question: different projects under same namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Qiangning Hong

    #1

    distutils question: different projects under same namespace

    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.su bpack1 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. Petitjean

    #2
    Re: distutils question: different projects under same namespace

    Le 16 Apr 2005 01:20:34 -0700, Qiangning Hong a écrit :[color=blue]
    > 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.su bpack1 import module2", etc.[/color]
    That makes sense[color=blue]
    >
    > 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![/color]
    You can detect if there is __init__.py in the hongqn directory.[color=blue]
    >
    > 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.[/color]
    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.[color=blue]
    >
    > As a note, I wish the solution can handle setup.py bdist and
    > bdist_wininst well.
    >[/color]

    Comment

    Working...