Debian Codegraph @

contrib/freeze_packages.sh

raw symbols SCIP
1 #!/bin/bash
2 # Run this after a new release to update dependencies
3
4 set -e
5
6 venv_dir=~/.electrum-venv
7 contrib="$(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=$(which python3.10) || printf ""
12 else
13 SYSTEM_PYTHON=$(which "$SYSTEM_PYTHON") || printf ""
14 fi
15 if [[ ! "$SYSTEM_PYTHON" ]] ; then
16 echo "Please specify which python to use in \$SYSTEM_PYTHON" && exit 1
17 fi
18
19 "${SYSTEM_PYTHON}" -m hashin -h > /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 rm -rf "$venv_dir"
25 "${SYSTEM_PYTHON}" -m venv "$venv_dir"
26
27 source "$venv_dir/bin/activate"
28
29 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 $(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 echo "OK."
45
46 requirements=$(pip freeze --all)
47
48 restricted=$(echo $requirements | python "$contrib/deterministic-build/find_restricted_dependencies.py")
49 if [ ! -z "$restricted" ]; then
50 python -m pip install $restricted
51 fi
52
53 echo "Generating package hashes... (${reqfile})"
54 rm -f "$contrib/deterministic-build/${reqfile}"
55 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 $(cat "$contrib/requirements/ghost.txt"); do
74 python -m pip uninstall -y $package
75 done
76 requirements=$(pip freeze --all)
77
78 echo -e "\r Hashing requirements for $reqfile..."
79 ${SYSTEM_PYTHON} -m hashin $HASHIN_FLAGS -r "$contrib/deterministic-build/${reqfile}" $requirements
80
81 echo "OK."
82 done
83
84 echo "Done. Updated requirements"