<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi KP,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 2, 2015, at 7:00 PM, KP <<a href="mailto:patter001@gmail.com" class="">patter001@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">><span style="font-size:12.8px" class="">It looks like you are trying to find a workaround for the problem that perhaps is not a problem at all if you use the standard approach properly.</span><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">I'm definitely _trying_ to use a standard approach...That is why I am here posting. Put simply this seems like a valid use case:</span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">>pip install foo.bar </span></div><div class=""><span style="font-size:12.8px" class="">></span><span style="font-size:12.8px" class="">pip install -e svn+http://<path-to-foo.more></span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">Even if both tools have the namespace_package foo, the "foo.more" will not properly import.</span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">How is this going against standard approaches?</span></div></div></div></blockquote><div><br class=""></div><div>I don’t know.</div><div>Without seeing the source code for these packages (which Marius already asked for) everything is hypothetical.</div><div>All I know is that I’m using namespaces successfully for over a decade now and never had the need to work around them.</div><div><br class=""></div><div>Show us the code.  We may be able to help better if we can try and reproduce.</div><div>Otherwise, it’s hard.</div><div><br class=""></div><div>Thanks!</div><div><br class=""></div><div>Zvezdan</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Dec 2, 2015 at 9:54 PM, Zvezdan Petkovic <span dir="ltr" class=""><<a href="mailto:zvezdanpetkovic@gmail.com" target="_blank" class="">zvezdanpetkovic@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi KP,<div class=""><br class=""></div><div class="">Maybe I didn’t follow the thread from the beginning, but your use case is not clear to me. </div><div class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Dec 1, 2015, at 1:31 PM, KP <<a href="mailto:patter001@gmail.com" target="_blank" class="">patter001@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class=""><span style="font-size:12.8px" class="">(sorry for the stupid previous early send)</span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><span style="font-size:12.8px" class="">Just to recap:</span><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">1. if you don’t put namespace_packages in the setup.py, then it will uninstall the shared __init__.py when you uninstall any of the packages</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Right. You need to declare the namespace in setup.py.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class="">2. <span style="font-size:11pt;font-family:Calibri" class="">If you put namespace_packages, then there is a pth file created for the shared directory (site-packages/foo) and no foo/__init__.py is created (even if it is in your package)</span></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Correct. That is exactly the behavior that’s expected. There can be many packages in the namespace (e.g., zope.* or zope.app.*) and they all share the namespace, but none of them owns that __init__.py. That’s why it’s not installed there and is replaced with a *.pth file.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">#2 - breaks things like : doing a source checkout that participates in this namespace_package…If you do this then only the lib/site-packages/foo/<modules> are importable</span></font></div></div></div></blockquote><div class=""><br class=""></div><div class="">Again, it’s not clear what are you referring to?</div><div class="">Are you doing a source checkout over your installed packages / virtual environment?</div><div class="">I sure hope not.</div><div class="">You can use pip —editable for adding your source checkouts to virtual environment or installed packages.</div><div class=""><br class=""></div><div class="">If you use build tools (such as zc.buildout) and install your packages, they will end up over several egg / wheel directories “parallel” to each other, but the proper namespace declaration will ensure that they are all importable. You cannot even do the source checkout over such an installation.</div><div class=""><br class=""></div><div class="">It looks like you are trying to find a workaround for the problem that perhaps is not a problem at all if you use the standard approach properly.</div><span class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">Solution appears to be:</span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">create a standalone “foo" package that has ONLY the shared __init__.py, and do NOT set "namespace_packages" .</span></font></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">No, that is not the solution. That’s a sure way to break the namespace in the egg/wheel based installations.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""> This seems to associate the __init__.py with the “foo” tool, so that only when you uninstall the "foo" tool does the __init__.py get uninstalled.</span></font></div></div></div></blockquote><br class=""></span><div class="">Why do you worry so much about uninstalling __init__.py.</div><div class="">If it’s not there (and it isn’t with properly declared namespaces) why does it matter?</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""> It also has the shared __init__.py in lib/site-packages, so it seems that enables the other namespace packages that are source checkouts or added to path via other methods.</span></font></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">What other methods?</div><div class="">The key here is to make decision how do you want to install your packages?</div><div class="">Pick one and use it instead fighting the tooling.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">Hopefully this works long term, and maybe is useful to someone else out there….</span></font></div></div></div></blockquote><div class=""><br class=""></div>I doubt it,</div><div class="">It’s an incorrect advice.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Zvezdan</div></font></span><div class=""><div class="h5"><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">Thanks,</span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div style="font-size:12.8px" class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Dec 1, 2015 at 4:29 PM, KP <span dir="ltr" class=""><<a href="mailto:patter001@gmail.com" target="_blank" class="">patter001@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Just to recap:<div class=""><br class=""></div><div class="">1. if
you don't put namespace_packages in the setup.py, then it will uninstall the
shared __init__.py when you uninstall any of the packages</div><div class="">2. <span style="font-size:11pt;font-family:Calibri" class="">If you put
     namespace_packages, then there is a pth file created for the shared
     directory (site-packages/foo) and no foo/__init__.py is
     created (even if it is in your package)</span></div><div class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">#2 - breaks things like : doing a source checkout that participates in this namespace_package...If you do this then only the lib/site-packages/foo/<modules> are importable</span></font></div><div class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div><div class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class="">Solution appears to be:</span></font></div><div class=""><font face="Calibri" class=""><span style="font-size:14.6667px" class=""><br class=""></span></font></div></div><div class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Dec 1, 2015 at 7:17 AM, KP <span dir="ltr" class=""><<a href="mailto:patter001@gmail.com" target="_blank" class="">patter001@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">yes, both of those statements are true.<div class=""><br class=""></div><div class="">However, with the namespace_packages = ['foo'], the lib\site-packages\foo\__init__.py does not get installed (even though it is in the source tree). Instead there's just a dir with "foo/bar/__init__.py" and "foo/blah/__init__.py". I will try to look in the "wheel" side of things next I guess. Perhaps pip is doing something since it seems to install even source distributables by first converting to a wheel.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="">On Tue, Dec 1, 2015 at 1:38 AM, Marius Gedminas <span dir="ltr" class=""><<a href="mailto:marius@gedmin.as" target="_blank" class="">marius@gedmin.as</a>></span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class=""><span class="">On Mon, Nov 30, 2015 at 06:59:31PM -0500, KP wrote:<br class="">
> I'm not sure where the issue is, but when I specify a namespace_package in<br class="">
> the setup.py file, I can indeed have multiple packages with the same base<br class="">
> (foo.bar, foo.blah, etc...). The files all install in to the same<br class="">
> directory. It drops  the foo/__init__.py that would be doing the<br class="">
> extend_path, and instead adds a ".pth" file that is a bit over my head.<br class="">
><br class="">
> The problem is that it does not seem to traverse the entire sys.path to<br class="">
> find multiple foo packages.<br class="">
<br class="">
</span>Does every foo.x package specify namespace_packages=['foo']?<br class="">
<br class="">
Do they all ship an identical foo/__init__.py with<br class="">
<br class="">
    import pkg_resources<br class="">
    pkg_resources.declare_namespace(__name__)<br class="">
<br class="">
?<br class="">
<br class="">
AFAIU you need both things in every package, if you want to use<br class="">
namespace packages.<br class="">
<div class=""><div class=""><br class="">
> If I do not specify namespace_packages and instead just use the<br class="">
> pkgutil.extend_path, then this seems to allow the packages to be in<br class="">
> multiple places in the sys.path.<br class="">
><br class="">
> Is there something additional for the namespace_package that i need to<br class="">
> specify in order for all of the sys.path to be checked?<br class="">
><br class="">
> I'm using 18.5 setuptools....but I am not sure if this somehow ties in to<br class="">
> wheel/pip, since I'm using that for the actual install.<br class="">
<br class="">
</div></div><span class=""><font color="#888888" class="">Marius Gedminas<br class="">
--<br class="">
Give a man a computer program and you give him a headache, but teach him to<br class="">
program computers and you give him the power to create headaches for others for<br class="">
the rest of his life...<br class="">
        -- R. B. Forest<br class="">
</font></span><br class=""></div></div>_______________________________________________<br class="">
Distutils-SIG maillist  -  <a href="mailto:Distutils-SIG@python.org" target="_blank" class="">Distutils-SIG@python.org</a><br class="">
<a href="https://mail.python.org/mailman/listinfo/distutils-sig" rel="noreferrer" target="_blank" class="">https://mail.python.org/mailman/listinfo/distutils-sig</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">Distutils-SIG maillist  -  <a href="mailto:Distutils-SIG@python.org" target="_blank" class="">Distutils-SIG@python.org</a><br class=""><a href="https://mail.python.org/mailman/listinfo/distutils-sig" target="_blank" class="">https://mail.python.org/mailman/listinfo/distutils-sig</a><br class=""></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>