unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45655: Please use 'python3' command instead of 'python'
@ 2021-01-04 15:14 Balint Reczey
  2021-01-06 16:59 ` Glenn Morris
  2021-01-10 17:42 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Balint Reczey @ 2021-01-04 15:14 UTC (permalink / raw)
  To: 45655

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Hi,

Python 2 reached EOL about a year ago thus the 'python' command may be
missing on some systems.
'python3' is the standard way of invoking the Python 3 interpreter,
thus Emacs would have a better chance trying that.

The attached patch is already carried in Ubuntu.

Cheers,
Balint

[1] https://www.python.org/doc/sunset-python-2/

-- 
Balint Reczey
Ubuntu & Debian Developer

[-- Attachment #2: python3-as-default.patch --]
[-- Type: text/x-patch, Size: 799 bytes --]

Description: Run python3 command as default instead of python
Author: Balint Reczey <balint.reczey@canonical.com>
Origin: vendor
Forwarded: no
Last-Update: 2020-03-25

--- a/lisp/ldefs-boot.el
+++ b/lisp/ldefs-boot.el
@@ -26539,7 +26539,7 @@
 
 (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode))
 
-(autoload 'run-python "python" "\
+(autoload 'run-python "python3" "\
 Run an inferior Python process.
 
 Argument CMD defaults to `python-shell-calculate-command' return
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1952,7 +1952,7 @@
   :group 'python
   :safe 'stringp)
 
-(defcustom python-shell-interpreter "python"
+(defcustom python-shell-interpreter "python3"
   "Default Python interpreter for shell."
   :type 'string
   :group 'python)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-04 15:14 bug#45655: Please use 'python3' command instead of 'python' Balint Reczey
@ 2021-01-06 16:59 ` Glenn Morris
  2021-01-06 17:47   ` Balint Reczey
  2021-01-10 17:42 ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2021-01-06 16:59 UTC (permalink / raw)
  To: Balint Reczey; +Cc: 45655

Balint Reczey wrote:

> Python 2 reached EOL about a year ago thus the 'python' command may be
> missing on some systems. 'python3' is the standard way of invoking the
> Python 3 interpreter, thus Emacs would have a better chance trying
> that.
>
> The attached patch is already carried in Ubuntu.

Thanks for the report.

> --- a/lisp/ldefs-boot.el
> +++ b/lisp/ldefs-boot.el
> @@ -26539,7 +26539,7 @@
>  
>  (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode))
>  
> -(autoload 'run-python "python" "\
> +(autoload 'run-python "python3" "\

This bit is wrong. Firstly, ldefs-boot is a generated file, and
secondly, unless Ubuntu is distributing a python3.el, it would just
break the autoload.

> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -1952,7 +1952,7 @@
>    :group 'python
>    :safe 'stringp)
>  
> -(defcustom python-shell-interpreter "python"
> +(defcustom python-shell-interpreter "python3"

(if (executable-find "python3") "python3" "python")

is probably how Emacs would normally handle this kind of thing.
Or if defaulting to python3 is better (I guess it is):

(cond ((executable-find "python3") "python3")
      ((executable-find "python") "python")
      (t "python3"))





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-06 16:59 ` Glenn Morris
@ 2021-01-06 17:47   ` Balint Reczey
  2021-01-10 14:49     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Balint Reczey @ 2021-01-06 17:47 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 45655

Hi Glenn,

Thanks for the quick response.

On Wed, Jan 6, 2021 at 5:59 PM Glenn Morris <rgm@gnu.org> wrote:
>
> Balint Reczey wrote:
>
> > Python 2 reached EOL about a year ago thus the 'python' command may be
> > missing on some systems. 'python3' is the standard way of invoking the
> > Python 3 interpreter, thus Emacs would have a better chance trying
> > that.
> >
> > The attached patch is already carried in Ubuntu.
>
> Thanks for the report.
>
> > --- a/lisp/ldefs-boot.el
> > +++ b/lisp/ldefs-boot.el
> > @@ -26539,7 +26539,7 @@
> >
> >  (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode))
> >
> > -(autoload 'run-python "python" "\
> > +(autoload 'run-python "python3" "\
>
> This bit is wrong. Firstly, ldefs-boot is a generated file, and
> secondly, unless Ubuntu is distributing a python3.el, it would just
> break the autoload.
>
> > --- a/lisp/progmodes/python.el
> > +++ b/lisp/progmodes/python.el
> > @@ -1952,7 +1952,7 @@
> >    :group 'python
> >    :safe 'stringp)
> >
> > -(defcustom python-shell-interpreter "python"
> > +(defcustom python-shell-interpreter "python3"
>
> (if (executable-find "python3") "python3" "python")
>
> is probably how Emacs would normally handle this kind of thing.
> Or if defaulting to python3 is better (I guess it is):
>
> (cond ((executable-find "python3") "python3")
>       ((executable-find "python") "python")
>       (t "python3"))

Indeed, that would be better for very old systems.
Could you please land the proper fix or you would like me to rework mine?

Thanks,
Balint

-- 
Balint Reczey
Ubuntu & Debian Developer





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-06 17:47   ` Balint Reczey
@ 2021-01-10 14:49     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-10 14:49 UTC (permalink / raw)
  To: Balint Reczey; +Cc: Glenn Morris, 45655

Balint Reczey <balint.reczey@canonical.com> writes:

> Indeed, that would be better for very old systems.
> Could you please land the proper fix or you would like me to rework mine?

I've now installed Glenn's suggested change in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-04 15:14 bug#45655: Please use 'python3' command instead of 'python' Balint Reczey
  2021-01-06 16:59 ` Glenn Morris
@ 2021-01-10 17:42 ` Stefan Monnier
  2021-01-10 17:49   ` Balint Reczey
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2021-01-10 17:42 UTC (permalink / raw)
  To: Balint Reczey; +Cc: 45655

> Python 2 reached EOL about a year ago thus the 'python' command may be
> missing on some systems.
> 'python3' is the standard way of invoking the Python 3 interpreter,
> thus Emacs would have a better chance trying that.

At least here on Debian, `python` redirects to `python3` or `python2`
depending on some user choice (by installing either `python-is-python3`
or `python-in-python2`).

So I think it makes a lot of sense to keep using `python` rather than
`python3`.


        Stefan






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-10 17:42 ` Stefan Monnier
@ 2021-01-10 17:49   ` Balint Reczey
  2021-01-10 20:48     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Balint Reczey @ 2021-01-10 17:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 45655

Hi Stefan,

On Sun, Jan 10, 2021 at 6:42 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > Python 2 reached EOL about a year ago thus the 'python' command may be
> > missing on some systems.
> > 'python3' is the standard way of invoking the Python 3 interpreter,
> > thus Emacs would have a better chance trying that.
>
> At least here on Debian, `python` redirects to `python3` or `python2`
> depending on some user choice (by installing either `python-is-python3`
> or `python-in-python2`).
>
> So I think it makes a lot of sense to keep using `python` rather than
> `python3`.

I don't think keeping `python` is a good idea, this would make Emacs
considered to be buggy in Debian.

Please see https://wiki.debian.org/Python :
...
NOTE: Debian testing (bullseye) has removed the "python" package and
the '/usr/bin/python' symlink due to the deprecation of Python 2. No
packaged scripts should depend on the existence of '/usr/bin/python':
if they do, that is a bug that should be reported to Debian. You can
use the 'python-is-python3' or 'python-is-python2' packages to restore
an appropriate '/usr/bin/python' symlink for third-party or legacy
scripts.
...

Cheers,
Balint

-- 
Balint Reczey
Ubuntu & Debian Developer





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-10 17:49   ` Balint Reczey
@ 2021-01-10 20:48     ` Stefan Monnier
  2021-01-11  5:17       ` Pankaj Jangid
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2021-01-10 20:48 UTC (permalink / raw)
  To: Balint Reczey; +Cc: 45655

> I don't think keeping `python` is a good idea, this would make Emacs
> considered to be buggy in Debian.
>
> Please see https://wiki.debian.org/Python :
> ...
> NOTE: Debian testing (bullseye) has removed the "python" package and
> the '/usr/bin/python' symlink due to the deprecation of Python 2. No
> packaged scripts should depend on the existence of '/usr/bin/python':
> if they do, that is a bug that should be reported to Debian. You can
> use the 'python-is-python3' or 'python-is-python2' packages to restore
> an appropriate '/usr/bin/python' symlink for third-party or legacy
> scripts.
> ...

That's a very different situation, tho: what you describe is for Debian
packages, where clearly each package is written&tested to work against
a particular version (or range of versions) of Python.

In contrast the question at hand is "which version of Python should one
start when the user wants to run a Python subprocess".  I think it's
reasonable to consider that *if* there is a `python` executable in
$PATH, it makes sense to considered it as the preferred version
of Python.


        Stefan






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#45655: Please use 'python3' command instead of 'python'
  2021-01-10 20:48     ` Stefan Monnier
@ 2021-01-11  5:17       ` Pankaj Jangid
  0 siblings, 0 replies; 8+ messages in thread
From: Pankaj Jangid @ 2021-01-11  5:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Balint Reczey, 45655

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> In contrast the question at hand is "which version of Python should one
> start when the user wants to run a Python subprocess".  I think it's
> reasonable to consider that *if* there is a `python` executable in
> $PATH, it makes sense to considered it as the preferred version
> of Python.

We need to consider multiple scenarios:

1. Both, ‘python’ as well as ‘python3’ executables, are in PATH.
   1.1 ‘python’ pointing to Python v2
   1.2 ‘python’ pointing to Python v3

2. Only ‘python’ is in PATH
   - This is surely Python v2 otherwise ‘python3’ will also be in PATH

3. Only ‘python3’ is in PATH

In (2) and (3), we have only one choice to pick. The point of discussion
are (1.1) and (1.2).

In (1.2), user has somehow customized the system PATH and made Python v3
as default. So we can obey what the user wants - pick
‘python’. Although, I don’t know if there is a standard prescription on
‘python2’ executable, but on some systems this is available (macOS). In
case of (1.2), we can simply pick ‘python’.

(1.1) is the case where both Python v2 and Python v3 are installed and
we don’t know what the user wants. ‘python’ and ‘python3’ (and may be
‘python2’) are in PATH.

In (1.1), my opinion is that we should pick the version which is
officially supported by the Python Community - pick ‘python3’.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-11  5:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 15:14 bug#45655: Please use 'python3' command instead of 'python' Balint Reczey
2021-01-06 16:59 ` Glenn Morris
2021-01-06 17:47   ` Balint Reczey
2021-01-10 14:49     ` Lars Ingebrigtsen
2021-01-10 17:42 ` Stefan Monnier
2021-01-10 17:49   ` Balint Reczey
2021-01-10 20:48     ` Stefan Monnier
2021-01-11  5:17       ` Pankaj Jangid

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).