pyodide/tools/dependency-check.sh

81 lines
1.9 KiB
Bash
Raw Normal View History

#!/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() {
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
if ! command -v python"$PYMAJOR"."$PYMINOR" &> /dev/null; then
echo >&2 "Must compile with python $PYMAJOR.$PYMINOR."
2020-12-07 23:19:16 +00:00
exit 1
fi
}
check_python_headers() {
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
local python_headers_present
python_headers_present=$(pkg-config --libs python-"$PYMAJOR"."$PYMINOR")
if [ ! "${python_headers_present}" ]; then
failure_exit "Python $PYMAJOR.$PYMINOR headers"
fi
}
check_binary_present() {
local binary_exists
binary_exists="$(command -v "${1}")"
if [ ! "${binary_exists}" ]; then
failure_exit "${1}"
fi
}
check_pkgconfig() {
check_binary_present "pkg-config"
}
check_shasum() {
check_binary_present "shasum"
}
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
check_pkgconfig
check_cmake
2023-03-08 20:22:59 +00:00
check_sed
check_patch
#check_python_headers
check_shasum