import conflict

Discussion in 'Python' started by rplzqx402@sneakemail.com, May 7, 2007.

  1. Guest

    Hello,

    I have a problem where I need to set up two separate Python projects
    that each live under the same package. Once they are distributed,
    they will live under the same filesystem path, but during development,
    they are separated.

    For example:
    proj1/lib/pkg/foo/mod1.py
    proj2/lib/pkg/bar/mod2.py

    Furthermore, proj1 is dependent on proj2, so I want to be able to say
    things like this, from within proj1:

    import pkg.foo.mod1
    import pkg.bar.mod2

    Of course this doesn't work, even with a PYTHONPATH configured to see
    both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
    will be hidden from view.

    Any suggestions?

    Thanks!
     
    , May 7, 2007
    #1
    1. Advertising

  2. schrieb:
    > Hello,
    >
    > I have a problem where I need to set up two separate Python projects
    > that each live under the same package. Once they are distributed,
    > they will live under the same filesystem path, but during development,
    > they are separated.
    >
    > For example:
    > proj1/lib/pkg/foo/mod1.py
    > proj2/lib/pkg/bar/mod2.py
    >
    > Furthermore, proj1 is dependent on proj2, so I want to be able to say
    > things like this, from within proj1:
    >
    > import pkg.foo.mod1
    > import pkg.bar.mod2
    >
    > Of course this doesn't work, even with a PYTHONPATH configured to see
    > both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
    > will be hidden from view.
    >
    > Any suggestions?
    >
    > Thanks!
    >
    >

    Hi,
    my only suggestion would be to overthink your project organization.
    You can surely solve that problem with symlinks, but if they depend
    on another, perhaps the structure is not optimal.
    If you use python 2.5 you can try absolute imports (which I personally
    find not so well):

    from __future__ import absolute_import

    See here: http://python.mirrors-r-us.net/dev/peps/pep-0328/

    Cheers,
    Stefan
     
    Stefan Sonnenberg-Carstens, May 7, 2007
    #2
    1. Advertising

  3. schrieb:
    > Hello,
    >
    > I have a problem where I need to set up two separate Python projects
    > that each live under the same package. Once they are distributed,
    > they will live under the same filesystem path, but during development,
    > they are separated.
    >
    > For example:
    > proj1/lib/pkg/foo/mod1.py
    > proj2/lib/pkg/bar/mod2.py
    >
    > Furthermore, proj1 is dependent on proj2, so I want to be able to say
    > things like this, from within proj1:
    >
    > import pkg.foo.mod1
    > import pkg.bar.mod2
    >
    > Of course this doesn't work, even with a PYTHONPATH configured to see
    > both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
    > will be hidden from view.
    >
    > Any suggestions?
    >
    > Thanks!
    >
    >

    Hi,
    my only suggestion would be to overthink your project organization.
    You can surely solve that problem with symlinks, but if they depend
    on another, perhaps the structure is not optimal.
    If you use python 2.5 you can try absolute imports (which I personally
    find not so well):

    from __future__ import absolute_import

    See here: http://python.mirrors-r-us.net/dev/peps/pep-0328/

    Cheers,
    Stefan
     
    Stefan Sonnenberg-Carstens, May 7, 2007
    #3
  4. <> wrote:

    > Hello,
    >
    > I have a problem where I need to set up two separate Python projects
    > that each live under the same package. Once they are distributed,
    > they will live under the same filesystem path, but during development,
    > they are separated.
    >
    > For example:
    > proj1/lib/pkg/foo/mod1.py
    > proj2/lib/pkg/bar/mod2.py
    >
    > Furthermore, proj1 is dependent on proj2, so I want to be able to say
    > things like this, from within proj1:
    >
    > import pkg.foo.mod1
    > import pkg.bar.mod2
    >
    > Of course this doesn't work, even with a PYTHONPATH configured to see
    > both projects, because it will find 'pkg' in proj1/lib and so pkg.bar
    > will be hidden from view.


    proj1/lib/pkg/__init__.py (and its counterpart under proj2) might set
    their __path__ as to "merge" the two separate directories when seen as
    Python packages. A rather contorted "solution" (compared to the simple
    and obvious one of NOT "separating during development" parts that appear
    to be so closely entwined) but I think it would work.


    Alex
     
    Alex Martelli, May 7, 2007
    #4
  5. On 6 May 2007 19:16:17 -0700, declaimed the
    following in comp.lang.python:

    > Hello,
    >
    > I have a problem where I need to set up two separate Python projects
    > that each live under the same package. Once they are distributed,
    > they will live under the same filesystem path, but during development,
    > they are separated.
    >
    > For example:
    > proj1/lib/pkg/foo/mod1.py
    > proj2/lib/pkg/bar/mod2.py
    >

    That does not fit your text description "two separate ... under the
    same package."

    Your text description implies something like

    lib/pkg/proj1/foo/...
    lib/pkg/proj2/bar/...
    --
    Wulfraed Dennis Lee Bieber KD6MOG

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, May 7, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    1,009
    Paul Opal
    Oct 11, 2004
  2. JPractitioner
    Replies:
    13
    Views:
    20,240
    Roedy Green
    Feb 24, 2006
  3. Charles Fineman

    targetNamespace/import conflict

    Charles Fineman, Jan 21, 2004, in forum: XML
    Replies:
    2
    Views:
    4,360
    Charles Fineman
    Feb 9, 2004
  4. Vitali Gontsharuk
    Replies:
    2
    Views:
    605
    Vitali Gontsharuk
    Aug 25, 2005
  5. charles cashion

    css conflict (or html conflict)

    charles cashion, Feb 18, 2009, in forum: HTML
    Replies:
    2
    Views:
    823
    charles cashion
    Feb 18, 2009
Loading...

Share This Page