2019-11-19 21:51:45 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
failure_exit() {
|
|
|
|
echo >&2 "Could not find ${1}. Please install that before continuing."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-12-07 23:19:16 +00:00
|
|
|
check_python_version() {
|
2024-01-26 05:29:27 +00:00
|
|
|
if [ -z "$PYMAJOR$PYMINOR" ]; then
|
|
|
|
echo >&2 "$0: This script expects that environment variables PYMAJOR and PYMINOR are set; skipping check_python_version"
|
|
|
|
return
|
|
|
|
fi
|
2022-03-08 05:51:20 +00:00
|
|
|
if ! command -v python"$PYMAJOR"."$PYMINOR" &> /dev/null; then
|
2022-03-04 03:13:58 +00:00
|
|
|
echo >&2 "Must compile with python $PYMAJOR.$PYMINOR."
|
2020-12-07 23:19:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2024-01-26 05:29:27 +00:00
|
|
|
|
2019-11-19 21:51:45 +00:00
|
|
|
check_python_headers() {
|
2024-01-26 05:29:27 +00:00
|
|
|
if [ -z "$PYMAJOR$PYMINOR" ]; then
|
|
|
|
echo >&2 "$0: This script expects that environment variables PYMAJOR and PYMINOR are set; skipping check_python_headers"
|
|
|
|
return
|
|
|
|
fi
|
2019-11-19 21:51:45 +00:00
|
|
|
local python_headers_present
|
2022-03-08 05:51:20 +00:00
|
|
|
python_headers_present=$(pkg-config --libs python-"$PYMAJOR"."$PYMINOR")
|
2019-11-19 21:51:45 +00:00
|
|
|
|
|
|
|
if [ ! "${python_headers_present}" ]; then
|
2022-03-04 03:13:58 +00:00
|
|
|
failure_exit "Python $PYMAJOR.$PYMINOR headers"
|
2019-11-19 21:51:45 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_binary_present() {
|
|
|
|
local binary_exists
|
|
|
|
binary_exists="$(command -v "${1}")"
|
|
|
|
if [ ! "${binary_exists}" ]; then
|
|
|
|
failure_exit "${1}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-01-02 22:42:43 +00:00
|
|
|
check_pkgconfig() {
|
|
|
|
check_binary_present "pkg-config"
|
|
|
|
}
|
|
|
|
|
2022-04-09 20:41:10 +00:00
|
|
|
check_shasum() {
|
|
|
|
check_binary_present "shasum"
|
2021-06-04 07:36:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-28 15:27:56 +00:00
|
|
|
check_cmake() {
|
|
|
|
check_binary_present "cmake"
|
|
|
|
}
|
|
|
|
|
2023-03-08 20:22:59 +00:00
|
|
|
check_sed() {
|
|
|
|
check_binary_present "sed"
|
|
|
|
gnu_sed_found=$(sed --help | grep -q gnu.org)
|
|
|
|
|
|
|
|
if [ "${gnu_sed_found}" ]; then
|
|
|
|
echo >&2 "Pyodide requires GNU sed."
|
|
|
|
echo >&2 "If you are on macOS you can install it with 'brew install gnu-sed' and then add it to your PATH."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_patch() {
|
|
|
|
check_binary_present "patch"
|
|
|
|
gnu_patch_found=$(patch --help | grep -q gnu.org)
|
|
|
|
|
|
|
|
if [ "${gnu_patch_found}" ]; then
|
|
|
|
echo >&2 "Pyodide requires GNU patch."
|
|
|
|
echo >&2 "If you are on macOS you can install it with 'brew install gpatch' and then add it to your PATH."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-07 23:19:16 +00:00
|
|
|
check_python_version
|
2020-01-02 22:42:43 +00:00
|
|
|
check_pkgconfig
|
2022-06-30 04:22:03 +00:00
|
|
|
check_cmake
|
2023-03-08 20:22:59 +00:00
|
|
|
check_sed
|
|
|
|
check_patch
|
2020-07-07 14:21:33 +00:00
|
|
|
#check_python_headers
|
2022-04-09 20:41:10 +00:00
|
|
|
check_shasum
|