Compare commits
16 Commits
gcc-arm-no
...
openssl/v3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31b96deac5 | ||
|
|
6fe17e7b31 | ||
|
|
2377af3f1f | ||
|
|
b9f89a5a5d | ||
|
|
fd4ae72793 | ||
|
|
dfa87aa31a | ||
|
|
71d4d1d3a1 | ||
|
|
f117a0e60d | ||
|
|
bf379a6268 | ||
|
|
fcd4d49232 | ||
|
|
9a30c4f717 | ||
|
|
c57efe15bc | ||
|
|
f67ffb5c94 | ||
|
|
cd913d0f9f | ||
|
|
e66179c262 | ||
|
|
453518f608 |
212
.github/workflows/release.yml
vendored
Normal file
212
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
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: Install build dependencies
|
||||||
|
run: ./setup.sh
|
||||||
|
|
||||||
|
- 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//-/_}"
|
||||||
|
# detect the package-data directory (e.g. "toolchain" or "install")
|
||||||
|
datadir=$(python3 -c "
|
||||||
|
import tomllib
|
||||||
|
t = tomllib.load(open('$toml', 'rb'))
|
||||||
|
pat = t.get('tool', {}).get('setuptools', {}).get('package-data', {}).get('$module', [''])[0]
|
||||||
|
print(pat.split('/')[0])
|
||||||
|
")
|
||||||
|
description=$(python3 -c "import tomllib; print(tomllib.load(open('$toml', 'rb'))['project']['description'])")
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo "Creating shim: $pkg v$version (datadir=$datadir)"
|
||||||
|
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/"
|
||||||
|
|
||||||
|
cat > "$pkg_dir/pyproject.toml" << TOML
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "$pkg"
|
||||||
|
version = "$version"
|
||||||
|
description = "$description (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 = ["${datadir}/**/*"]
|
||||||
|
TOML
|
||||||
|
|
||||||
|
# setup.py — downloads pre-built wheel from GH releases and extracts data
|
||||||
|
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"
|
||||||
|
DATADIR = "DATADIR_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 binaries."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
data_dir = os.path.join(pkg_dir, MODULE, DATADIR)
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(data_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(f"Extracting {DATADIR} ...")
|
||||||
|
with zipfile.ZipFile(BytesIO(data)) as zf:
|
||||||
|
prefix = f"{MODULE}/{DATADIR}/"
|
||||||
|
alt_prefix = f"{MODULE}-{VERSION}.data/purelib/{MODULE}/{DATADIR}/"
|
||||||
|
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(data_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))
|
||||||
|
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"
|
||||||
|
sed -i "s|DATADIR_PLACEHOLDER|${datadir}|" "$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
|
||||||
83
.github/workflows/test.yml
vendored
83
.github/workflows/test.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: ./test.sh
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,20 +6,47 @@ 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: Install build dependencies
|
||||||
|
run: ./setup.sh
|
||||||
|
- 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 +55,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 +66,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
|
|
||||||
|
|||||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,10 +1,22 @@
|
|||||||
.git/
|
.git/
|
||||||
repo/
|
repo/
|
||||||
|
.venv/
|
||||||
|
__pycache__/
|
||||||
|
|
||||||
|
# agents
|
||||||
|
.claude/
|
||||||
|
.context/
|
||||||
|
TASK.md
|
||||||
|
|
||||||
# build artifacts (applies to all packages)
|
# build artifacts (applies to all packages)
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
install/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
|
||||||
# downloaded toolchain binaries
|
# downloaded toolchain binaries
|
||||||
gcc-arm-none-eabi/gcc_arm_none_eabi/toolchain/
|
gcc-arm-none-eabi/gcc_arm_none_eabi/toolchain/
|
||||||
|
|
||||||
|
|
||||||
|
# downloaded git-lfs
|
||||||
|
git-lfs/git_lfs/bin/
|
||||||
|
|||||||
51
README.md
51
README.md
@@ -1,14 +1,24 @@
|
|||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
a central repo for managing and vendoring third party dependencies for all comma projects.
|
a central repo for managing and [vendoring](https://htmx.org/essays/vendoring/) third party dependencies for all comma projects.
|
||||||
|
|
||||||
all of our projects are python projects, so each of these gets packaged as a pip project.
|
since all our projects are Python, we wrap each vendored dependency as a pip package. `git clone` and `uv sync` is all you need.
|
||||||
|
|
||||||
this vendoring serves a few goals:
|
motivations for this approach
|
||||||
- all dependencies are centrally managed here
|
- `apt-get` is slow
|
||||||
- we can slim them down to only what we need
|
- `apt-get` updates its packages on a schedule we don't control
|
||||||
- all platforms get the same versions installed
|
- `apt-get` package versions don't match `brew` versions
|
||||||
- tighter control of distribution for fast installs (e.g. Ubuntu's `apt-get` is slow)
|
- `apt-get` doesn't come with Arch Linux
|
||||||
|
- `apt-get` doesn't always have the exact package we need
|
||||||
|
- `apt-get` packages are often bloated
|
||||||
|
|
||||||
|
<!--
|
||||||
|
this critically adds friction to adding dependencies to our project
|
||||||
|
- `apt-get` installing a package is easy. is it 1MB, 10MB, or 100MB? no idea.
|
||||||
|
- `apt-get` installing a package is much easier than adding it here. how much do you want it?
|
||||||
|
-->
|
||||||
|
|
||||||
|
`uv`, as opposed to `apt-get`, `brew`, and friends, is fast and already used in our projects.
|
||||||
|
|
||||||
we target the following platforms:
|
we target the following platforms:
|
||||||
- Linux x86_64
|
- Linux x86_64
|
||||||
@@ -16,3 +26,30 @@ we target the following platforms:
|
|||||||
- Darwin aarch64 (Apple Silicon)
|
- Darwin aarch64 (Apple Silicon)
|
||||||
|
|
||||||
contributions welcome for other platforms!
|
contributions welcome for other platforms!
|
||||||
|
|
||||||
|
## packages
|
||||||
|
|
||||||
|
| package | description |
|
||||||
|
|-------------------|--------------------------------------------------------------------------|
|
||||||
|
| gcc-arm-none-eabi | builds [panda](https://github.com/commaai/panda) firmware for STM32 MCUs |
|
||||||
|
| capnproto | message serialization for openpilot |
|
||||||
|
| ffmpeg | video encode and decode for openpilot |
|
||||||
|
| git-lfs | for tracking large files in openpilot |
|
||||||
|
| zeromq | bridging the openpilot IPC between different hosts |
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
```python
|
||||||
|
dependencies = [
|
||||||
|
"capnproto @ git+https://github.com/commaai/dependencies.git@releases#subdirectory=capnproto",
|
||||||
|
"ffmpeg @ git+https://github.com/commaai/dependencies.git@releases#subdirectory=ffmpeg",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## workflow
|
||||||
|
|
||||||
|
to add a new package:
|
||||||
|
* start a new top-level directory as a new package
|
||||||
|
* `./test.sh` tests the building of all packages
|
||||||
|
* on pushes to `master`, wheels are built for our target platforms and pushed to a GitHub release
|
||||||
|
* the `releases` branch contains shim packages that allow pointing to a git branch and always getting the appropriate wheel for your platform
|
||||||
|
|||||||
69
capnproto/build.sh
Normal file
69
capnproto/build.sh
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="1.0.1"
|
||||||
|
INSTALL_DIR="$DIR/capnproto/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -x "$INSTALL_DIR/bin/capnp" ]; then
|
||||||
|
echo "capnproto already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Clone
|
||||||
|
if [ ! -d "capnproto-src" ]; then
|
||||||
|
git clone --depth 1 --branch "v${VERSION}" https://github.com/capnproto/capnproto.git capnproto-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
cmake -S capnproto-src -B "$DIR/build" \
|
||||||
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||||
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||||
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DWITH_OPENSSL=OFF \
|
||||||
|
-DBUILD_TESTING=OFF \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF
|
||||||
|
|
||||||
|
cmake --build "$DIR/build" -j"$NJOBS"
|
||||||
|
cmake --install "$DIR/build"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{bin,lib,include}
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
cp "$PREFIX/bin/capnp" "$INSTALL_DIR/bin/"
|
||||||
|
cp "$PREFIX/bin/capnpc-c++" "$INSTALL_DIR/bin/"
|
||||||
|
ln -sf capnp "$INSTALL_DIR/bin/capnpc"
|
||||||
|
|
||||||
|
# Libraries (only the ones openpilot needs)
|
||||||
|
cp "$PREFIX/lib/libcapnp.a" "$INSTALL_DIR/lib/"
|
||||||
|
cp "$PREFIX/lib/libkj.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
cp -r "$PREFIX/include/capnp" "$INSTALL_DIR/include/"
|
||||||
|
cp -r "$PREFIX/include/kj" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Strip binaries and libs
|
||||||
|
strip "$INSTALL_DIR/bin/capnp" "$INSTALL_DIR/bin/capnpc-c++" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Strip unused kj objects from libkj.a (not needed by openpilot)
|
||||||
|
for obj in filesystem.c++.o main.c++.o test-helpers.c++.o; do
|
||||||
|
ar d "$INSTALL_DIR/lib/libkj.a" "$obj" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf capnproto-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed capnproto to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
31
capnproto/capnproto/__init__.py
Normal file
31
capnproto/capnproto/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
BIN_DIR = os.path.join(DIR, "bin")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def _run(name):
|
||||||
|
binary = os.path.join(BIN_DIR, name)
|
||||||
|
env = os.environ.copy()
|
||||||
|
# ensure sibling binaries (e.g. capnpc-c++) are findable
|
||||||
|
env["PATH"] = BIN_DIR + ":" + env.get("PATH", "")
|
||||||
|
os.execvpe(binary, [binary] + sys.argv[1:], env)
|
||||||
|
|
||||||
|
|
||||||
|
def _run_capnp():
|
||||||
|
_run("capnp")
|
||||||
|
|
||||||
|
|
||||||
|
def _run_capnpc():
|
||||||
|
# capnpc is a symlink to capnp; capnp checks argv[0] to enter compile mode
|
||||||
|
binary = os.path.join(BIN_DIR, "capnp")
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["PATH"] = BIN_DIR + ":" + env.get("PATH", "")
|
||||||
|
os.execvpe(binary, ["capnpc"] + sys.argv[1:], env)
|
||||||
|
|
||||||
|
|
||||||
|
def _run_capnpc_cpp():
|
||||||
|
_run("capnpc-c++")
|
||||||
20
capnproto/pyproject.toml
Normal file
20
capnproto/pyproject.toml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "capnproto"
|
||||||
|
version = "1.0.1"
|
||||||
|
description = "Cap'n Proto serialization library and compiler"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
capnp = "capnproto:_run_capnp"
|
||||||
|
capnpc = "capnproto:_run_capnpc"
|
||||||
|
"capnpc-c++" = "capnproto:_run_capnpc_cpp"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["capnproto*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
capnproto = ["install/**/*"]
|
||||||
61
capnproto/setup.py
Normal file
61
capnproto/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildCapnproto(build_py):
|
||||||
|
"""Run build.sh to compile capnproto before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "capnproto", "install", "bin", "capnp")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildCapnproto}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
42
cppcheck/build.sh
Executable file
42
cppcheck/build.sh
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="2.16.0"
|
||||||
|
INSTALL_DIR="$DIR/cppcheck/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -x "$INSTALL_DIR/cppcheck" ]; then
|
||||||
|
echo "cppcheck already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Clone
|
||||||
|
if [ ! -d "cppcheck-src" ]; then
|
||||||
|
git clone --depth 1 --branch "$VERSION" https://github.com/danmar/cppcheck.git cppcheck-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
cd cppcheck-src
|
||||||
|
make MATCHCOMPILER=yes CXXFLAGS="-O2" -j"$NJOBS"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Install
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
|
||||||
|
cp cppcheck-src/cppcheck "$INSTALL_DIR/"
|
||||||
|
cp -r cppcheck-src/addons "$INSTALL_DIR/"
|
||||||
|
cp -r cppcheck-src/cfg "$INSTALL_DIR/"
|
||||||
|
cp -r cppcheck-src/platforms "$INSTALL_DIR/"
|
||||||
|
strip "$INSTALL_DIR/cppcheck" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf cppcheck-src
|
||||||
|
|
||||||
|
echo "Installed cppcheck to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
16
cppcheck/cppcheck/__init__.py
Normal file
16
cppcheck/cppcheck/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
|
||||||
|
|
||||||
|
def _run():
|
||||||
|
binary = os.path.join(DIR, "cppcheck")
|
||||||
|
os.execvp(binary, ["cppcheck"] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
import subprocess
|
||||||
|
binary = os.path.join(DIR, "cppcheck")
|
||||||
|
result = subprocess.run([binary, "--version"], capture_output=True, text=True, check=True)
|
||||||
|
print(result.stdout.strip())
|
||||||
18
cppcheck/pyproject.toml
Normal file
18
cppcheck/pyproject.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "cppcheck"
|
||||||
|
version = "2.16.0"
|
||||||
|
description = "Cppcheck static analysis tool"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
cppcheck = "cppcheck:_run"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["cppcheck*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
cppcheck = ["install/**/*"]
|
||||||
61
cppcheck/setup.py
Normal file
61
cppcheck/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildCppcheck(build_py):
|
||||||
|
"""Run build.sh to compile cppcheck before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "cppcheck", "install", "cppcheck")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildCppcheck}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
34
eigen/build.sh
Executable file
34
eigen/build.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="3.4.0"
|
||||||
|
INSTALL_DIR="$DIR/eigen/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already present
|
||||||
|
if [ -d "$INSTALL_DIR/eigen3/Eigen" ]; then
|
||||||
|
echo "eigen already present, skipping download."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARBALL="eigen-${VERSION}.tar.gz"
|
||||||
|
URL="https://gitlab.com/libeigen/eigen/-/archive/${VERSION}/${TARBALL}"
|
||||||
|
|
||||||
|
echo "Downloading Eigen ${VERSION} ..."
|
||||||
|
curl -fSL -o "$TARBALL" "$URL"
|
||||||
|
|
||||||
|
echo "Extracting headers ..."
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR/eigen3"
|
||||||
|
|
||||||
|
# Extract only the Eigen/ and unsupported/Eigen/ header directories
|
||||||
|
tar --strip-components=1 -xzf "$TARBALL" -C "$INSTALL_DIR/eigen3" \
|
||||||
|
"eigen-${VERSION}/Eigen" \
|
||||||
|
"eigen-${VERSION}/unsupported"
|
||||||
|
|
||||||
|
rm -f "$TARBALL"
|
||||||
|
|
||||||
|
echo "Installed eigen to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
9
eigen/eigen/__init__.py
Normal file
9
eigen/eigen/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
INCLUDE_DIR = DIR
|
||||||
|
LIB_DIR = DIR # header-only; no libraries
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isdir(os.path.join(DIR, "eigen3", "Eigen")), "Eigen headers not found"
|
||||||
15
eigen/pyproject.toml
Normal file
15
eigen/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "eigen"
|
||||||
|
version = "3.4.0"
|
||||||
|
description = "Eigen C++ linear algebra headers"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["eigen*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
eigen = ["install/**/*"]
|
||||||
61
eigen/setup.py
Normal file
61
eigen/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildEigen(build_py):
|
||||||
|
"""Run build.sh to download Eigen headers before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "eigen", "install", "eigen3", "Eigen")
|
||||||
|
|
||||||
|
if not os.path.isdir(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildEigen}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
94
ffmpeg/build.sh
Normal file
94
ffmpeg/build.sh
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
FFMPEG_VERSION="7.1"
|
||||||
|
INSTALL_DIR="$DIR/ffmpeg/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -x "$INSTALL_DIR/bin/ffmpeg" ]; then
|
||||||
|
echo "ffmpeg already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
# --- Build x264 (static) ---
|
||||||
|
if [ ! -d "x264-src" ]; then
|
||||||
|
git clone --depth 1 --branch stable https://code.videolan.org/videolan/x264.git x264-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd x264-src
|
||||||
|
./configure \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--enable-static \
|
||||||
|
--disable-shared \
|
||||||
|
--disable-cli \
|
||||||
|
--disable-opencl \
|
||||||
|
--enable-pic
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# --- Build FFmpeg ---
|
||||||
|
if [ ! -d "ffmpeg-src" ]; then
|
||||||
|
git clone --depth 1 --branch "n${FFMPEG_VERSION}" https://github.com/FFmpeg/FFmpeg.git ffmpeg-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ffmpeg-src
|
||||||
|
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" \
|
||||||
|
./configure \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--enable-gpl \
|
||||||
|
--enable-static \
|
||||||
|
--disable-shared \
|
||||||
|
--enable-libx264 \
|
||||||
|
--enable-pic \
|
||||||
|
--disable-doc \
|
||||||
|
--disable-ffplay \
|
||||||
|
--disable-autodetect \
|
||||||
|
--disable-everything \
|
||||||
|
--enable-encoder=libx264,aac,ffvhuff,rawvideo,png \
|
||||||
|
--enable-decoder=h264,hevc,ffvhuff,aac,rawvideo,png,mjpeg,mp3,pcm_s16le \
|
||||||
|
--enable-muxer=mpegts,matroska,mp4,hevc,rawvideo,image2,null,mov \
|
||||||
|
--enable-demuxer=hevc,matroska,mpegts,mov,rawvideo,image2,aac,concat \
|
||||||
|
--enable-parser=h264,hevc,aac,mpegaudio \
|
||||||
|
--enable-protocol=file,pipe \
|
||||||
|
--enable-filter=blend,vflip,format,scale,aformat,anull,aresample,null \
|
||||||
|
--enable-bsf=extract_extradata,h264_mp4toannexb,hevc_mp4toannexb \
|
||||||
|
--extra-cflags="-I$PREFIX/include" \
|
||||||
|
--extra-ldflags="-L$PREFIX/lib"
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{bin,lib,include}
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
cp "$PREFIX/bin/ffmpeg" "$INSTALL_DIR/bin/"
|
||||||
|
cp "$PREFIX/bin/ffprobe" "$INSTALL_DIR/bin/"
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
for lib in libavformat.a libavcodec.a libavutil.a libswresample.a libx264.a; do
|
||||||
|
cp "$PREFIX/lib/$lib" "$INSTALL_DIR/lib/"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
for dir in libavformat libavcodec libavutil libswresample; do
|
||||||
|
cp -r "$PREFIX/include/$dir" "$INSTALL_DIR/include/"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Strip binaries
|
||||||
|
strip "$INSTALL_DIR/bin/ffmpeg" "$INSTALL_DIR/bin/ffprobe" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf x264-src ffmpeg-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed ffmpeg to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
20
ffmpeg/ffmpeg/__init__.py
Normal file
20
ffmpeg/ffmpeg/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
BIN_DIR = os.path.join(DIR, "bin")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def _run(name):
|
||||||
|
binary = os.path.join(BIN_DIR, name)
|
||||||
|
os.execvp(binary, [binary] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
def _run_ffmpeg():
|
||||||
|
_run("ffmpeg")
|
||||||
|
|
||||||
|
|
||||||
|
def _run_ffprobe():
|
||||||
|
_run("ffprobe")
|
||||||
19
ffmpeg/pyproject.toml
Normal file
19
ffmpeg/pyproject.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "ffmpeg"
|
||||||
|
version = "7.1.0"
|
||||||
|
description = "FFmpeg media tools and libraries (minimal build for openpilot)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
ffmpeg = "ffmpeg:_run_ffmpeg"
|
||||||
|
ffprobe = "ffmpeg:_run_ffprobe"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["ffmpeg*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
ffmpeg = ["install/**/*"]
|
||||||
61
ffmpeg/setup.py
Normal file
61
ffmpeg/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildFFmpeg(build_py):
|
||||||
|
"""Run build.sh to compile ffmpeg before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "ffmpeg", "install", "bin", "ffmpeg")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildFFmpeg}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
@@ -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)
|
||||||
|
|||||||
56
git-lfs/build.sh
Executable file
56
git-lfs/build.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="3.6.1"
|
||||||
|
INSTALL_DIR="$DIR/git_lfs/bin"
|
||||||
|
|
||||||
|
# Idempotent: skip if already present
|
||||||
|
if [ -x "$INSTALL_DIR/git-lfs" ]; then
|
||||||
|
echo "git-lfs already present, skipping download."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
OS="$(uname -s)"
|
||||||
|
ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "${OS}-${ARCH}" in
|
||||||
|
Linux-x86_64) PLATFORM="linux-amd64" ; EXT="tar.gz" ;;
|
||||||
|
Linux-aarch64) PLATFORM="linux-arm64" ; EXT="tar.gz" ;;
|
||||||
|
Darwin-arm64) PLATFORM="darwin-arm64" ; EXT="zip" ;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported platform: ${OS}-${ARCH}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
FILENAME="git-lfs-${PLATFORM}-v${VERSION}.${EXT}"
|
||||||
|
URL="https://github.com/git-lfs/git-lfs/releases/download/v${VERSION}/${FILENAME}"
|
||||||
|
|
||||||
|
echo "Downloading $FILENAME ..."
|
||||||
|
curl -fSL -o "$FILENAME" "$URL"
|
||||||
|
|
||||||
|
echo "Extracting ..."
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
if [ "$EXT" = "zip" ]; then
|
||||||
|
python3 -c "
|
||||||
|
import zipfile, sys
|
||||||
|
with zipfile.ZipFile('$FILENAME') as zf:
|
||||||
|
for info in zf.infolist():
|
||||||
|
if info.filename.endswith('/git-lfs'):
|
||||||
|
with open('$INSTALL_DIR/git-lfs', 'wb') as f:
|
||||||
|
f.write(zf.read(info))
|
||||||
|
break
|
||||||
|
"
|
||||||
|
else
|
||||||
|
tar --strip-components=1 -xzf "$FILENAME" -C "$INSTALL_DIR" --wildcards '*/git-lfs'
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x "$INSTALL_DIR/git-lfs"
|
||||||
|
|
||||||
|
rm -f "$FILENAME"
|
||||||
|
|
||||||
|
echo "Installed git-lfs to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
15
git-lfs/git_lfs/__init__.py
Normal file
15
git-lfs/git_lfs/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
BIN_DIR = os.path.join(os.path.dirname(__file__), "bin")
|
||||||
|
|
||||||
|
|
||||||
|
def _run():
|
||||||
|
binary = os.path.join(BIN_DIR, "git-lfs")
|
||||||
|
os.execvp(binary, [binary] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
import subprocess
|
||||||
|
binary = os.path.join(BIN_DIR, "git-lfs")
|
||||||
|
subprocess.run([binary, "--version"], check=True)
|
||||||
18
git-lfs/pyproject.toml
Normal file
18
git-lfs/pyproject.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "git-lfs"
|
||||||
|
version = "3.6.1"
|
||||||
|
description = "Git Large File Storage extension"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
git-lfs = "git_lfs:_run"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["git_lfs*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
git_lfs = ["bin/**/*"]
|
||||||
61
git-lfs/setup.py
Normal file
61
git-lfs/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildGitLfs(build_py):
|
||||||
|
"""Run build.sh to download git-lfs before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "git_lfs", "bin", "git-lfs")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildGitLfs}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
56
libjpeg/build.sh
Executable file
56
libjpeg/build.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="3.1.0"
|
||||||
|
INSTALL_DIR="$DIR/libjpeg/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -f "$INSTALL_DIR/lib/libjpeg.a" ]; then
|
||||||
|
echo "libjpeg already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Clone
|
||||||
|
if [ ! -d "libjpeg-turbo-src" ]; then
|
||||||
|
git clone --depth 1 --branch "${VERSION}" https://github.com/libjpeg-turbo/libjpeg-turbo.git libjpeg-turbo-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
cmake -S libjpeg-turbo-src -B "$DIR/build" \
|
||||||
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||||
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||||
|
-DENABLE_SHARED=OFF \
|
||||||
|
-DENABLE_STATIC=ON \
|
||||||
|
-DWITH_TURBOJPEG=OFF
|
||||||
|
|
||||||
|
cmake --build "$DIR/build" -j"$NJOBS"
|
||||||
|
cmake --install "$DIR/build"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
|
# Library
|
||||||
|
cp "$PREFIX/lib/libjpeg.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
cp "$PREFIX/include/jpeglib.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/jconfig.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/jerror.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/jmorecfg.h" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf libjpeg-turbo-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed libjpeg to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
10
libjpeg/libjpeg/__init__.py
Normal file
10
libjpeg/libjpeg/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libjpeg.a")), "libjpeg.a not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "jpeglib.h")), "jpeglib.h not found"
|
||||||
15
libjpeg/pyproject.toml
Normal file
15
libjpeg/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "libjpeg"
|
||||||
|
version = "3.1.0"
|
||||||
|
description = "libjpeg-turbo JPEG library (static build)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["libjpeg*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
libjpeg = ["install/**/*"]
|
||||||
61
libjpeg/setup.py
Normal file
61
libjpeg/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildLibjpeg(build_py):
|
||||||
|
"""Run build.sh to compile libjpeg-turbo before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "libjpeg", "install", "lib", "libjpeg.a")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildLibjpeg}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
73
ncurses/build.sh
Executable file
73
ncurses/build.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="6.5"
|
||||||
|
INSTALL_DIR="$DIR/ncurses/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -f "$INSTALL_DIR/lib/libncurses.a" ]; then
|
||||||
|
echo "ncurses already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Download
|
||||||
|
TARBALL="ncurses-${VERSION}.tar.gz"
|
||||||
|
if [ ! -f "$TARBALL" ]; then
|
||||||
|
curl -fsSL "https://ftp.gnu.org/gnu/ncurses/${TARBALL}" -o "$TARBALL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract
|
||||||
|
if [ ! -d "ncurses-${VERSION}" ]; then
|
||||||
|
tar xf "$TARBALL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
cd "ncurses-${VERSION}"
|
||||||
|
./configure \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--without-shared \
|
||||||
|
--with-normal \
|
||||||
|
--without-debug \
|
||||||
|
--without-cxx \
|
||||||
|
--without-cxx-binding \
|
||||||
|
--without-ada \
|
||||||
|
--without-manpages \
|
||||||
|
--without-progs \
|
||||||
|
--without-tests \
|
||||||
|
--without-dlsym \
|
||||||
|
--enable-overwrite
|
||||||
|
|
||||||
|
make -j"$NJOBS"
|
||||||
|
# Only install libs and headers; skip terminfo database (fails on macOS CI)
|
||||||
|
make install.libs install.includes
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
|
# Libraries (ncurses 6.x builds wide-char by default; provide as libncurses.a)
|
||||||
|
cp "$PREFIX/lib/libncursesw.a" "$INSTALL_DIR/lib/libncurses.a" 2>/dev/null \
|
||||||
|
|| cp "$PREFIX/lib/libncurses.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers (--enable-overwrite puts them directly in include/)
|
||||||
|
cp "$PREFIX/include/ncurses.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/curses.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/ncurses_dll.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/unctrl.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/term.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/termcap.h" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "ncurses-${VERSION}" "$TARBALL" "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed ncurses to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
10
ncurses/ncurses/__init__.py
Normal file
10
ncurses/ncurses/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libncurses.a")), "libncurses.a not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "ncurses.h")), "ncurses.h not found"
|
||||||
15
ncurses/pyproject.toml
Normal file
15
ncurses/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "ncurses"
|
||||||
|
version = "6.5"
|
||||||
|
description = "ncurses terminal library (static build)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["ncurses*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
ncurses = ["install/**/*"]
|
||||||
61
ncurses/setup.py
Normal file
61
ncurses/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildNcurses(build_py):
|
||||||
|
"""Run build.sh to compile ncurses before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "ncurses", "install", "lib", "libncurses.a")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildNcurses}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
74
openssl/build.sh
Executable file
74
openssl/build.sh
Executable file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="3.4.1"
|
||||||
|
INSTALL_DIR="$DIR/openssl3/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -f "$INSTALL_DIR/lib/libcrypto.a" ]; then
|
||||||
|
echo "openssl already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Download
|
||||||
|
TARBALL="openssl-${VERSION}.tar.gz"
|
||||||
|
if [ ! -d "openssl-src" ]; then
|
||||||
|
curl -fSL -o "$TARBALL" "https://github.com/openssl/openssl/releases/download/openssl-${VERSION}/${TARBALL}"
|
||||||
|
mkdir -p openssl-src
|
||||||
|
tar -xf "$TARBALL" -C openssl-src --strip-components=1
|
||||||
|
rm -f "$TARBALL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
cd openssl-src
|
||||||
|
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
TARGET="darwin64-arm64-cc"
|
||||||
|
else
|
||||||
|
MACHINE="$(uname -m)"
|
||||||
|
if [ "$MACHINE" = "x86_64" ]; then
|
||||||
|
TARGET="linux-x86_64"
|
||||||
|
elif [ "$MACHINE" = "aarch64" ]; then
|
||||||
|
TARGET="linux-aarch64"
|
||||||
|
else
|
||||||
|
TARGET="linux-${MACHINE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
./Configure "$TARGET" \
|
||||||
|
--prefix="$PREFIX" \
|
||||||
|
--libdir=lib \
|
||||||
|
no-shared \
|
||||||
|
no-tests \
|
||||||
|
no-docs \
|
||||||
|
no-apps \
|
||||||
|
-Os
|
||||||
|
|
||||||
|
# Build
|
||||||
|
make -j"$NJOBS"
|
||||||
|
make install_sw
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
cp "$PREFIX/lib/libcrypto.a" "$INSTALL_DIR/lib/"
|
||||||
|
cp "$PREFIX/lib/libssl.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
cp -r "$PREFIX/include/openssl" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf openssl-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed openssl to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
11
openssl/openssl3/__init__.py
Normal file
11
openssl/openssl3/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libcrypto.a")), "libcrypto.a not found"
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libssl.a")), "libssl.a not found"
|
||||||
|
assert os.path.isdir(os.path.join(INCLUDE_DIR, "openssl")), "openssl headers not found"
|
||||||
15
openssl/pyproject.toml
Normal file
15
openssl/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "openssl"
|
||||||
|
version = "3.4.1"
|
||||||
|
description = "OpenSSL cryptography library (static build)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["openssl3*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
openssl3 = ["install/**/*"]
|
||||||
61
openssl/setup.py
Normal file
61
openssl/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildOpenssl(build_py):
|
||||||
|
"""Run build.sh to compile OpenSSL before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "openssl3", "install", "lib", "libcrypto.a")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildOpenssl}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
44
python3-dev/build.sh
Executable file
44
python3-dev/build.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="3.12.8"
|
||||||
|
INSTALL_DIR="$DIR/python3_dev/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already present
|
||||||
|
if [ -f "$INSTALL_DIR/include/Python.h" ]; then
|
||||||
|
echo "python3-dev headers already present, skipping."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARBALL="Python-${VERSION}.tgz"
|
||||||
|
URL="https://www.python.org/ftp/python/${VERSION}/${TARBALL}"
|
||||||
|
|
||||||
|
echo "Downloading CPython ${VERSION} source ..."
|
||||||
|
curl -fSL -o "$TARBALL" "$URL"
|
||||||
|
|
||||||
|
echo "Extracting ..."
|
||||||
|
tar xzf "$TARBALL"
|
||||||
|
|
||||||
|
cd "Python-${VERSION}"
|
||||||
|
|
||||||
|
# Run configure to generate pyconfig.h for this platform
|
||||||
|
echo "Running configure to generate pyconfig.h ..."
|
||||||
|
./configure --disable-shared --without-ensurepip > /dev/null 2>&1
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# Copy headers
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR/include"
|
||||||
|
|
||||||
|
cp -r "Python-${VERSION}/Include/"* "$INSTALL_DIR/include/"
|
||||||
|
cp "Python-${VERSION}/pyconfig.h" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "Python-${VERSION}" "$TARBALL"
|
||||||
|
|
||||||
|
echo "Installed python3-dev headers to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
15
python3-dev/pyproject.toml
Normal file
15
python3-dev/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "python3-dev"
|
||||||
|
version = "3.12.8"
|
||||||
|
description = "CPython development headers"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["python3_dev*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
python3_dev = ["install/**/*"]
|
||||||
9
python3-dev/python3_dev/__init__.py
Normal file
9
python3-dev/python3_dev/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "Python.h")), "Python.h not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "pyconfig.h")), "pyconfig.h not found"
|
||||||
61
python3-dev/setup.py
Normal file
61
python3-dev/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildPython3Dev(build_py):
|
||||||
|
"""Run build.sh to download CPython headers before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "python3_dev", "install", "include", "Python.h")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildPython3Dev}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
8
setup.sh
Executable file
8
setup.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
brew install nasm pkg-config
|
||||||
|
else
|
||||||
|
sudo apt-get update && sudo apt-get install -y nasm cmake g++ pkg-config
|
||||||
|
fi
|
||||||
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
|
||||||
59
zeromq/build.sh
Executable file
59
zeromq/build.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="4.3.5"
|
||||||
|
INSTALL_DIR="$DIR/zeromq/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -f "$INSTALL_DIR/lib/libzmq.a" ]; then
|
||||||
|
echo "zeromq already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Clone
|
||||||
|
if [ ! -d "libzmq-src" ]; then
|
||||||
|
git clone --depth 1 --branch "v${VERSION}" https://github.com/zeromq/libzmq.git libzmq-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
cmake -S libzmq-src -B "$DIR/build" \
|
||||||
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||||
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||||
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DWITH_LIBSODIUM=OFF \
|
||||||
|
-DWITH_TLS=OFF \
|
||||||
|
-DWITH_DOCS=OFF \
|
||||||
|
-DBUILD_TESTS=OFF \
|
||||||
|
-DBUILD_SHARED=OFF \
|
||||||
|
-DBUILD_STATIC=ON \
|
||||||
|
-DENABLE_DRAFTS=OFF
|
||||||
|
|
||||||
|
cmake --build "$DIR/build" -j"$NJOBS"
|
||||||
|
cmake --install "$DIR/build"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
|
# Library
|
||||||
|
cp "$PREFIX/lib/libzmq.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
cp "$PREFIX/include/zmq.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/zmq_utils.h" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf libzmq-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed zeromq to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
15
zeromq/pyproject.toml
Normal file
15
zeromq/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "zeromq"
|
||||||
|
version = "4.3.5"
|
||||||
|
description = "ZeroMQ messaging library (static build)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["zeromq*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
zeromq = ["install/**/*"]
|
||||||
61
zeromq/setup.py
Normal file
61
zeromq/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildZeromq(build_py):
|
||||||
|
"""Run build.sh to compile zeromq before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "zeromq", "install", "lib", "libzmq.a")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildZeromq}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
10
zeromq/zeromq/__init__.py
Normal file
10
zeromq/zeromq/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libzmq.a")), "libzmq.a not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "zmq.h")), "zmq.h not found"
|
||||||
58
zstd/build.sh
Executable file
58
zstd/build.sh
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
VERSION="1.5.6"
|
||||||
|
INSTALL_DIR="$DIR/zstd/install"
|
||||||
|
|
||||||
|
# Idempotent: skip if already built
|
||||||
|
if [ -f "$INSTALL_DIR/lib/libzstd.a" ]; then
|
||||||
|
echo "zstd already present, skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
|
|
||||||
|
# Clone
|
||||||
|
if [ ! -d "zstd-src" ]; then
|
||||||
|
git clone --depth 1 --branch "v${VERSION}" https://github.com/facebook/zstd.git zstd-src
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
PREFIX="$DIR/build/prefix"
|
||||||
|
mkdir -p "$DIR/build"
|
||||||
|
|
||||||
|
cmake -S zstd-src/build/cmake -B "$DIR/build" \
|
||||||
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||||
|
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||||
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DZSTD_BUILD_PROGRAMS=OFF \
|
||||||
|
-DZSTD_BUILD_TESTS=OFF \
|
||||||
|
-DZSTD_BUILD_CONTRIB=OFF \
|
||||||
|
-DZSTD_BUILD_SHARED=OFF \
|
||||||
|
-DZSTD_BUILD_STATIC=ON
|
||||||
|
|
||||||
|
cmake --build "$DIR/build" -j"$NJOBS"
|
||||||
|
cmake --install "$DIR/build"
|
||||||
|
|
||||||
|
# Copy to package install dir
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
|
# Library
|
||||||
|
cp "$PREFIX/lib/libzstd.a" "$INSTALL_DIR/lib/"
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
cp "$PREFIX/include/zstd.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/zstd_errors.h" "$INSTALL_DIR/include/"
|
||||||
|
cp "$PREFIX/include/zdict.h" "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf zstd-src "$DIR/build"
|
||||||
|
|
||||||
|
echo "Installed zstd to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
15
zstd/pyproject.toml
Normal file
15
zstd/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "zstd"
|
||||||
|
version = "1.5.6"
|
||||||
|
description = "Zstandard compression library (static build)"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["zstd*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
zstd = ["install/**/*"]
|
||||||
61
zstd/setup.py
Normal file
61
zstd/setup.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildZstd(build_py):
|
||||||
|
"""Run build.sh to compile zstd before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
marker = os.path.join(pkg_dir, "zstd", "install", "lib", "libzstd.a")
|
||||||
|
|
||||||
|
if not os.path.exists(marker):
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildZstd}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
10
zstd/zstd/__init__.py
Normal file
10
zstd/zstd/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
LIB_DIR = os.path.join(DIR, "lib")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(LIB_DIR, "libzstd.a")), "libzstd.a not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "zstd.h")), "zstd.h not found"
|
||||||
Reference in New Issue
Block a user