[Python-Dev] PEP 397 (Python launcher for Windows) reference implementation

Vinay Sajip vinay_sajip at yahoo.co.uk
Sat Jul 2 11:08:50 CEST 2011


Mark Hammond <skippy.hammond <at> gmail.com> writes:

> The PEP does say "if possible, should be installed somewhere likely to 
> already be on the system PATH (eg., the Windows System32) directory." 
> It is silent about what to do when that isn't possible, but I'd think it 
> OK if the launcher was installed directly in the Python directory - IOW, 
> I'd think it OK if the PEP said "should be installed next to the 
> PythonXX.dll being installed" - but an important point in the above 
> working is the "already be on the system PATH" - ie, I don't really want 
> it put in a newly created directory unless the installer also adds that 
> directory to the PATH - and what to do on uninstall then becomes an issue.

But "next to PythonXY.dll" implies multiple copies, which we want to avoid,
right?

> One problem with all of this is uninstallation and specifically if the 
> user is uninstalling the most recent Python installation while leaving 
> earlier ones.  I guess there are 2 general answers to this:
> 
> * The installer process could remember the previous association and 
> restore that on uninstall.

We'd need to do that in the case of the earlier Python not having come with a
launcher, i.e. when its version is < 3.3.

> * We treat this as a "wont-fix" and document a work-around of asking the 
> user to reinstall the previous version to restore the file association.

This is not ideal from a user's perspective.

> We probably need to be mindful of adding too much extra work for the 
> installer process as that may well end up blocking us on getting this 
> into the next appropriate release.  In particular, Martin's thoughts 
> here would be very useful.
> 
> This would force the user to reinstall that older one to re-establish 
> the associations correctly

It sounds onerous for users to have to reinstall an older Python. I'm not that
familiar with Windows Installer features, so I don't know if this is too fancy,
but perhaps we could remember the last non-launcher association when we install
the launcher, and either restore that when the launcher is uninstalled (if it's
still pointing to an installed Python) or remove the association altogether,
otherwise. If this logic is too fancy to include in the installer itself,
perhaps we can provide this logic in the launcher itself or via an ancillary
executable or DLL that the installer can just call into.

Is there some mechanism like the SharedDLLs registry key for executables, which
could be used to reference count launcher installations so that it could be
uninstalled at the appropriate time? Could we perhaps used the SharedDLLs
feature itself?

> Yeah - I wonder if we can leverage the "job" api here and refuse to 
> start if there are already 2 processes in the job?  OTOH, that is tricky 
> as it would also prevent someone using os.startfile with a .py file....

If there's only ever one launcher installed (which we could ensure by
installing it in a Windows rather than a Python location) then perhaps we could
perhaps check for the value of a customised command pointing at the one-and-
only launcher, but this is circumventable. Anyway, perhaps we just need to
handle a user error rather than someone deliberately trying to engineer
recursion.

Another approach might be - rather than limit the number of processes in the
job, look to see if the launcher executable is already associated with an
existing job. I'm not au fait with the job API, and hence unsure of how that
would play with usages such as os.startfile, subprocess etc.

> I'm not too bothered to be honest - the customized commands exist purely 
> for alternative implementations, so my initial thoughts are that 
> additional args would be as useful for them as they are for cpython 
> invocations.  IOW, if they don't need it, then CPython invocations don't 
> need it either, so maybe it can be dropped completely?

I think they would be useful, so let me check the implementation again.

> It will be a few days until I can look at the implementation, but I'm 
> very happy to see it started.  Given it is now ahead of the Python 
> reference impl, I wonder if we should just drop all wording about that 
> reference impl and just treat the C impl as canonical?

Once you've taken a closer look, if you think it looks good enough, then that's
fine. If you have a BitBucket account, I can add your account to the repo so
you can push changes to it.

Regards,

Vinay Sajip



More information about the Python-Dev mailing list