From bb79a7746da50bbfe5858528d96a708a6d07d4dc Mon Sep 17 00:00:00 2001 From: Ahmed Ihab <57008633+ahmedihabb2@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:09:08 +0200 Subject: [PATCH] feat: Build with Python support for MacOS (#391) * feat: Build with Python support for MacOS * set python paths * fix build with python [skip ci] * Update metacall-environment-macos.sh --------- Co-authored-by: Vicente Eduardo Ferrer Garcia <7854099+viferga@users.noreply.github.com> --- .github/workflows/macos-test.yml | 19 ++++++++++++------- tools/metacall-environment-macos.sh | 12 ++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml index a2ae0410e..02c4ecde1 100644 --- a/.github/workflows/macos-test.yml +++ b/.github/workflows/macos-test.yml @@ -5,7 +5,7 @@ on: pull_request: push: tags: - - 'v*.*.*' + - "v*.*.*" branches: - master - develop @@ -18,11 +18,11 @@ jobs: strategy: matrix: buildtype: [debug] # TODO: [debug, release] - + env: LTTNG_UST_REGISTER_TIMEOUT: 0 NUGET_XMLDOC_MODE: skip - DOTNET_CLI_TELEMETRY_OPTOUT: 'true' + DOTNET_CLI_TELEMETRY_OPTOUT: "true" steps: - name: Check out the repository @@ -30,13 +30,13 @@ jobs: with: fetch-depth: 0 - - name: Uninstall NodeJS and NPM + - name: Uninstall NodeJS and NPM run: | npm uninstall npm -g rm -rf /usr/local/lib/node_modules/npm # TODO: This must go in metacall-environment-macos.sh as base dependencies - - name: Configure Clang + - name: Configure Clang run: | brew install llvm cmake git wget gnupg ca-certificates @@ -51,13 +51,18 @@ jobs: cd build bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS env: - METACALL_CONFIGURE_OPTIONS: ${{ matrix.buildtype }} scripts ports tests sanitizer # nodejs python java sanitizer ruby netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage + METACALL_CONFIGURE_OPTIONS: ${{ matrix.buildtype }} scripts ports tests sanitizer python # nodejs python java sanitizer ruby netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage - name: Build working-directory: ./build # TODO: Remove the disable option for fork safe once funchook problem is solved run: | - cmake -DOPTION_FORK_SAFE=OFF .. + cmake -DOPTION_FORK_SAFE=OFF \ + -DPython_INCLUDE_DIRS="$HOME/.pyenv/versions/3.11.1/include/python3.11" \ + -DPython_LIBRARY="$HOME/.pyenv/versions/3.11.1/lib/libpython3.11.dylib" \ + -DPython_EXECUTABLE="$HOME/.pyenv/versions/3.11.1/bin/python3.11" \ + -DPython_ROOT="$HOME/.pyenv/versions/3.11.1" \ + -DPython_VERSION="3.11.1" .. bash ../tools/metacall-build.sh $METACALL_BUILD_OPTIONS env: METACALL_BUILD_OPTIONS: ${{ matrix.buildtype }} tests diff --git a/tools/metacall-environment-macos.sh b/tools/metacall-environment-macos.sh index b684603f9..1d400057a 100755 --- a/tools/metacall-environment-macos.sh +++ b/tools/metacall-environment-macos.sh @@ -44,8 +44,16 @@ sub_swig() { # Python sub_python() { - echo "configuring python" - brew install python3 python3-pip + echo "configuring python" + brew install pyenv openssl + export PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig + export PYTHON_CONFIGURE_OPTS="--enable-shared" + pyenv install 3.11.1 + pyenv global 3.11.1 + pyenv rehash + echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile + source ~/.bash_profile + which python3 pip3 install requests pip3 install setuptools pip3 install wheel