patch python sysconfig so that extensions (greenlet & grpcio) can build

This commit is contained in:
damian0815 2022-11-15 17:58:30 +01:00
parent 4c035ad4ae
commit 7707bc7818
2 changed files with 15 additions and 2 deletions

View File

@ -29,7 +29,7 @@ OS_NAME=$(uname -s)
case "${OS_NAME}" in
Linux*) OS_NAME="linux";;
Darwin*) OS_NAME="darwin";;
*) echo -e "\n----- Unknown OS: $OS_NAME! This script runs only on Linux or MacOS -----\n" && exit
*) echo -e "\n----- Unknown OS: $OS_NAME! This script runs only on Linux or macOS -----\n" && exit
esac
OS_ARCH=$(uname -m)
@ -154,6 +154,19 @@ echo -e "\n***** Unpacked python-build-standalone *****\n"
# create venv
_err_msg="\n----- problem creating venv -----\n"
if [ "$OS_NAME" == "darwin" ]; then
# patch sysconfig so that extensions can build properly
# adapted from https://github.com/cashapp/hermit-packages/commit/fcba384663892f4d9cfb35e8639ff7a28166ee43
PYTHON_INSTALL_DIR="$(pwd)/python"
SYSCONFIG="$(echo python/lib/python*/_sysconfigdata_*.py)"
TMPFILE="$(mktemp)"
chmod +w "${SYSCONFIG}"
cp "${SYSCONFIG}" "${TMPFILE}"
sed "s,'/install,'${PYTHON_INSTALL_DIR},g" "${TMPFILE}" > "${SYSCONFIG}"
rm -f ${TMPFILE}
fi
./python/bin/python3 -E -s -m venv .venv
_err_exit $? _err_msg
# In reality, the following is ALL that 'activate.bat' does,

View File

@ -95,7 +95,7 @@ source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains abou
conda activate
if [ "$OS_NAME" == "mac" ]; then
echo "Macintosh system detected. Installing MPS and CPU support."
echo "macOS detected. Installing MPS and CPU support."
ln -sf environments-and-requirements/environment-mac.yml environment.yml
else
if (lsmod | grep amdgpu) &>/dev/null ; then