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 147795 28214460272816ae950284b6776801484bd3ebcb
parent 147794 9a1397d11937b14f3ca70fe9d19627a244a68b65
child 147796 9bce276f9c2d00cd43a65cc0297e24b1ce55f097
push id25317
push useremorley@mozilla.com
push dateThu, 19 Sep 2013 14:37:38 +0000
treeherdermozilla-central@70a765607344 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs870420
milestone27.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
old mode 100755
new mode 100644
--- a/build/virtualenv/populate_virtualenv.py
+++ b/build/virtualenv/populate_virtualenv.py
@@ -9,20 +9,36 @@ from __future__ import print_function, u
 
 import distutils.sysconfig
 import os
 import shutil
 import subprocess
 import sys
 import warnings
 
+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 environment. 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.
@@ -366,23 +382,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)