Skip to content

Commit 59fdafc

Browse files
committed
Vibe coded prototype of cibuildwheel
1 parent a4642c1 commit 59fdafc

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Runs as CIBW_BEFORE_ALL inside the manylinux container.
3+
# Installs C++ dependencies via micromamba and builds all roboplan sub-packages
4+
# so that the bindings wheel can find them via CMAKE_PREFIX_PATH.
5+
set -euxo pipefail
6+
7+
PROJECT_DIR="${1:-/project}"
8+
CONDA_ENV="/opt/cibw_env"
9+
INSTALL_PREFIX="/opt/roboplan_deps"
10+
11+
# ---------------------------------------------------------------------------
12+
# 1. Install micromamba (static binary, works in any Linux container)
13+
# ---------------------------------------------------------------------------
14+
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest \
15+
| tar -xvj -C /usr/local bin/micromamba
16+
17+
# ---------------------------------------------------------------------------
18+
# 2. Create conda environment with all C++ build + runtime dependencies.
19+
# - osqp-eigen / libtoppra are NOT listed here; roboplan_oink and
20+
# roboplan_toppra fall back to FetchContent when they are absent, so
21+
# cmake will download and build them automatically.
22+
# ---------------------------------------------------------------------------
23+
/usr/local/bin/micromamba create \
24+
--prefix "$CONDA_ENV" \
25+
--channel conda-forge \
26+
--yes \
27+
"cmake>=3.22" ninja \
28+
"gcc>=11,<12" "gxx>=11,<12" \
29+
"eigen>=3.4" \
30+
"pinocchio>=3.9.0,<4" \
31+
"yaml-cpp>=0.8"
32+
33+
CMAKE="$CONDA_ENV/bin/cmake"
34+
GCC="$CONDA_ENV/bin/gcc"
35+
GXX="$CONDA_ENV/bin/g++"
36+
37+
# ---------------------------------------------------------------------------
38+
# 3. Build and install every roboplan sub-package.
39+
# Order mirrors pixi.toml build_all task.
40+
# ---------------------------------------------------------------------------
41+
build_and_install() {
42+
local NAME="$1"
43+
"$CMAKE" \
44+
-GNinja \
45+
-S "$PROJECT_DIR/$NAME" \
46+
-B "/tmp/build/$NAME" \
47+
-DCMAKE_BUILD_TYPE=Release \
48+
-DBUILD_TESTING=OFF \
49+
"-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" \
50+
"-DCMAKE_PREFIX_PATH=$CONDA_ENV;$INSTALL_PREFIX" \
51+
"-DCMAKE_C_COMPILER=$GCC" \
52+
"-DCMAKE_CXX_COMPILER=$GXX"
53+
"$CMAKE" --build "/tmp/build/$NAME" --parallel "$(nproc)"
54+
"$CMAKE" --install "/tmp/build/$NAME"
55+
}
56+
57+
build_and_install roboplan_example_models
58+
build_and_install roboplan
59+
build_and_install roboplan_simple_ik
60+
build_and_install roboplan_oink
61+
build_and_install roboplan_toppra
62+
build_and_install roboplan_rrt
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and publish wheels
2+
3+
on:
4+
# Build (smoke-test) on pushes to main; build + publish on version tags.
5+
push:
6+
# branches: [main]
7+
# tags: ["v*"]
8+
# Manual trigger
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build_wheels:
17+
name: Build wheels (Linux x86_64)
18+
runs-on: ubuntu-22.04
19+
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
26+
- name: Build wheels
27+
uses: pypa/cibuildwheel@v2.22.0
28+
with:
29+
# Build the bindings sub-package, not the repo root.
30+
package-dir: bindings/
31+
output-dir: wheelhouse/
32+
33+
- name: Upload wheels as artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: wheels
37+
path: wheelhouse/*.whl
38+
39+
publish:
40+
name: Publish to PyPI
41+
needs: build_wheels
42+
runs-on: ubuntu-22.04
43+
# Only publish on version tags.
44+
if: startsWith(github.ref, 'refs/tags/v')
45+
environment:
46+
name: pypi
47+
url: https://pypi.org/p/roboplan
48+
permissions:
49+
id-token: write # Required for PyPI trusted publishing (OIDC)
50+
51+
steps:
52+
- name: Download wheels
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: wheels
56+
path: dist/
57+
58+
- name: Publish to PyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1

bindings/pyproject.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,30 @@ minimum-version = "build-system.requires"
2424

2525
# Setuptools-style build caching in a local directory
2626
build-dir = "build/{wheel_tag}"
27+
28+
# ---------------------------------------------------------------------------
29+
# cibuildwheel — produces manylinux_2_28 wheels for PyPI
30+
#
31+
# Only one Python version is built because the extension uses nanobind's
32+
# STABLE_ABI + NB_STATIC flags, which produce a cp310-abi3 wheel that is
33+
# compatible with Python 3.10 and all later versions.
34+
#
35+
# The before-all script:
36+
# 1. Installs micromamba and creates a conda-forge environment with the
37+
# C++ build tools and runtime libraries (eigen, pinocchio, yaml-cpp …).
38+
# 2. Builds every roboplan sub-package and installs them to
39+
# /opt/roboplan_deps so cmake can find them via CMAKE_PREFIX_PATH.
40+
# roboplan_oink and roboplan_toppra use FetchContent fallbacks for
41+
# osqp-eigen and libtoppra, so those are not listed in the conda env.
42+
#
43+
# auditwheel repair (run automatically by cibuildwheel) bundles all
44+
# non-manylinux shared libraries into the wheel, making it self-contained.
45+
# ---------------------------------------------------------------------------
46+
[tool.cibuildwheel]
47+
build = ["cp310-manylinux_x86_64"]
48+
manylinux-x86_64-image = "manylinux_2_28"
49+
before-all = "bash {project}/.github/scripts/build_roboplan_deps.sh {project}"
50+
51+
[tool.cibuildwheel.environment]
52+
CMAKE_PREFIX_PATH = "/opt/roboplan_deps:/opt/cibw_env"
53+
LD_LIBRARY_PATH = "/opt/roboplan_deps/lib:/opt/cibw_env/lib:$LD_LIBRARY_PATH"

0 commit comments

Comments
 (0)