[Distutils] Skipping namespace file?

Kurt Schwehr schwehr at gmail.com
Fri Jan 5 15:05:04 CET 2007


Thanks for the reply, but I don't really understand your response.  I don't
know why multiple packages would install the same __init__.py file.  I think
that would be an error to do so on my part as a packager.  Maybe I am
missing the point.

Here is some more info.  Maybe this enough to show what I am doing wrong.

This install does not work (e.g.  "import dap" fails):

 %p/bin/python%type_raw[python] setup.py install --root=%d
--single-version-externally-managed

I do NOT get this file installed.

/sw/lib/python2.5/site-packages/dap/__init__.py


But this does work (as in the dap module works  "import dap" and "import
dap.client" but succeed and function correctly):

 %p/bin/python%type_raw[python] setup.py install --root=%d
--single-version-externally-managed
cp dap/__init__.py* %i/lib/python%type_raw[python]/site-packages/dap/

I then end up with

/sw/lib/python2.5/site-packages/dap/__init__.py

Here is what the pth looks like.  Is there something wrong with it then?

cat /sw/lib/python2.5/site-packages/dap-2.2.5.7-py2.5-nspkg.pth
import sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'],
*('dap', 'plugins')); ie = os.path.exists(os.path.join(p,'__init__.py')); m
= not ie and sys.modules.setdefault('dap.plugins',new.module('dap.plugins'));
mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and
mp.append(p)
import sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'],
*('dap', 'responses')); ie = os.path.exists(os.path.join(p,'__init__.py'));
m = not ie and sys.modules.setdefault('dap.responses',new.module('
dap.responses')); mp = (m or []) and m.__dict__.setdefault('__path__',[]);
(p not in mp) and mp.append(p)

If I read that right, it is not letting python know about the dap module, so
that I can't do something like "import dap.client".  Does this mean that the
setup.py is not configured correctly to include a "dap"?

Thanks!
-kurt


On 1/4/07, Phillip J. Eby <pje at telecommunity.com> wrote:
>
> At 10:47 AM 1/3/2007 -0500, Kurt Schwehr wrote:
> >Hi All,
> >
> >I am working on packaging pydap and am getting some strange behavior.
> >
> >Here is the install phase...
> >
> >/sw/bin/python2.4 setup.py install
> >--root=/sw/src/fink.build/root-dap-py24-2.2.5.7-1
> >--single-version-externally-managed
> >
> >
> >And when it gets to the __init__.py file for dap, it skips it.  This
> >causes the package to not work.
>
> It should also be installing a .pth file that makes it work, but if your
> final installation destination is not a 'site' directory (e.g. Python's
> site-packages directory), this will not work.
>
>
> >   Anyone have an idea why it is doing this?
>
> Because system packaging tools like RPM et al do not like it when multiple
> packages install the same file.  dap.plugins and dap.responses are
> "namespace packages", which means that other projects can install modules
> in them.  Those modules mustn't install an __init__.py, as it would
> overwrite the one supplied by pydap.  The setuptools solution to this
> problem is to never install an __init__.py at all for such packages, when
> used with a packaging tool (which is implied by the use of --root).
>
> Instead, setuptools generates a uniquely-named .pth file for each project,
> that sets up the namespace package at runtime.  Look for a .pth file being
> placed in your
>
>    /sw/src/fink.build/root-dap-py24-2.2.5.7-1
> /sw/lib/python2.4/site-packages/
>
> directory.  The problem is that if you then install the package somewhere
> other than /sw/lib/python2.4/site-packages, or use the -S option to Python
> at runtime, it may not work.
>
>
> >This install proceedure works well with other packages in mac
> osx/fink.  I
> >also see the behavior without the --single-version-externally-managed
> flag.
>
> That's because --root implies --single-version-externally-managed.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/distutils-sig/attachments/20070105/140a6898/attachment.html 


More information about the Distutils-SIG mailing list