Bug 1821117 [wpt PR 38888] - Expose desired{Execution|Render}Start in LoAF+ScriptTimi...
[gecko.git] / taskcluster / scripts / misc / build-cpython.sh
blobb6b99168132a846ecdc142dd6d9080c0cd12bca1
1 #!/bin/sh
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 # This script builds the official interpreter for the python language,
7 # while also packing in a few default extra packages.
9 set -e
10 set -x
12 # Required fetch artifact
13 clang_bindir=${MOZ_FETCHES_DIR}/clang/bin
14 clang_libdir=${MOZ_FETCHES_DIR}/clang/lib
15 python_src=${MOZ_FETCHES_DIR}/cpython-source
17 # Setup environment
18 export PATH=${clang_bindir}:${PATH}
19 export CC=clang
20 export CXX=clang++
21 export LDFLAGS=-fuse-ld=lld
23 # Extra setup for OSX
24 case `uname -s` in
25 Darwin)
26 case `uname -m` in
27 aarch64)
28 macosx_version_min=11.0
31 macosx_version_min=10.12
33 esac
34 macosx_sdk=13.0
35 # NOTE: both CFLAGS and CPPFLAGS need to be set here, otherwise
36 # configure step fails.
37 sysroot_flags="-isysroot ${MOZ_FETCHES_DIR}/MacOSX${macosx_sdk}.sdk -mmacosx-version-min=${macosx_version_min}"
38 export CPPFLAGS=${sysroot_flags}
39 export CFLAGS=${sysroot_flags}
40 export LDFLAGS="${LDFLAGS} ${sysroot_flags}"
41 configure_flags_extra=--with-openssl=/usr/local/opt/openssl
43 # see https://bugs.python.org/issue44065
44 sed -i -e 's,$CC --print-multiarch,:,' ${python_src}/configure
46 esac
48 # Patch Python to honor MOZPYTHONHOME instead of PYTHONHOME. That way we have a
49 # relocatable python for free, while not interfering with the system Python that
50 # already honors PYTHONHOME.
51 find ${python_src} -type f -print0 | xargs -0 perl -i -pe "s,PYTHONHOME,MOZPYTHONHOME,g"
53 # Actual build
54 work_dir=`pwd`
55 tardir=python
57 cd `mktemp -d`
58 ${python_src}/configure --prefix=/${tardir} --enable-optimizations ${configure_flags_extra} || { exit_status=$? && cat config.log && exit $exit_status ; }
59 export MAKEFLAGS=-j`nproc`
60 make
61 make DESTDIR=${work_dir} install
62 cd ${work_dir}
64 ${work_dir}/python/bin/python3 -m pip install --upgrade pip==23.0
65 ${work_dir}/python/bin/python3 -m pip install -r ${GECKO_PATH}/build/psutil_requirements.txt -r ${GECKO_PATH}/build/zstandard_requirements.txt
67 $(dirname $0)/pack.sh ${tardir}