-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add python bindings to this repo (#10)
Adds the `hyperdrivepy` bindings to this repo so they can be centrally located Modifies `Cargo.toml` files to all share the same version as the `hyperdrive-rs` workspace file All `*.rs` changes were moving stuff around, lint, etc. The workflow changes were substantive.
- Loading branch information
Showing
48 changed files
with
9,880 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,183 @@ | ||
name: build wheels | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
detect-version-changes: | ||
uses: ./.github/workflows/check_version.yml | ||
with: | ||
file_path: bindings/hyperdrivepy/pyproject.toml | ||
|
||
build-wheels-linux: | ||
needs: detect-version-changes | ||
# Run on main if version has changed | ||
if: needs.detect-version-changes.outputs.version_changed == 'true' | ||
name: build on linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout hyperdrive-rs | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{github.token}} | ||
|
||
- name: setup rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
|
||
- name: setup foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: set up python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
cache: "pip" | ||
token: ${{github.token}} | ||
|
||
- name: set up pip | ||
run: python -m pip install --upgrade pip | ||
|
||
- name: Fetch latest release tag from hyperdrive | ||
shell: bash | ||
run: source scripts/fetch-latest-tag.sh delvtech hyperdrive | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: check out hyperdrive | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: delvtech/hyperdrive | ||
ref: ${{ env.latest_tag_hyperdrive }} | ||
path: "./hyperdrive" | ||
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} | ||
|
||
- name: build hyperdrive | ||
run: cd hyperdrive && make build-sol | ||
|
||
- name: build hyperdrivepy | ||
shell: bash | ||
run: source scripts/build_python.sh | ||
|
||
- name: upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-linux | ||
path: ./wheelhouse/*.whl | ||
|
||
build-wheels-cibw: | ||
needs: detect-version-changes | ||
# Run on main if version has changed | ||
if: needs.detect-version-changes.outputs.version_changed == 'true' | ||
name: Build on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-12] | ||
python-version: [cp310] | ||
|
||
steps: | ||
- name: Checkout hyperdrive-rs | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Fetch latest release tag from hyperdrive | ||
shell: bash | ||
run: scripts/fetch-latest-tag.sh delvtech hyperdrive | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: check out hyperdrive | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: delvtech/hyperdrive | ||
ref: ${{ env.latest_tag_hyperdrive }} | ||
path: "./hyperdrive" | ||
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }} | ||
|
||
- name: build hyperdrive | ||
run: cd hyperdrive && make build-sol | ||
|
||
- name: set up python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: install python dependencies | ||
run: python -m pip install --upgrade pip && python -m pip install --upgrade -r requirements-dev.txt | ||
|
||
- name: build wheels | ||
uses: pypa/cibuildwheel@v2.16.5 | ||
env: | ||
CIBW_BUILD: "${{ matrix.python-version }}-*" | ||
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$HOME/.foundry/bin:$HOME/.cargo/env:$PATH" CARGO_TERM_COLOR="always"' | ||
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$UserProfile\.foundry\bin;$UserProfile\.cargo\env;$PATH"' | ||
CIBW_ARCHS_MACOS: x86_64 arm64 | ||
CIBW_BEFORE_ALL_MACOS: > | ||
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && | ||
rustup show && | ||
rustup target add aarch64-apple-darwin && | ||
curl -L https://foundry.paradigm.xyz | sh && | ||
foundryup | ||
CIBW_BUILD_VERBOSITY: 1 | ||
with: | ||
output-dir: wheelhouse | ||
package-dir: bindings/hyperdrivepy | ||
|
||
- name: upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
path: ./wheelhouse/*.whl | ||
|
||
build-sdist: | ||
needs: detect-version-changes | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
# Run on main if version has changed | ||
if: needs.detect-version-changes.outputs.version_changed == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build sdist | ||
run: pipx run build bindings/hyperdrivepy --sdist | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-sdist | ||
path: bindings/hyperdrivepy/dist/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: | ||
[ | ||
build-wheels-linux, | ||
build-wheels-cibw, | ||
build-sdist, | ||
detect-version-changes, | ||
] | ||
runs-on: ubuntu-latest | ||
environment: pypi | ||
permissions: | ||
id-token: write | ||
# Run on main if version has changed | ||
if: needs.detect-version-changes.outputs.version_changed == 'true' | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all wheels into dist/ | ||
pattern: wheels-* | ||
path: dist | ||
merge-multiple: true | ||
- uses: pypa/gh-action-pypi-publish@release/v1 |
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Check Version | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
file_path: | ||
description: File path to check for version change | ||
required: true | ||
type: string | ||
outputs: | ||
version_changed: | ||
description: true if the version line in the file has changed | ||
value: ${{ jobs.check.outputs.version_changed }} | ||
only_patch_version_changed: | ||
description: true if only the patch version has changed | ||
value: ${{ jobs.check.outputs.only_patch_version_changed }} | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version_changed: ${{ steps.check.outputs.version_changed }} | ||
only_patch_version_changed: ${{ steps.check.outputs.only_patch_version_changed }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
submodules: recursive | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check for version changes | ||
id: check | ||
run: | | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
# For PRs, compare PR head against base branch | ||
OLD_VERSION=$(git show ${{ github.event.pull_request.base.sha }}:${{ inputs.file_path }} | grep '^version = ' | cut -d '"' -f 2) | ||
else | ||
# For direct pushes, compare the last two commits | ||
OLD_VERSION=$(git show HEAD~1:${{ inputs.file_path }} | grep '^version = ' | cut -d '"' -f 2) | ||
fi | ||
# `cut` grabs everything inside the ", i.e. the version number x.y.z | ||
NEW_VERSION=$(grep '^version = ' ${{ inputs.file_path }} | cut -d '"' -f 2) | ||
echo "OLD_VERSION=$OLD_VERSION" | ||
echo "NEW_VERSION=$NEW_VERSION" | ||
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then | ||
echo "Version has changed." | ||
echo "version_changed=true" >> $GITHUB_OUTPUT | ||
IFS='.' read -ra OLD_PARTS <<< "$OLD_VERSION" | ||
IFS='.' read -ra NEW_PARTS <<< "$NEW_VERSION" | ||
if [ "${OLD_PARTS[0]}" == "${NEW_PARTS[0]}" ] && [ "${OLD_PARTS[1]}" == "${NEW_PARTS[1]}" ]; then | ||
echo "Only the patch version has changed." | ||
echo "only_patch_version_changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Major or minor version has changed." | ||
echo "only_patch_version_changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "No version change detected." | ||
echo "version_changed=false" >> $GITHUB_OUTPUT | ||
echo "only_patch_version_changed=false" >> $GITHUB_OUTPUT | ||
fi |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.js | ||
*.md | ||
*.yaml | ||
*.yml | ||
lib/ | ||
target/ | ||
forge-cache/ | ||
|
Oops, something went wrong.