GNU bug report logs - #45655
Please use 'python3' command instead of 'python'

Previous Next

Package: emacs;

Reported by: Balint Reczey <balint.reczey <at> canonical.com>

Date: Mon, 4 Jan 2021 15:50:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45655 in the body.
You can then email your comments to 45655 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Mon, 04 Jan 2021 15:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Balint Reczey <balint.reczey <at> canonical.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 04 Jan 2021 15:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Balint Reczey <balint.reczey <at> canonical.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Please use 'python3' command instead of 'python'
Date: Mon, 4 Jan 2021 16:14:02 +0100
[Message part 1 (text/plain, inline)]
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
[python3-as-default.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Wed, 06 Jan 2021 17:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Balint Reczey <balint.reczey <at> canonical.com>
Cc: 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Wed, 06 Jan 2021 11:59:28 -0500
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"))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Wed, 06 Jan 2021 17:56:02 GMT) Full text and rfc822 format available.

Message #11 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Balint Reczey <balint.reczey <at> canonical.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Wed, 6 Jan 2021 18:47:48 +0100
Hi Glenn,

Thanks for the quick response.

On Wed, Jan 6, 2021 at 5:59 PM Glenn Morris <rgm <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Sun, 10 Jan 2021 14:50:02 GMT) Full text and rfc822 format available.

Message #14 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Balint Reczey <balint.reczey <at> canonical.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Sun, 10 Jan 2021 15:49:25 +0100
Balint Reczey <balint.reczey <at> 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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 14:50:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 45655 <at> debbugs.gnu.org and Balint Reczey <balint.reczey <at> canonical.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 14:50:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Sun, 10 Jan 2021 17:43:01 GMT) Full text and rfc822 format available.

Message #21 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Balint Reczey <balint.reczey <at> canonical.com>
Cc: 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Sun, 10 Jan 2021 12:42:38 -0500
> 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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Sun, 10 Jan 2021 17:50:02 GMT) Full text and rfc822 format available.

Message #24 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Balint Reczey <balint.reczey <at> canonical.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Sun, 10 Jan 2021 18:49:06 +0100
Hi Stefan,

On Sun, Jan 10, 2021 at 6:42 PM Stefan Monnier <monnier <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Sun, 10 Jan 2021 20:50:02 GMT) Full text and rfc822 format available.

Message #27 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Balint Reczey <balint.reczey <at> canonical.com>
Cc: 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Sun, 10 Jan 2021 15:48:52 -0500
> 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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45655; Package emacs. (Mon, 11 Jan 2021 05:19:02 GMT) Full text and rfc822 format available.

Message #30 received at 45655 <at> debbugs.gnu.org (full text, mbox):

From: Pankaj Jangid <pankaj <at> codeisgreat.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Balint Reczey <balint.reczey <at> canonical.com>, 45655 <at> debbugs.gnu.org
Subject: Re: bug#45655: Please use 'python3' command instead of 'python'
Date: Mon, 11 Jan 2021 10:47:59 +0530
Stefan Monnier <monnier <at> 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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Feb 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.