Bug 1451065 - Attempt to install Python 3 on Debian distros; r=mshal
authorGregory Szorc <gps@mozilla.com>
Tue, 03 Apr 2018 10:57:07 -0700
changeset 468166 6c443e883ed488963fb70d1c7ed981ef5b30d9d3
parent 468165 835775164d3f17d4965347b9384f05a7be801853
child 468167 af5755fcc4882a24fa25402a7035796dc9a6258c
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1451065
milestone61.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 1451065 - Attempt to install Python 3 on Debian distros; r=mshal Not all distros will have a "python3" package. But the modern ones should. Because many people install Python via other means, we only install the system packages if a Python 3 executable can't be found. MozReview-Commit-ID: 2ni7Ha92cRD
python/mozboot/mozboot/debian.py
--- a/python/mozboot/mozboot/debian.py
+++ b/python/mozboot/mozboot/debian.py
@@ -95,17 +95,32 @@ class DebianBootstrapper(StyloInstall, B
         self.packages = self.COMMON_PACKAGES + self.DISTRO_PACKAGES
         if self.distro == 'Debian' or self.distro == 'debian':
             self.packages += self.DEBIAN_PACKAGES
         self.browser_packages = self.BROWSER_COMMON_PACKAGES + self.BROWSER_DISTRO_PACKAGES
         self.mobile_android_packages = self.MOBILE_ANDROID_COMMON_PACKAGES + \
             self.MOBILE_ANDROID_DISTRO_PACKAGES
 
     def install_system_packages(self):
-        self.apt_install(*self.packages)
+        # Python 3 may not be present on all distros. Search for it and
+        # install if found.
+        packages = list(self.packages)
+
+        have_python3 = any([self.which('python3'), self.which('python3.6'),
+                            self.which('python3.5')])
+
+        if not have_python3:
+            python3_packages = self.check_output([
+                'apt-cache', 'pkgnames', 'python3'])
+            python3_packages = python3_packages.splitlines()
+
+            if 'python3' in python3_packages:
+                packages.extend(['python3', 'python3-dev'])
+
+        self.apt_install(*packages)
 
     def install_browser_packages(self):
         self.ensure_browser_packages()
 
     def install_browser_artifact_mode_packages(self):
         self.ensure_browser_packages(artifact_mode=True)
 
     def install_mobile_android_packages(self):