|
35 | 35 | - name: Run Tests |
36 | 36 | run: just ffi-test |
37 | 37 |
|
| 38 | + build-wheel-x86_64: |
| 39 | + name: Build Python Wheel (x86_64) |
| 40 | + runs-on: ubuntu-latest |
| 41 | + container: quay.io/pypa/manylinux_2_28_x86_64 |
| 42 | + steps: |
| 43 | + - name: Checkout CDK |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Install System Dependencies |
| 47 | + run: yum install -y openssl-devel pkg-config |
| 48 | + |
| 49 | + - name: Install Rust |
| 50 | + run: | |
| 51 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 52 | + source $HOME/.cargo/env |
| 53 | + rustup target add x86_64-unknown-linux-gnu |
| 54 | +
|
| 55 | + - name: Scaffold Python Package |
| 56 | + run: | |
| 57 | + mkdir -p python-package/src/cdk |
| 58 | + |
| 59 | + # Create pyproject.toml |
| 60 | + cat <<EOF > python-package/pyproject.toml |
| 61 | + [build-system] |
| 62 | + requires = ["setuptools>=61.0", "wheel"] |
| 63 | + build-backend = "setuptools.build_meta" |
| 64 | +
|
| 65 | + [project] |
| 66 | + name = "cdk-python" |
| 67 | + version = "0.0.1" |
| 68 | + description = "CDK Python Bindings (CI Build)" |
| 69 | + requires-python = ">=3.10" |
| 70 | + license = {text = "MIT"} |
| 71 | + authors = [{name = "CDK Developers", email = "tsk@cashudevkit.org"}] |
| 72 | + |
| 73 | + [tool.setuptools] |
| 74 | + packages = ["cdk"] |
| 75 | + |
| 76 | + [tool.setuptools.package-dir] |
| 77 | + cdk = "src/cdk" |
| 78 | + |
| 79 | + [tool.setuptools.package-data] |
| 80 | + cdk = ["*.so", "*.dylib", "*.dll", "*.pyi"] |
| 81 | + EOF |
| 82 | +
|
| 83 | + # Create __init__.py |
| 84 | + cat <<EOF > python-package/src/cdk/__init__.py |
| 85 | + """CDK Python Bindings""" |
| 86 | + from .cdk import * |
| 87 | + EOF |
| 88 | +
|
| 89 | + - name: Build FFI & Generate Bindings |
| 90 | + run: | |
| 91 | + source $HOME/.cargo/env |
| 92 | + cd crates/cdk-ffi |
| 93 | + |
| 94 | + # Build Rust Library |
| 95 | + cargo build --profile release-smaller --target x86_64-unknown-linux-gnu |
| 96 | + |
| 97 | + # Generate Bindings |
| 98 | + # Note: We are running natively on x86_64, so we use the native target for the generator |
| 99 | + cargo run --target x86_64-unknown-linux-gnu --bin uniffi-bindgen generate \ |
| 100 | + --library ../../target/x86_64-unknown-linux-gnu/release-smaller/libcdk_ffi.so \ |
| 101 | + --language python \ |
| 102 | + --out-dir ../../python-package/src/cdk/ |
| 103 | + |
| 104 | + # Copy Shared Object |
| 105 | + cp ../../target/x86_64-unknown-linux-gnu/release-smaller/libcdk_ffi.so ../../python-package/src/cdk/ |
| 106 | +
|
| 107 | + - name: Build Wheel |
| 108 | + run: | |
| 109 | + cd python-package |
| 110 | + |
| 111 | + # Find Python (Manylinux specific) |
| 112 | + PYTHON_BIN="/opt/python/cp310-cp310/bin/python" |
| 113 | + |
| 114 | + $PYTHON_BIN -m pip install build wheel auditwheel |
| 115 | + $PYTHON_BIN -m build --wheel |
| 116 | + |
| 117 | + # Auditwheel Repair |
| 118 | + mkdir -p wheelhouse |
| 119 | + for whl in dist/*.whl; do |
| 120 | + $PYTHON_BIN -m auditwheel repair "$whl" --plat manylinux_2_28_x86_64 -w wheelhouse/ |
| 121 | + done |
| 122 | + |
| 123 | + echo "✅ Wheel built and repaired successfully" |
| 124 | + ls -lh wheelhouse/ |
| 125 | +
|
38 | 126 | build-wheel-aarch64: |
39 | 127 | name: Build Python Wheel (ARM64) |
40 | 128 | runs-on: ubuntu-24.04-arm |
|
0 commit comments