py launcher for Linux?
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux. Anyone care to try their hand at writing such a script? Cheers, Nick.
Not me, but I would recommend giving it a more prosaic (and longer) name.
When discussing this at PyCon I was initially confused by the multiple uses
of "py" in the same sentence. :)
On Tue, Apr 15, 2014 at 7:12 PM, Nick Coghlan
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux.
Anyone care to try their hand at writing such a script?
Cheers, Nick.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido)
16.04.14 05:12, Nick Coghlan написав(ла):
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux.
Anyone care to try their hand at writing such a script?
$ alias py= or script: $ cat py #!/bin/sh "$@"
On 04/15/2014 10:12 PM, Nick Coghlan wrote:
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux.
Anyone care to try their hand at writing such a script?
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed? I have a pristine 2.7 in /usr/local/bin and the system python 2.7 in /usr/bin. I've also seen /opt/bin used, and other places deliberately not on PATH. How would a launcher find these, let alone decide which one to use? I'll be around the sprints for a very short time this morning, if anyone wants to discuss it. Eric.
On 16 Apr 2014 06:27, "Eric V. Smith"
On 04/15/2014 10:12 PM, Nick Coghlan wrote:
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to
Linux.
Anyone care to try their hand at writing such a script?
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed?
I have a pristine 2.7 in /usr/local/bin and the system python 2.7 in /usr/bin. I've also seen /opt/bin used, and other places deliberately not on PATH. How would a launcher find these, let alone decide which one to use?
Note that my main interest here is in making commands like: py -3 -m pip install foo cross platform rather than Windows specific. At the moment we don't have a way to explicitly invoke Python 3 that works everywhere. Given the way POSIX installations of Python name things, simple string munging, along with delegation to the shell's normal shebang line processing when given a script without nominating a particular version to use, should suffice to largely reproduce the PEP 397 behaviour. The launcher config file also provides an opportunity to make the "default Python" a per user setting without altering which version the "python" symlink refers to. Cheers, Nick.
I'll be around the sprints for a very short time this morning, if anyone wants to discuss it.
Eric.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
On 04/16/2014 07:50 AM, Nick Coghlan wrote:
On 16 Apr 2014 06:27, "Eric V. Smith"
mailto:eric@trueblade.com> wrote: On 04/15/2014 10:12 PM, Nick Coghlan wrote:
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to
Linux.
Anyone care to try their hand at writing such a script?
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed?
I have a pristine 2.7 in /usr/local/bin and the system python 2.7 in /usr/bin. I've also seen /opt/bin used, and other places deliberately not on PATH. How would a launcher find these, let alone decide which one to use?
Note that my main interest here is in making commands like:
py -3 -m pip install foo
cross platform rather than Windows specific. At the moment we don't have a way to explicitly invoke Python 3 that works everywhere.
Given the way POSIX installations of Python name things, simple string munging, along with delegation to the shell's normal shebang line processing when given a script without nominating a particular version to use, should suffice to largely reproduce the PEP 397 behaviour.
The launcher config file also provides an opportunity to make the "default Python" a per user setting without altering which version the "python" symlink refers to.
Okay. I'll take a crack at this. Eric.
On Wed, 16 Apr 2014 07:50:17 -0400
Nick Coghlan
cross platform rather than Windows specific. At the moment we don't have a way to explicitly invoke Python 3 that works everywhere.
How about "python3"? That's not different from "python" for 2.x. If we don't install anything named "python3.exe" under Windows, then perhaps we should, instead of adding a clunky wrapper under POSIX. Regards Antoine.
16.04.14 13:25, Eric V. Smith написав(ла):
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed?
Debian-like systems use "alternatives". https://wiki.debian.org/DebianAlternatives
On 14-04-15 07:12 PM, Nick Coghlan wrote:
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux.
Anyone care to try their hand at writing such a script?
Do you mean something like "pyenv": https://github.com/yyuu/pyenv
Serhiy Storchaka writes:
16.04.14 13:25, Eric V. Smith написав(ла):
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed?
Debian-like systems use "alternatives".
Eric's example of a "pristine" build in /usr/local/bin shows that we need to consider whether a python not known to the system PMS should be considered to be "installed". I would think on POSIX systems anything on the PATH should be considered to be "installed", but that's not an exact analogy to Windows semantics of "look in the registry".
On Thu, Apr 17, 2014 at 02:21:16AM +0900, "Stephen J. Turnbull"
Serhiy Storchaka writes:
16.04.14 13:25, Eric V. Smith написав(ла):
I meant to bring this up at the PyCon sprints. On Windows, the launcher finds the various versions of Python by looking in the registry. How is a Linux version supposed to find what versions of Python are installed?
Debian-like systems use "alternatives".
Eric's example of a "pristine" build in /usr/local/bin shows that we need to consider whether a python not known to the system PMS should be considered to be "installed". I would think on POSIX systems anything on the PATH should be considered to be "installed", but that's not an exact analogy to Windows semantics of "look in the registry".
I believe there is no need to think about what's *installed*; it's enough to think about what's *available* -- in PATH and in the config file. Who cares from what sources and in what ways they became available? Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.
On Apr 16, 2014, at 4:50, Nick Coghlan
Note that my main interest here is in making commands like:
py -3 -m pip install foo
cross platform rather than Windows specific. At the moment we don't have a way to explicitly invoke Python 3 that works everywhere.
It might be a lot simpler to get just that than the full py script: If you just run python (off the path), unless -3 is specified, in which case you run python3 instead. Doesn't that over all known distros, third-party installations, and pristine local installs of 3.x? If you also want to make -2 portable, it seems like that requires some configuration (as long as some distros install 3.x as python, and others install 2.x as just python and not also python2). But is that a requirement!
Andrew Barnert writes:
If you just run python (off the path), unless -3 is specified, in which case you run python3 instead. Doesn't that over all known distros, third-party installations, and pristine local installs of 3.x?
I don't know if you consider MacPorts a "distro", but no, it doesn't install a /opt/local/bin/python3 link. You need to specify the minor version.
In article <87eh0w4gee.fsf@uwakimon.sk.tsukuba.ac.jp>,
"Stephen J. Turnbull"
I don't know if you consider MacPorts a "distro", but no, it doesn't install a /opt/local/bin/python3 link. You need to specify the minor version.
https://trac.macports.org/ticket/42747 -- Ned Deily, nad@acm.org
Hi, Le 15/04/2014 22:12, Nick Coghlan a écrit :
Something that came up during PyCon was the idea of a "py" script that brought "Python Launcher for Windows" explicit version dispatch to Linux.
As a Debian end user and Python developer, I don’t have a need for this; Unixen have shebangs and naming conventions (more or less similar across OSes) for co-installed versions of Python. (“Explicit dispatch” and “cross-platform invocation” don’t tell me much.) I went back and read the beginning of PEP 397 again to find use cases: Abstract This PEP describes a Python launcher for the Windows platform. A Python launcher is a single executable which uses a number of heuristics to locate a Python executable and launch it with a specified command line. Rationale Windows provides "file associations" so an executable can be associated with an extension, allowing for scripts to be executed directly in some contexts (eg., double-clicking the file in Windows Explorer.) Until now, a strategy of "last installed Python wins" has been used and while not ideal, has generally been workable due to the conservative changes in Python 2.x releases. As Python 3.x scripts are often syntactically incompatible with Python 2.x scripts, a different strategy must be used to allow files with a '.py' extension to use a different executable based on the Python version the script targets. This will be done by borrowing the existing practices of another operating system - scripts will be able to nominate the version of Python they need by way of a "shebang" line, as described below. It seems to me the problem is defined as specific to Windows, and the solution takes inspiration from other operating systems. I think a new rationale explaining why bring back that solution to these other OSes is needed. Regards
On 18 April 2014 15:49, Éric Araujo
It seems to me the problem is defined as specific to Windows, and the solution takes inspiration from other operating systems. I think a new rationale explaining why bring back that solution to these other OSes is needed.
It would be about removing the current cross-platform discrepancy in the instructions at https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-... Not a high priority for me personally, but I figured it was worth mentioning in case it captured someone's interest. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
On 4/18/2014 6:27 PM, Nick Coghlan wrote:
On 18 April 2014 15:49, Éric Araujo
wrote: It seems to me the problem is defined as specific to Windows, and the solution takes inspiration from other operating systems. I think a new rationale explaining why bring back that solution to these other OSes is needed.
It would be about removing the current cross-platform discrepancy in the instructions at https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-...
Not a high priority for me personally, but I figured it was worth mentioning in case it captured someone's interest.
I'm sort of interested. I'm still working on the semantic differences between the Windows and Unix versions. Parsing the .ini files in C or sh/awk/sed is definitely a hassle. I can't decide if we should assume there's a python executable on the PATH or not. Windows has the benefit of GetPrivateProfileString to do the heavy lifting there. Eric.
participants (11)
-
Andrew Barnert
-
Antoine Pitrou
-
Eric V. Smith
-
Guido van Rossum
-
Ned Deily
-
Nick Coghlan
-
Oleg Broytman
-
Serhiy Storchaka
-
Stephen J. Turnbull
-
Todd Whiteman
-
Éric Araujo