Skip to content

Commit

Permalink
ci: build Python wheels
Browse files Browse the repository at this point in the history
This change adds extra steps to the CI workflows to build Python
wheels so that the Austin binary can be installed with pip from
PyPI.
  • Loading branch information
P403n1x87 committed Mar 18, 2023
1 parent 8ff6d23 commit 8a7b681
Show file tree
Hide file tree
Showing 8 changed files with 553 additions and 10 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/build_arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
steps:
- uses: actions/checkout@v2
name: Checkout sources

- uses: uraimo/run-on-arch-action@v2.0.5
name: Build on ${{ matrix.arch }}
name: Build Austin on ${{ matrix.arch }}
id: build-on-arch
with:
arch: ${{ matrix.arch }}
Expand All @@ -31,6 +31,47 @@ jobs:
mkdir -p ./artifacts
run: ARCH=${{ matrix.arch }} bash scripts/build_arch.sh

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Build wheels on ${{ matrix.arch }}
run: |
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r scripts/requirements-bw.txt
export VERSION=$(cat src/austin.h | sed -r -n "s/^#define VERSION[ ]+\"(.+)\"/\1/p");
case ${{ matrix.arch }} in
armv7)
PLATFORM=manylinux_2_17_armv7l.manylinux2014_armv7l
MUSL_PLATFORM=musllinux_1_1_armv7l
;;
aarch64)
PLATFORM=manylinux_2_17_aarch64.manylinux2014_aarch64
MUSL_PLATFORM=musllinux_1_1_aarch64
;;
ppc64le)
PLATFORM=manylinux_2_17_ppc64le.manylinux2014_ppc64le
MUSL_PLATFORM=musllinux_1_1_ppc64le
;;
esac
python scripts/build-wheel.py \
--version=$VERSION \
--platform=$PLATFORM \
--files austin:./artifacts/austin austinp:./artifacts/austinp
python scripts/build-wheel.py \
--version=$VERSION \
--platform=$MUSL_PLATFORM \
--files austin:./artifacts/austin.musl
deactivate
- name: Show artifacts
run: |
ls -al ./artifacts
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ jobs:
- uses: actions/checkout@v2
name: Checkout Austin

- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Generate artifacts
run: |
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r scripts/requirements-bw.txt
sudo apt-get update
sudo apt-get -y install autoconf build-essential libunwind-dev binutils-dev libiberty-dev musl-tools zlib1g-dev
Expand All @@ -30,12 +40,26 @@ jobs:
tar -Jcf austinp-$VERSION-gnu-linux-amd64.tar.xz austinp
popd
# Build gnu wheel
python scripts/build-wheel.py \
--version=$VERSION \
--platform=manylinux_2_12_x86_64.manylinux2010_x86_64 \
--files austin:src/austin austinp:src/austinp
# Build with musl
musl-gcc -O3 -Os -s -Wall -pthread src/*.c -o src/austin -D__MUSL__
pushd src
tar -Jcf austin-$VERSION-musl-linux-amd64.tar.xz austin
popd
# Build musl wheel
python scripts/build-wheel.py \
--version=$VERSION \
--platform=musllinux_1_1_x86_64 \
--files austin:src/austin
deactivate
- name: Upload artifacts to release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -44,6 +68,12 @@ jobs:
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Upload Python wheels to PyPI
run: |
source .venv/bin/activate
twine upload dist/*.whl --username __token__ --password ${{ secrets.PYPI_TOKEN }}
deactivate
release-win:
runs-on: windows-latest
Expand Down Expand Up @@ -109,6 +139,29 @@ jobs:
overwrite: true
file_glob: true

- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Build Python wheels
shell: bash
run: |
py -3.10 -m pip install --upgrade pip
py -3.10 -m pip install -r scripts/requirements-bw.txt
export VERSION=$(cat src/austin.h | sed -r -n "s/^#define VERSION[ ]+\"(.+)\"/\1/p")
py -3.10 scripts/build-wheel.py \
--version=$VERSION \
--platform=win_amd64 \
--files austin.exe:src/austin.exe
- name: Upload Python wheels to PyPI
shell: bash
run: |
py -3.10 -m twine upload dist/*.whl --username __token__ --password ${{ secrets.PYPI_TOKEN }}
release-osx:
runs-on: macos-latest
strategy:
Expand All @@ -118,8 +171,18 @@ jobs:
- uses: actions/checkout@v2
name: Checkout Austin

- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Generate artifacts
run: |
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r scripts/requirements-bw.txt
export VERSION=$(cat src/austin.h | sed -n -E "s/^#define VERSION[ ]+\"(.+)\"/\1/p")
echo "::set-output name=version::$VERSION"
Expand All @@ -129,6 +192,26 @@ jobs:
zip -r austin-${VERSION}-mac64.zip austin
popd
# Build intel wheel
python scripts/build-wheel.py \
--version=$VERSION \
--platform=macosx_11_0_x86_64 \
--files austin:src/austin
clang -Wall -O3 -Os -o src/austin src/*.c -target arm64-apple-macos11
pushd src
zip -r austin-${VERSION}-mac-arm64.zip austin
popd
# Build arm wheel
python scripts/build-wheel.py \
--version=$VERSION \
--platform=macosx_11_0_arm64 \
--files austin:src/austin
deactivate
- name: Upload artifacts to release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -137,3 +220,10 @@ jobs:
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Upload Python wheels to PyPI
shell: bash
run: |
source .venv/bin/activate
twine upload dist/*.whl --username __token__ --password ${{ secrets.PYPI_TOKEN }}
deactivate
47 changes: 47 additions & 0 deletions .github/workflows/release_arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,50 @@ jobs:
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Build wheels on ${{ matrix.arch }}
run: |
python3.10 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r scripts/requirements-bw.txt
export VERSION=$(cat src/austin.h | sed -r -n "s/^#define VERSION[ ]+\"(.+)\"/\1/p");
case ${{ matrix.arch }} in
armv7)
PLATFORM=manylinux_2_17_armv7l.manylinux2014_armv7l
MUSL_PLATFORM=musllinux_1_1_armv7l
;;
aarch64)
PLATFORM=manylinux_2_17_aarch64.manylinux2014_aarch64
MUSL_PLATFORM=musllinux_1_1_aarch64
;;
ppc64le)
PLATFORM=manylinux_2_17_ppc64le.manylinux2014_ppc64le
MUSL_PLATFORM=musllinux_1_1_ppc64le
;;
esac
python scripts/build-wheel.py \
--version=$VERSION \
--platform=$PLATFORM \
--files austin:./artifacts/austin austinp:./artifacts/austinp
python scripts/build-wheel.py \
--version=$VERSION \
--platform=$MUSL_PLATFORM \
--files austin:./artifacts/austin.musl
deactivate
- name: Upload wheels
run: |
source .venv/bin/activate
twine upload dist/*.whl --username __token__ --password ${{ secrets.PYPI_TOKEN }}s
deactivate
Loading

0 comments on commit 8a7b681

Please sign in to comment.