-
Notifications
You must be signed in to change notification settings - Fork 3
fix: prevent SIGSEGV crash on Homebrew #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
005d4f5
fix: prevent SIGSEGV crash on Homebrew
MicBun 86df731
more patches
MicBun 7235708
build(macos): pass -dynamic-link to gopy gen so the Go .so defers lib…
MicBun f198805
build(macos): scope -dynamic-link to Darwin and widen CGO_LDFLAGS_ALLOW
MicBun 9c2eb67
build(macos): override gopy-generated Makefile LDFLAGS to drop libpyt…
MicBun 88ca900
build(macos): pass LDFLAGS as sub-make argument so override actually …
MicBun 3c8d200
ci: scope release perms to contents:write, bump setup actions to v5, …
MicBun 9deb11b
ci(release): smoke-test wheel before publish; make Darwin install_nam…
MicBun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,146 @@ | ||
| name: Release · Build & Package Python SDK | ||
|
|
||
| on: | ||
| # Run whenever you push a tag like v1.2.3 | ||
| push: | ||
| tags: | ||
| - 'v*.*.*' | ||
| # Also allow manual re-runs | ||
| workflow_dispatch: | ||
|
|
||
| permissions: write-all | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build wheels on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| python-version: ['3.12'] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Fetch all history for setuptools_scm to detect version from git tags | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.24.1' | ||
|
|
||
| - name: Install gopy & goimports | ||
| run: | | ||
| go install github.com/go-python/gopy@v0.4.10 | ||
| go install golang.org/x/tools/cmd/goimports@latest | ||
| echo "$HOME/go/bin" >> $GITHUB_PATH | ||
| shell: bash | ||
|
|
||
| - name: Install system dependencies (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y build-essential | ||
| export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install build tools | ||
| run: | | ||
| python3 -m pip install --upgrade pip setuptools wheel pybindgen build setuptools-scm | ||
|
|
||
| - name: Build gopy bindings | ||
| run: make gopy_build | ||
| shell: bash | ||
|
|
||
| - name: Build wheels | ||
| run: python -m build --wheel --outdir wheelhouse | ||
|
|
||
| - name: Upload wheels as artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-${{ matrix.os }} | ||
| path: wheelhouse/*.whl | ||
|
|
||
| publish: | ||
| name: Publish Wheels to Release | ||
| needs: build | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Download all built wheels | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: wheels-* | ||
| merge-multiple: true | ||
| path: dist/ | ||
|
|
||
| - name: Publish GitHub Release with Wheels | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: dist/*.whl | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| name: Release · Build & Package Python SDK | ||
|
|
||
| on: | ||
| # Run whenever you push a tag like v1.2.3 | ||
| push: | ||
| tags: | ||
| - 'v*.*.*' | ||
| # Also allow manual re-runs | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| build-linux: | ||
| name: Build Linux wheels | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.24.1' | ||
|
|
||
| - name: Install gopy & goimports | ||
| run: | | ||
| go install github.com/go-python/gopy@v0.4.10 | ||
| go install golang.org/x/tools/cmd/goimports@latest | ||
| echo "$HOME/go/bin" >> $GITHUB_PATH | ||
| shell: bash | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y build-essential patchelf | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install build tools | ||
| run: python3 -m pip install --upgrade pip setuptools wheel pybindgen build setuptools-scm | ||
|
|
||
| - name: Build gopy bindings | ||
| run: make gopy_build | ||
|
|
||
| - name: Build wheels | ||
| run: python -m build --wheel --outdir wheelhouse | ||
|
|
||
| - name: Upload wheels | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-linux | ||
| path: wheelhouse/*.whl | ||
|
|
||
| build-macos: | ||
| name: Build macOS wheels (${{ matrix.arch }}) | ||
| runs-on: ${{ matrix.runs-on }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - arch: arm64 | ||
| runs-on: macos-14 | ||
| goarch: arm64 | ||
| # Uncomment to also publish x86_64 wheels: | ||
| # - arch: x86_64 | ||
| # runs-on: macos-13 | ||
| # goarch: amd64 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.24.1' | ||
|
|
||
| # cibuildwheel uses the python.org installer for the in-wheel Python, | ||
| # which bakes @rpath-relative libpython install names into the .so — | ||
| # the property that makes the wheel loadable by Homebrew/conda/uv | ||
| # interpreters. | ||
| - name: Build wheels with cibuildwheel | ||
| uses: pypa/cibuildwheel@v2.21.3 | ||
| env: | ||
| CIBW_BUILD: cp312-macosx_${{ matrix.arch }} | ||
| CIBW_ARCHS_MACOS: ${{ matrix.arch }} | ||
| # CGO must be on for arm64; gopy + goimports must be reachable | ||
| # inside the build's hermetic env, so we install them in | ||
| # BEFORE_ALL and forward PATH via CIBW_ENVIRONMENT. | ||
| CIBW_ENVIRONMENT: > | ||
| CGO_ENABLED=1 | ||
| GOARCH=${{ matrix.goarch }} | ||
| PATH=$PATH:/usr/local/go/bin:$HOME/go/bin | ||
| MACOSX_DEPLOYMENT_TARGET=11.0 | ||
| CIBW_BEFORE_ALL_MACOS: | | ||
| go install github.com/go-python/gopy@v0.4.10 | ||
| go install golang.org/x/tools/cmd/goimports@latest | ||
| CIBW_BEFORE_BUILD_MACOS: | | ||
| pip install pybindgen setuptools wheel setuptools-scm | ||
|
|
||
| # Smoke-test the wheel before publishing: install it into a fresh | ||
| # interpreter and load the C bindings. Catches packaging breakage | ||
| # and the SIGSEGV-class regression the PR fixes (the import alone | ||
| # triggers loading both gopy .so files). | ||
| - name: Set up Python for wheel smoke test | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Smoke-test built wheel | ||
| run: | | ||
| python -m venv /tmp/smoke-venv | ||
| /tmp/smoke-venv/bin/pip install wheelhouse/*.whl | ||
| /tmp/smoke-venv/bin/python -c "from trufnetwork_sdk_py.client import TNClient; print('wheel import ok')" | ||
|
|
||
| - name: Upload wheels | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheels-macos-${{ matrix.arch }} | ||
| path: wheelhouse/*.whl | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| publish: | ||
| name: Publish wheels to release | ||
| needs: [build-linux, build-macos] | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download all built wheels | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: wheels-* | ||
| merge-multiple: true | ||
| path: dist/ | ||
|
|
||
| - name: Publish GitHub release with wheels | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: dist/*.whl | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.