[Python-Dev] Draft PEP and reference implementation of a Python launcher for Windows

Mark Hammond mhammond at skippinet.com.au
Mon Mar 21 06:30:56 CET 2011


On 21/03/2011 3:50 PM, Greg Ewing wrote:
> Martin v. Löwis wrote:
>
>> Windows doesn't support exec.
>
> Hmmm. In that case, if the launcher works by loading a pythonXY.dll,
> I'd say that sys.executable should point to whatever version of
> python.exe corresponds to that dll.
>
> Generally, things should be made to look as much as possible as
> if that python.exe had been executed in the first place.

Yeah, that would have to be the plan - if there are ways it *doesn't* 
look like python.exe had been executed it is likely to cause problems.

Initially I thought we could just adjust sys.executable after it is set 
to the "inappropriate" default value, but that would be tricky - this is 
called by Python during Py_Main() - which also executes the specified 
script.  Thus, the launcher would either:

* Call Py_Initialize(), adjust sys.executable, then call Py_Main().  I'm 
not sure what side-effects this would have though - Py_Main does a 
number of things before calling Py_Initialize() and having it called 
before those things are done might have other side-effects.

* Re-implement Py_Main and adjust sys.executable immediately after it is 
set.  This would be a huge burden given the size of that routine and the 
number of different versions we want to support.

The first option is the only one I'd really consider reasonable and I'll 
probably experiment with it once we have enough agreement that the C 
implementation can proceed - but I'm not confident enough we can make it 
work correctly to base the entire success or failure of the PEP on that 
detail.

Any other ideas/thoughts about this?

Mark


More information about the Python-Dev mailing list