osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] New Python Initialization API


On 05Apr2019 0922, Victor Stinner wrote:
> While there are supporters of an "isolated Python" (sometimes called
> "system python"), the fact that it doesn't exist in any Linux distribution
> nor on any other operating system (Windows, macOS, FreeBSD), whereas it's
> already doable in Python 3.6 with Py_IsolatedFlag=1 makes me think that
> users like the ability to control Python with environment variables and
> configuration files.
> 
> I would prefer to leave Python as not isolated by default. It's just a
> matter of command line arguments.

Not for embedders it isn't. When embedding you need to do a whole lot of 
special things to make sure that your private version of Python doesn't 
pick up settings relating to a regular Python install.


We should make the Python runtime isolated by default, and only 
(automatically) pick up settings from the environment in the Python binary.


>>> * The PEP 432 stores ``PYTHONCASEOK`` into the config. Do we need
>>>    to add something for that into ``PyConfig``? How would it be exposed
>>>    at the Python level for ``importlib``? Passed as an argument to
>>>    ``importlib._bootstrap._setup()`` maybe? It can be added later if
>>>    needed.
>>
>> Could we convert it into an xoption? It's very rarely used, to my knowledge.
> 
> The first question is if there is any need for an embedder to change
> this option. Currently, importlib._bootstrap_external._install() reads
> the environment variable and it's the only way to control the option.

I think the first question should be "is there any reason to prevent an 
embedder from changing this option". In general, the answer is going to 
be no. We should expose all the options we rely on to embedders, or else 
they're going to have to find workarounds.

> ... By the way, importlib reads PYTHONCASEOK environment varaible even
> if isolated mode is enabled (sys.flags.isolated is equal to 1). Is it
> a bug? :-)

Yes, I think it's a bug. Perhaps this should become a proper 
configuration option, rather than a directly-read environment variable?