| 1 | #!/bin/bash |
| 2 | # This script installs our pure python dependencies into the 'packages' folder. |
| 3 | |
| 4 | set -e |
| 5 | |
| 6 | CONTRIB="$(dirname "$(readlink -e "$0")")" |
| 7 | PROJECT_ROOT="$CONTRIB"/.. |
| 8 | PACKAGES="$PROJECT_ROOT"/packages/ |
| 9 | |
| 10 | test -n "$CONTRIB" -a -d "$CONTRIB" || exit |
| 11 | cd "$CONTRIB" |
| 12 | |
| 13 | if [ -d "$PACKAGES" ]; then |
| 14 | rm -r "$PACKAGES" |
| 15 | fi |
| 16 | |
| 17 | # create virtualenv |
| 18 | # note: venv path needs to be deterministic as some produced files will contain it |
| 19 | venv_dir="$CONTRIB/.venv_make_packages/" |
| 20 | rm -rf "$venv_dir" |
| 21 | python3 -m venv "$venv_dir" |
| 22 | source "$venv_dir"/bin/activate |
| 23 | |
| 24 | # installing pinned build-time requirements, such as pip/wheel/setuptools |
| 25 | python3 -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \ |
| 26 | -r "$CONTRIB"/deterministic-build/requirements-build-base.txt |
| 27 | |
| 28 | # opt out of compiling C extensions |
| 29 | export AIOHTTP_NO_EXTENSIONS=1 |
| 30 | export YARL_NO_EXTENSIONS=1 |
| 31 | export MULTIDICT_NO_EXTENSIONS=1 |
| 32 | export FROZENLIST_NO_EXTENSIONS=1 |
| 33 | export PROPCACHE_NO_EXTENSIONS=1 |
| 34 | |
| 35 | export ELECTRUM_ECC_DONT_COMPILE=1 |
| 36 | |
| 37 | # see https://github.com/python-websockets/websockets/blob/e6d0ea1d6b13a979924329d02fb82f79d82c7236/setup.py#L22 |
| 38 | export BUILD_EXTENSION="no" |
| 39 | |
| 40 | |
| 41 | # if we end up having to compile something, at least give reproducibility a fighting chance |
| 42 | export LC_ALL=C |
| 43 | export TZ=UTC |
| 44 | export SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct 2>/dev/null || printf 1530212462)" |
| 45 | export PYTHONHASHSEED="$SOURCE_DATE_EPOCH" |
| 46 | export BUILD_DATE="$(LC_ALL=C TZ=UTC date +'%b %e %Y' -d @$SOURCE_DATE_EPOCH)" |
| 47 | export BUILD_TIME="$(LC_ALL=C TZ=UTC date +'%H:%M:%S' -d @$SOURCE_DATE_EPOCH)" |
| 48 | |
| 49 | # FIXME aiohttp will compile some .so files using distutils |
| 50 | # (until https://github.com/aio-libs/aiohttp/pull/4079 gets released), |
| 51 | # which are not reproducible unless using at least python 3.9 |
| 52 | # (as it needs https://github.com/python/cpython/commit/0d30ae1a03102de07758650af9243fd31211325a). |
| 53 | # Hence "aiohttp-*.dist-info/" is not reproducible either. |
| 54 | # All this means that downstream users of this script, such as the sdist build |
| 55 | # and the android apk build need to make sure these files get excluded. |
| 56 | # note: --no-build-isolation is needed so that pip uses the locally available setuptools and wheel, |
| 57 | # instead of downloading the latest ones |
| 58 | python3 -m pip install --no-build-isolation --no-compile --no-dependencies --no-binary :all: \ |
| 59 | -r "$CONTRIB"/deterministic-build/requirements.txt -t "$PACKAGES" |
| 60 | |
| 61 | echo "Pure-python dependencies have been placed into $PACKAGES" |