Compare commits

...

2 Commits

Author SHA1 Message Date
Adeeb Shihadeh
f9dd627e57 support pure wheels in shim packages (#75) 2026-04-25 13:35:28 -07:00
Adeeb Shihadeh
058ed3c076 add catch2 package (#74) 2026-04-25 13:11:59 -07:00
6 changed files with 97 additions and 12 deletions

View File

@@ -43,20 +43,29 @@ class InstallPrebuilt(build_py):
if plat is None: if plat is None:
raise RuntimeError(f"unsupported platform: {key}") raise RuntimeError(f"unsupported platform: {key}")
whl_name = f"{MODULE}-{VERSION}-py3-none-{plat}.whl" whl_names = [
url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}" f"{MODULE}-{VERSION}-py3-none-{plat}.whl",
f"{MODULE}-{VERSION}-py3-none-any.whl",
]
print(f"Downloading {url} ...") raw = None
for attempt in range(3): for whl_name in whl_names:
try: url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}"
raw = urlopen(url, timeout=60).read() print(f"Downloading {url} ...")
for attempt in range(3):
try:
raw = urlopen(url, timeout=60).read()
break
except (URLError, OSError) as e:
if attempt == 2:
if whl_name == whl_names[-1]:
raise
break
wait = 2 ** attempt
print(f"Download failed ({e}), retrying in {wait}s ...")
time.sleep(wait)
if raw is not None:
break break
except (URLError, OSError) as e:
if attempt == 2:
raise
wait = 2 ** attempt
print(f"Download failed ({e}), retrying in {wait}s ...")
time.sleep(wait)
print(f"Extracting {DATADIR} ...") print(f"Extracting {DATADIR} ...")
with zipfile.ZipFile(BytesIO(raw)) as zf: with zipfile.ZipFile(BytesIO(raw)) as zf:

22
catch2/build.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$DIR"
VERSION="v2.13.10"
INSTALL_DIR="$DIR/catch2/install"
if [ ! -d "catch2-src/.git" ]; then
rm -rf catch2-src
git clone --depth 1 https://github.com/catchorg/Catch2.git catch2-src
fi
git -C catch2-src fetch --depth 1 origin "$VERSION"
git -C catch2-src checkout --force FETCH_HEAD
rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/include"
cp -r catch2-src/single_include/catch2 "$INSTALL_DIR/include/"
echo "Installed catch2 to $INSTALL_DIR"
du -sh "$INSTALL_DIR"

View File

@@ -0,0 +1,9 @@
import os
DIR = os.path.join(os.path.dirname(__file__), "install")
INCLUDE_DIR = os.path.join(DIR, "include")
LIB_DIR = DIR # header-only; no libraries
def smoketest():
assert os.path.isfile(os.path.join(INCLUDE_DIR, "catch2", "catch.hpp")), "catch2/catch.hpp not found"

16
catch2/pyproject.toml Normal file
View File

@@ -0,0 +1,16 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "catch2"
version = "2.13.10"
description = "Catch2 C++ test framework headers"
requires-python = ">=3.8"
[tool.setuptools.packages.find]
include = ["catch2*"]
exclude = ["catch2-src*"]
[tool.setuptools.package-data]
catch2 = ["install/**/*"]

28
catch2/setup.py Normal file
View File

@@ -0,0 +1,28 @@
import os
import subprocess
from setuptools.command.build_py import build_py
class BuildCatch2(build_py):
"""Run build.sh to download Catch2 headers before collecting package data."""
def run(self):
pkg_dir = os.path.dirname(os.path.abspath(__file__))
build_script = os.path.join(pkg_dir, "build.sh")
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
super().run()
cmdclass = {"build_py": BuildCatch2}
def setup():
from setuptools import setup as _setup
_setup(cmdclass=cmdclass)
if __name__ == "__main__":
setup()

View File

@@ -2,6 +2,7 @@
members = [ members = [
"bzip2", "bzip2",
"capnproto", "capnproto",
"catch2",
"cppcheck", "cppcheck",
"eigen", "eigen",
"ffmpeg", "ffmpeg",