import conflict
Alex Martelli
aleax at mac.com
Mon May 7 00:34:04 EDT 2007
<rplzqx402 at sneakemail.com> 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
More information about the Python-list
mailing list