| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Run this after a new release to update dependencies |
| 3 | |
| 4 | set -e |
| 5 | |
| 6 | venv_dir=~/.electrum-venv |
| 7 | contrib="$(dirnamescip-shell system . . dirname. "$0")" |
| 8 | |
| 9 | # note: we should not use a higher version of python than what the binaries bundle |
| 10 | if [[ ! "$SYSTEM_PYTHON" ]] ; then |
| 11 | SYSTEM_PYTHON=$(whichscip-shell system . . which. python3.10) || printfscip-shell system . . printf. "" |
| 12 | else |
| 13 | SYSTEM_PYTHON=$(whichscip-shell system . . which. "$SYSTEM_PYTHON") || printfscip-shell system . . printf. "" |
| 14 | fi |
| 15 | if [[ ! "$SYSTEM_PYTHON" ]] ; then |
| 16 | echoscip-shell system . . echo. "Please specify which python to use in \$SYSTEM_PYTHON" && exit 1 |
| 17 | fi |
| 18 | |
| 19 | "${SYSTEM_PYTHON}" -m hashin -h > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || { "${SYSTEM_PYTHON}" -m pip install hashin; } |
| 20 | |
| 21 | for suffix in '' '-hw' '-binaries' '-binaries-mac' '-build-wine' '-build-mac' '-build-base' '-build-appimage' '-build-android'; do |
| 22 | reqfile="requirements${suffix}.txt" |
| 23 | |
| 24 | rmscip-shell system . . rm. -rf "$venv_dir" |
| 25 | "${SYSTEM_PYTHON}" -m venv "$venv_dir" |
| 26 | |
| 27 | source "$venv_dir/bin/activate" |
| 28 | |
| 29 | echoscip-shell system . . echo. "Installing dependencies... (${reqfile})" |
| 30 | |
| 31 | # We pin all python packaging tools (pip and friends). Some of our dependencies might |
| 32 | # pull some of them in (e.g. protobuf->setuptools), and all transitive dependencies |
| 33 | # must be pinned, so we might as well pin all packaging tools. This however means |
| 34 | # that we should explicitly install them now, so that we pin latest versions if possible. |
| 35 | python -m pip install --upgrade pip setuptools wheel |
| 36 | |
| 37 | # install ghost packages to satisfy dependency resolvers |
| 38 | for package in $(catscip-shell system . . cat. "$contrib/requirements/ghost.txt"); do |
| 39 | python "$contrib/install_ghost.py" "$package" |
| 40 | done |
| 41 | |
| 42 | python -m pip install -r "$contrib/requirements/${reqfile}" --upgrade |
| 43 | |
| 44 | echoscip-shell system . . echo. "OK." |
| 45 | |
| 46 | requirements=$(pipscip-shell system . . pip. freeze --all) |
| 47 | |
| 48 | restricted=$(echoscip-shell system . . echo. $requirements | python "$contrib/deterministic-build/find_restricted_dependencies.py") |
| 49 | if [scip-shell system . . `[`. ! -z "$restricted" ]; then |
| 50 | python -m pip install $restricted |
| 51 | fi |
| 52 | |
| 53 | echoscip-shell system . . echo. "Generating package hashes... (${reqfile})" |
| 54 | rmscip-shell system . . rm. -f "$contrib/deterministic-build/${reqfile}" |
| 55 | touchscip-shell system . . touch. "$contrib/deterministic-build/${reqfile}" |
| 56 | |
| 57 | # restrict ourselves to source-only packages. |
| 58 | # TODO expand this to all reqfiles... |
| 59 | HASHIN_FLAGS="" |
| 60 | if [[ |
| 61 | "${suffix}" == "" || |
| 62 | "${suffix}" == "-build-wine" || |
| 63 | "${suffix}" == "-build-mac" || |
| 64 | "${suffix}" == "-build-appimage" || |
| 65 | "${suffix}" == "-build-android" || |
| 66 | "0" == "1" |
| 67 | ]] ; |
| 68 | then |
| 69 | HASHIN_FLAGS="--python-version source" |
| 70 | fi |
| 71 | |
| 72 | # remove ghost packages before hashin step, so that they aren't hashed |
| 73 | for package in $(catscip-shell system . . cat. "$contrib/requirements/ghost.txt"); do |
| 74 | python -m pip uninstall -y $package |
| 75 | done |
| 76 | requirements=$(pipscip-shell system . . pip. freeze --all) |
| 77 | |
| 78 | echoscip-shell system . . echo. -e "\r Hashing requirements for $reqfile..." |
| 79 | ${SYSTEM_PYTHON} -m hashin $HASHIN_FLAGS -r "$contrib/deterministic-build/${reqfile}" $requirements |
| 80 | |
| 81 | echoscip-shell system . . echo. "OK." |
| 82 | done |
| 83 | |
| 84 | echoscip-shell system . . echo. "Done. Updated requirements" |