On Tue, Sep 28, 2021 at 2:22 AM Marc-Andre Lemburg <m...@egenix.com> wrote: > #3 sounds like a good solution, but how would you detect "running > from the source tree" ? This sounds like you need another stat call > somewhere, which is what the frozen modules try to avoid.
We already look for the stdlib dir in Modules/getpath.c. We can use that information without an extra stat. (See https://bugs.python.org/issue45211.) > I'd like to suggest adding an environment variable to enable / > disable the setting instead. This makes it easy to customize the > behavior without introducing complicated logic. That's essentially what "-X frozen_modules=..." provides, though with an env var you don't have to adjust your CLI invocation each time. That said, there are a couple reasons why an env var might not be suitable. For one, I expect use of the -X option to be very uncommon, especially outside of core development, so more of a one-off feature. In contrast, to me environment variables imply repeated usage. Also, if we use an env var to override the default (of "on"), contributors will still get bitten by the problem I described originally. To me, it's important that the default in that case be "off" without any other intervention. FWIW, I consider the "complicated logic" part as the negative side of going with running-in-source-tree. So, at this point I'm leaning more toward Brett's suggestion of using "configure --with-pydebug" (AKA Py_DEBUG) to determine the default. That should be a suitable approximation of running-in-source-tree. We can circle back if it proves inadequate. On Tue, Sep 28, 2021 at 2:26 AM Marc-Andre Lemburg <m...@egenix.com> wrote: > Just to clarify: the modules would still always be frozen with > the env var setting, but Python would simply not import them > as frozen modules, but instead go and look on the PYTHONPATH > for the modules. > > This could be achieved by special casing the frozen module > finder function to only trigger on importlib modules and > return NULL for all other possibly frozen modules. Right. That is essentially what we're doing. (See find_frozen() in Python/import.c.) -eric _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/BVXMNZYHBPTKYC4QEVHGWUKQMLR2XGSZ/ Code of Conduct: http://python.org/psf/codeofconduct/