Skip to content

Commit

Permalink
Solving darwing issues with python.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jan 23, 2024
1 parent 904bbee commit 12b6833
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/metacall-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,25 @@ BUILD_ADDRESS_SANITIZER=0
BUILD_THREAD_SANITIZER=0
BUILD_MEMORY_SANITIZER=0

# Operative System detection
case "$(uname -s)" in
Linux*) OPERATIVE_SYSTEM=Linux;;
Darwin*) OPERATIVE_SYSTEM=Darwin;;
CYGWIN*) OPERATIVE_SYSTEM=Cygwin;;
MINGW*) OPERATIVE_SYSTEM=MinGW;;
*) OPERATIVE_SYSTEM="Unknown"
esac

# Linux Distro detection
if [ -f /etc/os-release ]; then # Either Debian or Ubuntu
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces
LINUX_DISTRO=$(cat /etc/os-release | grep "^ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces | Remove quotes
LINUX_VERSION_ID=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d '"')
else
# TODO: Implement more distros or better detection
LINUX_DISTRO=unknown
LINUX_VERSION_ID=unknown
fi

sub_options() {
Expand Down Expand Up @@ -213,6 +225,12 @@ sub_configure() {
if [ $BUILD_PYTHON = 1 ]; then
BUILD_STRING="$BUILD_STRING -DOPTION_BUILD_LOADERS_PY=On"

# Patch for Darwin Python headers
if [ "${OPERATIVE_SYSTEM}" = "Darwin" ]; then
BUILD_STRING="$BUILD_STRING -DPython3_INCLUDE_DIR=$(python3 -c \"import sysconfig; print(sysconfig.get_path('include'))\")"
# BUILD_STRING="$BUILD_STRING -DPython3_LIBRARY=$(python3 -c \"import sysconfig; print(sysconfig.get_config_var('LIBDIR'))\")"
fi

if [ $BUILD_SCRIPTS = 1 ]; then
BUILD_STRING="$BUILD_STRING -DOPTION_BUILD_SCRIPTS_PY=On"
fi
Expand Down

0 comments on commit 12b6833

Please sign in to comment.