[Python-ideas] problems with import

Nick Coghlan ncoghlan at gmail.com
Sat Jun 28 00:18:27 CEST 2014


On 28 Jun 2014 05:20, "Steven D'Aprano" <steve at pearwood.info> wrote:
> Naturally, but I assumed that the only reason you would install
> something locally was if you intended it to over-ride the global
> version. If that's not the case, then you're right, it's an issue for
> Mercurial to solve.

Local installs are supported to *add* non-conflicting user specific
packages to the system Python installation, not to override them. The fact
it's tricky to override the standard library and system provided libraries
helps reduce the attack surface when running software with elevated access,
but still as a specific user.

Packages *can* opt-in to allowing contributions of submodules from later
sys.path entries by declaring that package as a namespace package. In
Python 3.3+ that's as simple as leaving __init__.py out entirely. In any
version, it can be done explicitly using pkgutil.extend_path() (standard
library) or pkg_resources.declare_namespace() (published as part of
setuptools)

Even with namespace packages, though, *modules* earlier in sys.path still
take precedence over later entries.

Cheers,
Nick.

>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140628/f5a646a3/attachment.html>


More information about the Python-ideas mailing list