[tbb-commits] [tor-browser-build/master] Bug 40368: Use system's python3 for building firefox

sysrqb at torproject.org sysrqb at torproject.org
Fri Dec 17 00:53:53 UTC 2021


commit 4367851afbf78b38ebaffdd635cfa2fc347ac643
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Fri Sep 24 10:12:55 2021 +0200

    Bug 40368: Use system's python3 for building firefox
    
    We still keep our build of python for the Linux builds since we are
    using an older Debian release there.
---
 projects/firefox/build             |  7 ++++---
 projects/firefox/config            |  9 +++++----
 projects/firefox/fix-info-plist.py | 10 ++++++----
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/projects/firefox/build b/projects/firefox/build
index 732da0f..0369e95 100644
--- a/projects/firefox/build
+++ b/projects/firefox/build
@@ -17,13 +17,14 @@ mkdir -p [% dest_dir _ '/' _ c('filename') %]
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/cbindgen') %]
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/nasm') %]
-tar -C /var/tmp/dist -xf [% c('input_files_by_name/python') %]
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/node') %]
-export PATH="/var/tmp/dist/rust/bin:/var/tmp/dist/cbindgen:/var/tmp/dist/nasm/bin:/var/tmp/dist/python/bin:/var/tmp/dist/node/bin:$PATH"
+export PATH="/var/tmp/dist/rust/bin:/var/tmp/dist/cbindgen:/var/tmp/dist/nasm/bin:/var/tmp/dist/node/bin:$PATH"
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/clang') %]
 export LLVM_CONFIG="/var/tmp/dist/clang/bin/llvm-config"
 
 [% IF c("var/linux") %]
+  tar -C /var/tmp/dist -xf [% c('input_files_by_name/python') %]
+  export PATH="/var/tmp/dist/python/bin:$PATH"
   tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
   export PATH="/var/tmp/dist/binutils/bin:$PATH"
   # Use clang for everything on Linux now if we don't build with ASan.
@@ -124,7 +125,7 @@ export MACH_USE_SYSTEM_PYTHON=1
   # Adjust the Info.plist file
   INFO_PLIST="$distdir/Tor Browser.app/Contents/Info.plist"
   mv "$INFO_PLIST" tmp.plist
-  python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > "$INFO_PLIST"
+  python3 $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > "$INFO_PLIST"
   rm -f tmp.plist
 [% END %]
 
diff --git a/projects/firefox/config b/projects/firefox/config
index 49a1e36..e180ee0 100644
--- a/projects/firefox/config
+++ b/projects/firefox/config
@@ -19,10 +19,6 @@ var:
     - zip
     - autoconf2.13
     - yasm
-    # We are building our own version of Python 3.6, which is required
-    # for the build. However mach still requires Python 2.7, so we
-    # install this version using the package.
-    - python
     - pkg-config
   container:
     use_container: 1
@@ -96,11 +92,15 @@ targets:
     var:
       martools_filename: mar-tools-mac64.zip
       arch_deps:
+        - python3
+        - python3-distutils
         - rsync
 
   windows:
     var:
       arch_deps:
+        - python3
+        - python3-distutils
         - wine
       compiler: mingw-w64-clang
 
@@ -142,6 +142,7 @@ input_files:
     name: nasm
   - project: python
     name: python
+    enable: '[% c("var/linux") %]'
   - project: clang
     name: clang
   - project: fxc2
diff --git a/projects/firefox/fix-info-plist.py b/projects/firefox/fix-info-plist.py
index fae29ed..4e17852 100755
--- a/projects/firefox/fix-info-plist.py
+++ b/projects/firefox/fix-info-plist.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Sets these keys in a property list file:
 #   CFBundleGetInfoString
@@ -10,7 +10,7 @@ import plistlib
 import sys
 
 def usage():
-    print >> sys.stderr, "usage: %s TORBROWSER_VERSION YEAR < Info.plist > FixedInfo.plist" % sys.argv[0]
+    print("usage: %s TORBROWSER_VERSION YEAR < Info.plist > FixedInfo.plist" % sys.argv[0], file=sys.stderr)
     sys.exit(2)
 
 _, args = getopt.gnu_getopt(sys.argv[1:], "")
@@ -23,10 +23,12 @@ YEAR = args[1]
 
 COPYRIGHT = "Tor Browser %s Copyright %s The Tor Project" % (TORBROWSER_VERSION, YEAR)
 
-plist = plistlib.readPlist(sys.stdin)
+sys.stdin = open(sys.stdin.fileno(), 'rb')
+plist = plistlib.load(sys.stdin)
 
 plist["CFBundleGetInfoString"] = "Tor Browser %s" % TORBROWSER_VERSION
 plist["CFBundleShortVersionString"] = TORBROWSER_VERSION
 plist["NSHumanReadableCopyright"] = COPYRIGHT
 
-plistlib.writePlist(plist, sys.stdout)
+sys.stdout = open(sys.stdout.fileno(), 'wb')
+plistlib.dump(plist, sys.stdout)





More information about the tbb-commits mailing list