On Tue, Mar 25, 2014 at 3:50 PM, Barry Warsaw <ba...@python.org> wrote:
> On Mar 25, 2014, at 03:35 PM, PJ Eby wrote: > > >I think the correct fix would be to change the nspkg.pth magic to check > for > >PEP 420 support, but unfortunately it seems we may have to use version > >checking: on rereading PEP 420 I see there's no 'sys.namespace_packages' > or > >similar object that can be directly checked for feature support. :-( > > There is. It's *pronounced* sys.namespace_packages, but it's spelled > importlib._bootstrap._NamespaceLoader ;) > Yeah, well that's not exactly a public attribute, so it's not necessarily a great way to do it. But if we did use that, presumably it'd add something like: hnp = hasattr(sys.modules.get('importlib._bootstrap',None),'_NamespaceLoader'); To the front of the magic, and then prefix all subsequent expression values with 'not hnp and' in order to prevent them executing if PEP 420 support is available. (Note: it's checking sys.modules since on any interpreter where PEP 420 is natively available, the module should *already* be loaded by the time site.py does its thing.) And we should probably think about adding sys.namespace_packages or something of the sort, or at least a proper flag for whether PEP 420 support is available on the platform.
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig