Bug 870420 - Require Python 2.7.3+ to build; r=ted
authorGregory Szorc <gps@mozilla.com>
Thu, 05 Sep 2013 13:55:58 -0700
changeset 158690 df244fde6aa4db4f2cdbee64d202799874d24469
parent 158689 e0d08a8a1c045db566d3b1a6c6ea9a413fb291cf
child 158691 85b39648b037e8cb8375a9a515f25c69e24b51e8
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs870420
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 870420 - Require Python 2.7.3+ to build; r=ted
build/virtualenv/populate_virtualenv.py
--- a/build/virtualenv/populate_virtualenv.py
+++ b/build/virtualenv/populate_virtualenv.py
@@ -8,20 +8,36 @@
 from __future__ import print_function, unicode_literals
 
 import distutils.sysconfig
 import os
 import shutil
 import subprocess
 import sys
 
+from distutils.version import StrictVersion
+
 
 # Minimum version of Python required to build.
+MINIMUM_PYTHON_VERSION = StrictVersion('2.7.3')
 MINIMUM_PYTHON_MAJOR = 2
-MINIMUM_PYTHON_MINOR = 7
+
+
+UPGRADE_WINDOWS = '''
+Please upgrade to the latest MozillaBuild development environments. See
+https://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions/Windows_Prerequisites
+'''.lstrip()
+
+UPGRADE_OTHER = '''
+Run |mach bootstrap| to ensure your system is up to date.
+
+If you still receive this error, your shell environment is likely detecting
+another Python version. Ensure a modern Python can be found in the paths
+defined by the $PATH environment variable and try again.
+'''.lstrip()
 
 
 class VirtualenvManager(object):
     """Contains logic for managing virtualenvs for building the tree."""
 
     def __init__(self, topsrcdir, topobjdir, virtualenv_path, log_handle,
         manifest_path):
         """Create a new manager.
@@ -338,23 +354,30 @@ class VirtualenvManager(object):
         and call .ensure() and .activate() to make the virtualenv active.
         """
 
         execfile(self.activate_path, dict(__file__=self.activate_path))
 
 
 def verify_python_version(log_handle):
     """Ensure the current version of Python is sufficient."""
-    major, minor = sys.version_info[:2]
+    major, minor, micro = sys.version_info[:3]
+
+    our = StrictVersion('%d.%d.%d' % (major, minor, micro))
 
-    if major != MINIMUM_PYTHON_MAJOR or minor < MINIMUM_PYTHON_MINOR:
-        log_handle.write('Python %d.%d or greater (but not Python 3) is '
-            'required to build. ' %
-            (MINIMUM_PYTHON_MAJOR, MINIMUM_PYTHON_MINOR))
-        log_handle.write('You are running Python %d.%d.\n' % (major, minor))
+    if major != MINIMUM_PYTHON_MAJOR or our < MINIMUM_PYTHON_VERSION:
+        log_handle.write('Python %s or greater (but not Python 3) is '
+            'required to build. ' % MINIMUM_PYTHON_VERSION)
+        log_handle.write('You are running Python %s.\n' % our)
+
+        if os.name in ('nt', 'ce'):
+            log_handle.write(UPGRADE_WINDOWS)
+        else:
+            log_handle.write(UPGRADE_OTHER)
+
         sys.exit(1)
 
 
 if __name__ == '__main__':
     if len(sys.argv) < 4:
         print('Usage: populate_virtualenv.py /path/to/topsrcdir /path/to/topobjdir /path/to/virtualenv')
         sys.exit(1)