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

2011-07-02 Thread Mark Hammond

On 1/07/2011 7:20 PM, Vinay Sajip wrote:

Mark Hammond  gmail.com>  writes:


The intention is that there only be a single launcher, as only one app
can be associated with .py files.  OTOH though, file associations can be
configured per-user IIRC, and assuming that is the case, we could avoid
my multiple-ini-file usecase above by just allowing a different launcher
to be registered for a specific user.  This is sounding difficult from
the UI perspective though (ie, does the installer then need to ask that
question, will there be a post-install technique for per-user
registration, etc?)


I don't like this, for the reasons you state. I think it would be better if the
PEP was changed to say that there is intended to be just one launcher
installation per machine. As the intention is for the launcher to ship with
Python, and there can be multiple Pythons installed, I presume we'll have to
handle this by installing the launcher in some common-to-all-Pythons location
somewhere outside a Python installation location, such as "c:\Program
Files\Python Launcher". This should be stated in the PEP, and we'll also need to
indicate how the launcher will be cleaned up if for some strange reason someone
uninstalls all Pythons from a machine. Then we can just state that there's a
global .ini file (where the launcher is installed) and a local one (in the
user's APPDATA). From that perspective, it makes sense to have items in the
local (APPDATA) override the global (launcher installation location).


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.


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 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.


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



BTW I thought of another thing that perhaps needs handling: what if a customized
command points to the launcher itself? It'd be turtles all the way down :-)


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


From your second mail:


I've assumed that if a customised command is provided with arguments in the
shebang line, these will be ignored - if people want to run with different
options they can always define more customised commands. If you agree with this,
the PEP should probably explicitly state this.


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?



In a couple of cases I've implemented using fixed size arrays - for the lists of
installed Pythons and customised commands. Of course these can be made dynamic,
but what's there is good enough for the moment for exploration.


Sure - I think there is some policy that a Python version number will 
never be > 10, so that sounds fine to me.  So long as the launcher 
doesn't blindly run off the end of such arrays I think it is fine - 
limitations can be addressed in later versions.


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?


Cheers,

Mark
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2011-07-02 Thread Vinay Sajip
Mark Hammond  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

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com