Bug 1451065 - Attempt to install Python 3 on Debian distros; r?Build draft
authorGregory Szorc <gps@mozilla.com>
Tue, 03 Apr 2018 10:57:07 -0700
changeset 784786 4d12cbb6ea1801f2bc52838c0a8f79935ccff6e0
parent 784785 e9f596f0a4351e71a36c66969af52b7d512cde15
child 784787 03cdb1453f35d485dd04bda7b82bc49de56bc601
push id107028
push userbmo:gps@mozilla.com
push dateThu, 19 Apr 2018 00:46:23 +0000
reviewersBuild
bugs1451065
milestone61.0a1
Bug 1451065 - Attempt to install Python 3 on Debian distros; r?Build 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):