From 5771cad7e4d9000f99722b0f778e48e324947abf Mon Sep 17 00:00:00 2001 From: Tolya Korniltsev Date: Mon, 15 Apr 2024 13:38:47 +0700 Subject: [PATCH] fix: python wheel incorrect architecture on mac (#162) --- .github/workflows/release.yml | 9 ++++----- ffi.mk | 18 ++++++++++-------- pyroscope_ffi/python/setup.cfg | 2 +- pyroscope_ffi/python/setup.py | 6 +++++- pyroscope_ffi/ruby/lib/pyroscope/version.rb | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a48d4b2..3f5add8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -195,7 +195,7 @@ jobs: with: python-version: 3.11 - - run: make wheel/mac/${{ matrix.mk-arch }} + - run: make pyroscope_ffi/clean wheel/mac/${{ matrix.mk-arch }} - uses: actions/upload-artifact@v2 with: @@ -314,9 +314,6 @@ jobs: name: macOS - ${{ matrix.target }} runs-on: macos-${{ matrix.macos-version }} - env: - RUST_TARGET: ${{ matrix.target }} - steps: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 @@ -328,7 +325,9 @@ jobs: target: ${{ matrix.target }} profile: minimal override: true - - run: make gem/mac/${{ matrix.mk-arch }} + + - run: make pyroscope_ffi/clean gem/mac/${{ matrix.mk-arch }} + - uses: actions/upload-artifact@v2 with: name: ${{ github.sha }} diff --git a/ffi.mk b/ffi.mk index 716dcc9..9ff25cd 100644 --- a/ffi.mk +++ b/ffi.mk @@ -33,13 +33,15 @@ wheel/linux/arm64: pyroscope_ffi/clean wheel/mac/amd64: cd pyroscope_ffi/python && \ pip install wheel && \ - python setup.py bdist_wheel -p macosx-11_0_x86_64 + CARGO_BUILD_TARGET=x86_64-apple-darwin \ + python setup.py bdist_wheel -p macosx-11_0_x86_64 .phony: wheel/mac/arm64 wheel/mac/arm64: cd pyroscope_ffi/python && \ pip install wheel && \ - python setup.py bdist_wheel -p macosx-11_0_arm64 + CARGO_BUILD_TARGET=aarch64-apple-darwin \ + python setup.py bdist_wheel -p macosx-11_0_arm64 .phony: gem/linux/amd64 @@ -66,14 +68,14 @@ gem/linux/arm64: pyroscope_ffi/clean gem/mac/amd64: pyroscope_ffi/clean cd pyroscope_ffi/ruby && \ bundle && \ - rake rbspy_install && \ - rake thread_id_install && \ - rake x86_64_darwin:gem + RUST_TARGET=x86_64-apple-darwin rake rbspy_install && \ + RUST_TARGET=x86_64-apple-darwin rake thread_id_install && \ + RUST_TARGET=x86_64-apple-darwin rake x86_64_darwin:gem .phony: gem/mac/arm64 gem/mac/arm64: pyroscope_ffi/clean cd pyroscope_ffi/ruby && \ bundle && \ - rake rbspy_install && \ - rake thread_id_install && \ - rake arm64_darwin:gem \ No newline at end of file + RUST_TARGET=aarch64-apple-darwin rake rbspy_install && \ + RUST_TARGET=aarch64-apple-darwin rake thread_id_install && \ + RUST_TARGET=aarch64-apple-darwin rake arm64_darwin:gem \ No newline at end of file diff --git a/pyroscope_ffi/python/setup.cfg b/pyroscope_ffi/python/setup.cfg index 2b39220..43c5679 100644 --- a/pyroscope_ffi/python/setup.cfg +++ b/pyroscope_ffi/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pyroscope-io -version= 0.8.6 +version= 0.8.7 description = Pyroscope Python integration long_description = file: README.md long_description_content_type = text/markdown diff --git a/pyroscope_ffi/python/setup.py b/pyroscope_ffi/python/setup.py index 6ed9272..81b1c73 100644 --- a/pyroscope_ffi/python/setup.py +++ b/pyroscope_ffi/python/setup.py @@ -15,7 +15,11 @@ def build_native(spec): ) def find_dylib(): - in_path = '../../../target/release' + cargo_target = os.environ.get('CARGO_BUILD_TARGET') + if cargo_target: + in_path = '../../../target/%s/release' % (cargo_target) + else: + in_path = '../../../target/release' return build.find_dylib('pyroscope_ffi', in_path=in_path) # Step 2: package the compiled library diff --git a/pyroscope_ffi/ruby/lib/pyroscope/version.rb b/pyroscope_ffi/ruby/lib/pyroscope/version.rb index 3214ea2..99f6f94 100644 --- a/pyroscope_ffi/ruby/lib/pyroscope/version.rb +++ b/pyroscope_ffi/ruby/lib/pyroscope/version.rb @@ -1,3 +1,3 @@ module Pyroscope - VERSION = '0.5.11'.freeze + VERSION = '0.5.12'.freeze end