mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 18:08:16 +00:00
[#3732] Switch meson.sh from venv to pyinstall to avoid venv depdendency when packaging
This commit is contained in:
parent
97968ebebb
commit
c450d69768
78
meson.sh
78
meson.sh
@ -1,5 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
# Pulls the latest meson that has fix https://github.com/mesonbuild/meson/pull/13532
|
# Pulls the latest meson that has fix https://github.com/mesonbuild/meson/pull/13532
|
||||||
# for issue https://github.com/mesonbuild/meson/issues/11322.
|
# for issue https://github.com/mesonbuild/meson/issues/11322.
|
||||||
#
|
#
|
||||||
@ -19,35 +21,59 @@ lt() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if test ! -d venv; then
|
# Change directory to Kea's top level directory.
|
||||||
# Starting with Meson 0.62, Python 3.7 is required.
|
top_level=$(cd "$(dirname "${0}")" && pwd)
|
||||||
python3=python3
|
cd "${top_level}" || exit 1
|
||||||
v=$(python3 -c 'import platform; print(platform.python_version())')
|
|
||||||
if lt "${v}" 3.7.0; then
|
if command -v meson > /dev/null 2>&1 && lt 1.7.98 "$(meson --version)"; then
|
||||||
# Search for a newer Python.
|
# Good to be used. Does not suffer from endless transitional dependency iteration.
|
||||||
if command -V compgen >/dev/null; then
|
meson='meson'
|
||||||
# shellcheck disable=SC3044
|
else
|
||||||
# SC3044 (warning): In POSIX sh, 'compgen' is undefined.
|
meson='./.meson/meson'
|
||||||
newer=$(compgen -c python3 | grep -E '^python3.[0-9]+$' | sort -V | tail -n 1)
|
if test ! -f "${meson}"; then
|
||||||
if test -n "${newer}"; then
|
# Starting with Meson 0.62, Python 3.7 is required.
|
||||||
python3="${newer}"
|
python3=python3
|
||||||
|
v=$(python3 -c 'import platform; print(platform.python_version())')
|
||||||
|
if lt "${v}" 3.7.0; then
|
||||||
|
# Search for a newer Python.
|
||||||
|
if command -V compgen >/dev/null; then
|
||||||
|
# shellcheck disable=SC3044
|
||||||
|
# SC3044 (warning): In POSIX sh, 'compgen' is undefined.
|
||||||
|
newer=$(compgen -c python3 | grep -E '^python3.[0-9]+$' | sort -V | tail -n 1)
|
||||||
|
if test -n "${newer}"; then
|
||||||
|
python3="${newer}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
v=$("${python3}" -c 'import platform; print(platform.python_version())')
|
||||||
|
printf 'Python version: %s\n' "${v}"
|
||||||
|
|
||||||
|
git clone https://github.com/mesonbuild/meson .meson-src
|
||||||
|
(
|
||||||
|
cd .meson-src || exit 1
|
||||||
|
if git tag -l | grep -E '^1.8.0$' > /dev/null 2>&1; then
|
||||||
|
git checkout 1.8.0
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
"${python3}" -m venv ./.venv
|
||||||
|
./.venv/bin/pip install --upgrade pip
|
||||||
|
|
||||||
|
./.venv/bin/pip install ninja
|
||||||
|
./.venv/bin/pip install pyinstaller
|
||||||
|
(
|
||||||
|
cd .meson-src || exit 1
|
||||||
|
"${top_level}/.venv/bin/pyinstaller" --additional-hooks-dir=packaging --clean --dist "${top_level}/.meson" --onefile ./meson.py
|
||||||
|
)
|
||||||
|
cp ./.venv/bin/ninja ./.meson/ninja
|
||||||
|
rm -fr ./.meson-src ./.venv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
v=$("${python3}" -c 'import platform; print(platform.python_version())')
|
|
||||||
printf 'Python version: %s\n' "${v}"
|
|
||||||
|
|
||||||
"${python3}" -m venv ./venv
|
|
||||||
./venv/bin/pip install --upgrade pip
|
|
||||||
|
|
||||||
# When meson 1.8 will be released, we can pin the versions.
|
|
||||||
./venv/bin/pip install git+https://github.com/mesonbuild/meson.git
|
|
||||||
./venv/bin/pip install ninja
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
if test -f "${top_level}/.meson/ninja"; then
|
||||||
# SC1091: Not following: ... was not specified as input (see shellcheck -x).
|
# To find ninja in case it went with the pyinstalled version.
|
||||||
. ./venv/bin/activate
|
export PATH="${top_level}/.meson:${PATH}"
|
||||||
|
fi
|
||||||
|
|
||||||
meson "${@}"
|
"${meson}" "${@}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user