Bug 1257095 - Bootstrapper now checks if Python interpreter is version 2.6 or 2.7 so users get a readable error instead of a stack trace. r?gps draft
authorNathan Hakkakzadeh <nhakkakzadeh@mozilla.com>
Tue, 24 May 2016 15:49:49 -0700
changeset 370554 000038843c5bacfc267f16e4a383bc5bd9ceaa6b
parent 370474 5511d54a3f172c1d68f98cc55dce4de1d0ba1b51
child 521781 deef8080cf0959342e40a727d95a6c101cd4821f
push id19096
push userbmo:nhakkakzadeh@mozilla.com
push dateTue, 24 May 2016 23:08:00 +0000
reviewersgps
bugs1257095
milestone49.0a1
Bug 1257095 - Bootstrapper now checks if Python interpreter is version 2.6 or 2.7 so users get a readable error instead of a stack trace. r?gps Should be a stopgap until bootstrapper is ported to Python 3. MozReview-Commit-ID: 2NNC3jMftr9
python/mozboot/bin/bootstrap.py
--- a/python/mozboot/bin/bootstrap.py
+++ b/python/mozboot/bin/bootstrap.py
@@ -7,22 +7,33 @@
 # the tree.
 #
 # The role of this script is to load the Python modules containing actual
 # bootstrap support. It does this through various means, including fetching
 # content from the upstream source repository.
 
 # If we add unicode_literals, optparse breaks on Python 2.6.1 (which is needed
 # to support OS X 10.6).
+
 from __future__ import print_function
 
+WRONG_PYTHON_VERSION_MESSAGE = '''
+Bootstrap currently only runs on Python 2.7 or Python 2.6. Please try re-running with python2.7 or python2.6.
+
+If these aren't available on your system, you may need to install them. Look for a "python2" or "python27" package in your package manager.
+'''
+
+import sys
+if sys.version_info[:2] not in [(2, 6), (2, 7)]:
+    print(WRONG_PYTHON_VERSION_MESSAGE)
+    sys.exit(1)
+
 import os
 import shutil
 from StringIO import StringIO
-import sys
 import tempfile
 try:
     from urllib2 import urlopen
 except ImportError:
     from urllib.request import urlopen
 import zipfile
 
 from optparse import OptionParser