On Nov 8, 2019, at 18:59, Brian Skinn <brian.sk...@gmail.com> wrote: > > And no, I suspect it would be *quite* hard to write automated software able > to reliably assign a given module's path into those categories. It raises > basically the same set of problems as writing an automated mechanism for > _constraining_ imports only to certain of those category/ies; it "... would > be a piece of a nightmare...."
I’m not sure it would be that hard. The standard install directories have to get set up at Python install time, and the installer knows which of those directories are “stdlib” vs. “site”, is storing that information somewhere is probably not a huge deal. Custom Python installers (like Anaconda) and packaging tools (like py2app) would have to change as well, but again, it shouldn’t be too hard for them. And note that this works fine for zipimports, or custom “paths” that are handled by custom importers (although I suspect you’d want to leave that functionality up to custom finders to do whatever they wanted), because it doesn’t have to be a literal directory path; it can be a zipfile path, or an arbitrary key or whatever. Anything added by the package site is additional “site” packages. The empty entry that the interpreter adds is “local”. Anything else is “other”, but tools/packagers/etc. that want to do something different with their extra directories can have a way to specify one of them. This doesn’t cover the current package directory, but if we can already handle that for relative imports, if we need it here too, we can presumably do it here. This all assumes that we actually want the distinction to be between groups of directories/finders (as opposed to, say, “everything that’s documented as the Python standard library is std but nothing else”), but if that’s what we want, I think it’s doable without an implementation nightmare. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XR7DFCYQ5CWKVWFQKQEGP4QGTTTIL3VI/ Code of Conduct: http://python.org/psf/codeofconduct/