From 7707bc78180b29e3ca341c60e04d8574db1d01cf Mon Sep 17 00:00:00 2001 From: damian0815 Date: Tue, 15 Nov 2022 17:58:30 +0100 Subject: [PATCH] patch python sysconfig so that extensions (greenlet & grpcio) can build --- installer/install.sh | 15 ++++++++++++++- source_installer/install.sh | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index fe6c38fcd1..02d83042ae 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -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, diff --git a/source_installer/install.sh b/source_installer/install.sh index 747d701611..d626169800 100755 --- a/source_installer/install.sh +++ b/source_installer/install.sh @@ -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