Skip to content
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

Add workflow to publish python package #395

Merged
merged 7 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Python Package

on:
release:
branches:
- main

jobs:
build-wheels:
name: Build wheels for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-13 # x86_64
- macos-14 # aarch64

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

# On Linux, use QEMU to build multiple platforms.
- name: Setup QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

# Need this for macos-14, which doesn't come with python for some reason.
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

# Need this to get cl.exe on the path.
- name: Set up Visual Studio shell
if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.5

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse bindings/python
env:

# We have QEMU setup and can build everything.
CIBW_ARCHS_LINUX: x86_64 i686 aarch64
# For some reason these don't use the same distro.
# musllinux uses apk & manylinux uses yum.
CIBW_BEFORE_BUILD_LINUX: |
if command -v apk > /dev/null; then
apk add --update clang && make -C src blst
elif command -v yum > /dev/null; then
yum install -y clang && make -C src blst
fi

# Building x86 (32-bit) package is difficult.
# We're missing the 32-bit Python library.
CIBW_ARCHS_WINDOWS: AMD64
# We need blst.lib (via MSVC) which our Makefile doesn't support.
CIBW_BEFORE_BUILD_WINDOWS: |
cd blst && build.bat && cp blst.lib ../lib && cp bindings/*.h ../inc

CIBW_BEFORE_BUILD_MACOS: |
make -C src blst

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
packages-dir: bindings/python/wheelhouse
1 change: 0 additions & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install py_ecc
pip install PyYAML
- name: Build BLST
run: |
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build/
dist/
ckzg.egg-info/
src/
9 changes: 6 additions & 3 deletions bindings/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension


def main():
setup(
name="ckzg",
version="1.0.0",
description="Python interface for C-KZG-4844",
version="0.4.2",
author="Ethereum Foundation",
description="Python bindings for C-KZG-4844",
ext_modules=[
Extension(
"ckzg",
Expand All @@ -13,5 +15,6 @@ def main():
library_dirs=["../../lib"],
libraries=["blst"])])


if __name__ == "__main__":
main()
Loading