setup.py
branchstable
changeset 36386 fb39f6a8a864
parent 35774 854a7315603e
child 36398 eb73f8a6177e
--- a/setup.py	Wed Feb 21 16:51:09 2018 -0500
+++ b/setup.py	Fri Feb 23 17:57:04 2018 -0800
@@ -67,6 +67,26 @@
     printf(error, file=sys.stderr)
     sys.exit(1)
 
+# We don't yet officially support Python 3. But we want to allow developers to
+# hack on. Detect and disallow running on Python 3 by default. But provide a
+# backdoor to enable working on Python 3.
+if sys.version_info[0] != 2:
+    badpython = True
+
+    # Allow Python 3 from source checkouts.
+    if os.path.isdir('.hg'):
+        badpython = False
+
+    if badpython:
+        error = """
+Mercurial only supports Python 2.7.
+Python {py} detected.
+Please re-run with Python 2.7.
+""".format(py=sys.version_info)
+
+        printf(error, file=sys.stderr)
+        sys.exit(1)
+
 # Solaris Python packaging brain damage
 try:
     import hashlib