Skip to content

Commit

Permalink
chore: polish patch_grpc_web script
Browse files Browse the repository at this point in the history
  • Loading branch information
jselig-rigetti committed Mar 21, 2024
1 parent f6119a1 commit b733526
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 48 deletions.
81 changes: 37 additions & 44 deletions .github/workflows/release-python-grpc-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,40 @@ jobs:
steps:
- run: echo "Publishing wheels"

# macos:
# runs-on: macos-12
# needs: [is-python-release, should-publish-wheels]
# env:
# CXXFLAGS: "-std=c++11 -stdlib=libc++"
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install protoc
# uses: arduino/setup-protoc@v1
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# version: '3.20.1'
# - name: Patch package metadata for grpc-web
# working-directory: ./crates/python
# run: |
# pip install toml
# python scripts/patch_package_name.py
# cd ../..
# python crates/python/scripts/patch_hyper_proxy.py
# - name: Build wheels - universal2
# # universal2 supports both x86_64 and aarch64
# uses: messense/maturin-action@v1
# with:
# args: -i 3.8 3.9 3.10 3.11 3.12 --release --target universal2-apple-darwin --manifest-path crates/python/Cargo.toml --features grpc-web --out dist
# docker-options: -e CI
# - name: Install wheel
# run: |
# pip install qcs-sdk-python --find-links dist --force-reinstall
# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: wheels-grpc-web
# path: dist
macos:
runs-on: macos-12
needs: [is-python-release, should-publish-wheels]
env:
CXXFLAGS: "-std=c++11 -stdlib=libc++"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.20.1'
- name: Patch package metadata for grpc-web
run: |
pip install toml
python crates/python/scripts/patch_grpc_web.py
cargo update
- name: Build wheels - universal2
# universal2 supports both x86_64 and aarch64
uses: messense/maturin-action@v1
with:
args: -i 3.8 3.9 3.10 3.11 3.12 --release --target universal2-apple-darwin --manifest-path crates/python/Cargo.toml --features grpc-web --out dist
docker-options: -e CI
- name: Install wheel
run: |
pip install qcs-sdk-python --find-links dist --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels-grpc-web
path: dist

linux:
runs-on: ubuntu-latest
Expand All @@ -83,12 +81,9 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.20.1'
- name: Patch package metadata for grpc-web
working-directory: ./crates/python
run: |
pip install toml
python scripts/patch_package_name.py
cd ../..
python crates/python/scripts/patch_hyper_proxy.py
python crates/python/scripts/patch_grpc_web.py
cargo update
- name: Build wheels
uses: messense/maturin-action@v1
Expand Down Expand Up @@ -123,12 +118,10 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.20.1'
- name: Patch package metadata for grpc-web
working-directory: ./crates/python
run: |
pip install toml
python scripts/patch_package_name.py
cd ../..
python crates/python/scripts/patch_hyper_proxy.py
python crates/python/scripts/patch_grpc_web.py
cargo update
- name: Build sdist
uses: messense/maturin-action@v1
with:
Expand Down
7 changes: 3 additions & 4 deletions crates/python/scripts/patch_grpc_web.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""
Appends grpc-web to the project name of both Cargo.toml and pyproject.toml,
and patches the `hyper-proxy` dependency.
and patches the `hyper-proxy` dependency to allow ppc64le wheel builds.
This is used in CI to update the package metadata before publishing the alternate
package with the grpc-web feature enabled.
This is used in CI to prepare grpc-web-specific python artifacts for publishing.
"""

from io import TextIOWrapper
from os.path import dirname, realpath, relpath, join
from os.path import dirname, realpath, join
import toml

pycrate_path = dirname(dirname(realpath(__file__)))
Expand Down

0 comments on commit b733526

Please sign in to comment.