Compare commits
2 Commits
gcc-arm-no
...
capnproto/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e66179c262 | ||
|
|
453518f608 |
202
.github/workflows/release.yml
vendored
Normal file
202
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
name: release wheels
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build - ${{ matrix.runs-on }}
|
||||||
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: "3.14"
|
||||||
|
|
||||||
|
- name: build and release wheels
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
pip install build
|
||||||
|
|
||||||
|
for toml in */pyproject.toml; do
|
||||||
|
[ -f "$toml" ] || continue
|
||||||
|
pkg="$(dirname "$toml")"
|
||||||
|
version=$(python3 -c "import tomllib; print(tomllib.load(open('$toml', 'rb'))['project']['version'])")
|
||||||
|
tag="${pkg}/v${version}"
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo "Building: $pkg v$version"
|
||||||
|
echo "========================================="
|
||||||
|
python -m build --wheel "$pkg"
|
||||||
|
|
||||||
|
whl=$(ls "$pkg"/dist/*.whl)
|
||||||
|
echo "Uploading: $whl"
|
||||||
|
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" &>/dev/null; then
|
||||||
|
gh release upload "$tag" "$whl" --repo "$GITHUB_REPOSITORY" --clobber
|
||||||
|
else
|
||||||
|
gh release create "$tag" "$whl" \
|
||||||
|
--repo "$GITHUB_REPOSITORY" \
|
||||||
|
--title "$pkg v$version" \
|
||||||
|
--notes "Platform wheels for $pkg $version"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
publish-shims:
|
||||||
|
name: publish releases branch
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: build and push shim packages
|
||||||
|
run: |
|
||||||
|
REPO_URL="https://github.com/${GITHUB_REPOSITORY}"
|
||||||
|
|
||||||
|
# set up a temp dir for the releases branch
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
|
for toml in */pyproject.toml; do
|
||||||
|
[ -f "$toml" ] || continue
|
||||||
|
pkg="$(dirname "$toml")"
|
||||||
|
version=$(python3 -c "import tomllib; print(tomllib.load(open('$toml', 'rb'))['project']['version'])")
|
||||||
|
tag="${pkg}/v${version}"
|
||||||
|
module="${pkg//-/_}"
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo "Creating shim: $pkg v$version"
|
||||||
|
echo "========================================="
|
||||||
|
|
||||||
|
pkg_dir="$tmp/$pkg"
|
||||||
|
mod_dir="$pkg_dir/$module"
|
||||||
|
mkdir -p "$mod_dir"
|
||||||
|
|
||||||
|
# copy __init__.py from source
|
||||||
|
cp "$pkg/$module/__init__.py" "$mod_dir/"
|
||||||
|
|
||||||
|
# pyproject.toml — same metadata, no package-data (toolchain comes from wheel)
|
||||||
|
cat > "$pkg_dir/pyproject.toml" << TOML
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "$pkg"
|
||||||
|
version = "$version"
|
||||||
|
description = "ARM GCC toolchain for bare-metal targets (pre-built)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
$(grep -A100 '^\[project\.scripts\]' "$pkg/pyproject.toml" | tail -n +2 | sed '/^\[/q' | grep -v '^\[')
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["${module}*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
$module = ["toolchain/**/*"]
|
||||||
|
TOML
|
||||||
|
|
||||||
|
# setup.py — downloads pre-built wheel from GH releases and extracts toolchain
|
||||||
|
cat > "$pkg_dir/setup.py" << 'SETUP'
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import zipfile
|
||||||
|
from io import BytesIO
|
||||||
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
REPO_URL = "REPO_URL_PLACEHOLDER"
|
||||||
|
TAG = "TAG_PLACEHOLDER"
|
||||||
|
VERSION = "VERSION_PLACEHOLDER"
|
||||||
|
MODULE = "MODULE_PLACEHOLDER"
|
||||||
|
|
||||||
|
PLATFORM_MAP = {
|
||||||
|
("Linux", "x86_64"): "linux_x86_64",
|
||||||
|
("Linux", "aarch64"): "linux_aarch64",
|
||||||
|
("Darwin", "arm64"): "macosx_11_0_arm64",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class InstallPrebuilt(build_py):
|
||||||
|
"""Download pre-built wheel from GitHub Releases and extract the toolchain."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
toolchain_dir = os.path.join(pkg_dir, MODULE, "toolchain")
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(toolchain_dir, "bin")):
|
||||||
|
key = (platform.system(), platform.machine())
|
||||||
|
plat = PLATFORM_MAP.get(key)
|
||||||
|
if plat is None:
|
||||||
|
raise RuntimeError(f"unsupported platform: {key}")
|
||||||
|
|
||||||
|
whl_name = f"{MODULE}-{VERSION}-py3-none-{plat}.whl"
|
||||||
|
url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}"
|
||||||
|
|
||||||
|
print(f"Downloading {url} ...")
|
||||||
|
data = urlopen(url).read()
|
||||||
|
|
||||||
|
print("Extracting toolchain ...")
|
||||||
|
with zipfile.ZipFile(BytesIO(data)) as zf:
|
||||||
|
prefix = f"{MODULE}/toolchain/"
|
||||||
|
# also handle .data/purelib/ layout
|
||||||
|
alt_prefix = f"{MODULE}-{VERSION}.data/purelib/{MODULE}/toolchain/"
|
||||||
|
for info in zf.infolist():
|
||||||
|
for p in (prefix, alt_prefix):
|
||||||
|
if info.filename.startswith(p):
|
||||||
|
rel = info.filename[len(p):]
|
||||||
|
if not rel:
|
||||||
|
continue
|
||||||
|
dest = os.path.join(toolchain_dir, rel)
|
||||||
|
if info.is_dir():
|
||||||
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
else:
|
||||||
|
os.makedirs(os.path.dirname(dest), exist_ok=True)
|
||||||
|
with open(dest, "wb") as f:
|
||||||
|
f.write(zf.read(info))
|
||||||
|
# preserve executable bit
|
||||||
|
if info.external_attr >> 16 & 0o111:
|
||||||
|
os.chmod(dest, 0o755)
|
||||||
|
break
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
_setup(cmdclass={"build_py": InstallPrebuilt})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
|
SETUP
|
||||||
|
|
||||||
|
# template in the actual values
|
||||||
|
sed -i "s|REPO_URL_PLACEHOLDER|${REPO_URL}|" "$pkg_dir/setup.py"
|
||||||
|
sed -i "s|TAG_PLACEHOLDER|${tag}|" "$pkg_dir/setup.py"
|
||||||
|
sed -i "s|VERSION_PLACEHOLDER|${version}|" "$pkg_dir/setup.py"
|
||||||
|
sed -i "s|MODULE_PLACEHOLDER|${module}|" "$pkg_dir/setup.py"
|
||||||
|
done
|
||||||
|
|
||||||
|
# push to releases branch
|
||||||
|
cd "$tmp"
|
||||||
|
git init
|
||||||
|
git checkout -b releases
|
||||||
|
git add .
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git commit -m "update shim packages"
|
||||||
|
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
|
git push -f origin releases
|
||||||
81
.github/workflows/test.yml
vendored
81
.github/workflows/test.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: ./test.sh
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,20 +6,45 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
build:
|
||||||
name: ${{ matrix.image || matrix.os }}
|
name: build (${{ matrix.platform }})
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# native (no docker)
|
- platform: macos
|
||||||
- os: macos-latest
|
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
- platform: linux-x86_64
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
- platform: linux-arm64
|
||||||
|
runs-on: ubuntu-24.04-arm
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: "3.14"
|
||||||
|
- name: Build wheels
|
||||||
|
run: |
|
||||||
|
for pkg in */pyproject.toml; do
|
||||||
|
pip wheel "./$(dirname "$pkg")" --no-deps --wheel-dir dist/
|
||||||
|
done
|
||||||
|
- name: Smoketest locally
|
||||||
|
run: bash smoketest.sh dist/
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: wheels-${{ matrix.platform }}
|
||||||
|
path: dist/*.whl
|
||||||
|
|
||||||
# the provided github actions runner images
|
test:
|
||||||
# have tons of pre-installed packages. the
|
name: test (${{ matrix.image }})
|
||||||
# goal here is to test across many vanilla setups
|
needs: build
|
||||||
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# test on vanilla linux images
|
||||||
- image: debian:bookworm-slim
|
- image: debian:bookworm-slim
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
- image: ubuntu:24.04
|
- image: ubuntu:24.04
|
||||||
@@ -28,8 +53,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
- image: archlinux:latest
|
- image: archlinux:latest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
- image: alpine:3.21 # musl libc
|
# TODO: make musl work
|
||||||
runs-on: ubuntu-latest
|
#- image: alpine:3.21
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
- image: opensuse/tumbleweed:latest
|
- image: opensuse/tumbleweed:latest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
- image: ghcr.io/void-linux/void-glibc:latest
|
- image: ghcr.io/void-linux/void-glibc:latest
|
||||||
@@ -38,36 +64,27 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04-arm
|
runs-on: ubuntu-24.04-arm
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
# native (macOS)
|
|
||||||
- if: ${{ !matrix.image }}
|
|
||||||
uses: actions/setup-python@v6
|
|
||||||
with:
|
with:
|
||||||
python-version: "3.14"
|
name: wheels-${{ contains(matrix.runs-on, 'arm') && 'linux-arm64' || 'linux-x86_64' }}
|
||||||
- if: ${{ !matrix.image }}
|
path: wheels
|
||||||
name: ./test.sh
|
- name: build docker
|
||||||
run: ./test.sh
|
|
||||||
|
|
||||||
# docker (vanilla Linux)
|
|
||||||
- if: ${{ matrix.image }}
|
|
||||||
name: install python3
|
|
||||||
run: |
|
run: |
|
||||||
docker build -t test -f - . <<'DOCKERFILE'
|
docker build -t smoketest -f - . <<'DOCKERFILE'
|
||||||
FROM ${{ matrix.image }}
|
FROM ${{ matrix.image }}
|
||||||
RUN if command -v apk >/dev/null; then \
|
RUN if command -v apk >/dev/null; then \
|
||||||
apk add --no-cache python3 py3-pip bash curl; \
|
apk add --no-cache python3 py3-pip bash; \
|
||||||
elif command -v apt-get >/dev/null; then \
|
elif command -v apt-get >/dev/null; then \
|
||||||
apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-venv curl ca-certificates; \
|
apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-venv; \
|
||||||
elif command -v dnf >/dev/null; then \
|
elif command -v dnf >/dev/null; then \
|
||||||
dnf install -y python3 python3-pip curl; \
|
dnf install -y python3 python3-pip; \
|
||||||
elif command -v pacman >/dev/null; then \
|
elif command -v pacman >/dev/null; then \
|
||||||
pacman -Sy --noconfirm python python-pip curl; \
|
pacman -Sy --noconfirm python python-pip; \
|
||||||
elif command -v zypper >/dev/null; then \
|
elif command -v zypper >/dev/null; then \
|
||||||
zypper install -y python3 python3-pip curl; \
|
zypper install -y python3 python3-pip; \
|
||||||
elif command -v xbps-install >/dev/null; then \
|
elif command -v xbps-install >/dev/null; then \
|
||||||
xbps-install -Sy python3 python3-pip bash curl; \
|
xbps-install -Sy python3 python3-pip bash; \
|
||||||
fi
|
fi
|
||||||
DOCKERFILE
|
DOCKERFILE
|
||||||
- if: ${{ matrix.image }}
|
- name: ./smoketest.sh
|
||||||
name: ./test.sh
|
run: docker run --rm -v "$PWD:/work" -w /work smoketest bash smoketest.sh wheels/
|
||||||
run: docker run --rm -v "$PWD:/work" -w /work test bash ./test.sh
|
|
||||||
|
|||||||
@@ -19,3 +19,9 @@ def _run_objcopy():
|
|||||||
|
|
||||||
def _run_size():
|
def _run_size():
|
||||||
_run("arm-none-eabi-size")
|
_run("arm-none-eabi-size")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
import subprocess
|
||||||
|
gcc = os.path.join(TOOLCHAIN_DIR, "bin", "arm-none-eabi-gcc")
|
||||||
|
subprocess.run([gcc, "--version"], check=True)
|
||||||
|
|||||||
18
smoketest.sh
Executable file
18
smoketest.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
WHEEL_DIR="${1:?Usage: smoketest.sh <wheel-directory>}"
|
||||||
|
WHEEL_DIR="$(cd "$WHEEL_DIR" && pwd)"
|
||||||
|
|
||||||
|
VENV_DIR="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$VENV_DIR"' EXIT
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
pip install --upgrade pip >/dev/null
|
||||||
|
pip install "$WHEEL_DIR"/*.whl
|
||||||
|
|
||||||
|
for toml in "$REPO_DIR"/*/pyproject.toml; do
|
||||||
|
module="$(basename "$(dirname "$toml")" | tr '-' '_')"
|
||||||
|
python3 -c "import $module; $module.smoketest()" && echo "$module: OK"
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user