Patchwork [STABLE] setup: tweak error message for Python 3

login
register
mail settings
Submitter Gregory Szorc
Date April 21, 2019, 3:57 p.m.
Message ID <8211a51e17c85b80e39f.1555862232@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/39781/
State Accepted
Headers show

Comments

Gregory Szorc - April 21, 2019, 3:57 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1555862221 25200
#      Sun Apr 21 08:57:01 2019 -0700
# Branch stable
# Node ID 8211a51e17c85b80e39f68668798a91323242e9a
# Parent  07faf5c65190f8fcc92c0a6663f8b9d223c4ebaa
setup: tweak error message for Python 3

We now have beta support for Python 3. In my opinion, it isn't
yet stable enough to allow `pip install Mercurial` to work with
Python 3 out of the box: we don't want people accidentally using
Mercurial with Python 3 just yet.

But I do think we should be more friendly about informing people
of their options.

This commit tweaks the error message that users see when running
setup.py with Python 3. We instruct them about the current level
of Python 3 support, point them at the wiki for more info, and
give them instructions on how to bypass the check.

As part of this, I also changed which version value is printed,
as we were printing a named tuple before.
Yuya Nishihara - April 21, 2019, 10:08 p.m.
On Sun, 21 Apr 2019 08:57:12 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1555862221 25200
> #      Sun Apr 21 08:57:01 2019 -0700
> # Branch stable
> # Node ID 8211a51e17c85b80e39f68668798a91323242e9a
> # Parent  07faf5c65190f8fcc92c0a6663f8b9d223c4ebaa
> setup: tweak error message for Python 3

Queued for stable, thanks.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -85,10 +85,21 @@  if sys.version_info[0] != 2:
 
     if badpython:
         error = """
-Mercurial only supports Python 2.7.
 Python {py} detected.
-Please re-run with Python 2.7.
-""".format(py=sys.version_info)
+
+Mercurial currently has beta support for Python 3 and use of Python 2.7 is
+recommended for the best experience.
+
+Please re-run with Python 2.7 for a faster, less buggy experience.
+
+If you would like to beta test Mercurial with Python 3, this error can
+be suppressed by defining the HGPYTHON3 environment variable when invoking
+this command. No special environment variables or configuration changes are
+necessary to run `hg` with Python 3.
+
+See https://www.mercurial-scm.org/wiki/Python3 for more on Mercurial's
+Python 3 support.
+""".format(py='.'.join('%d' % x for x in sys.version_info[0:2]))
 
         printf(error, file=sys.stderr)
         sys.exit(1)