Compare commits

..

3 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
Adeeb Shihadeh
9f9bc38a3e rm mdbook 2026-04-15 14:22:07 -07:00
9 changed files with 87 additions and 140 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"

View File

@@ -3,16 +3,14 @@ requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "mdbook" name = "catch2"
version = "0.5.2" version = "2.13.10"
description = "mdBook command-line tool for creating books from Markdown" description = "Catch2 C++ test framework headers"
requires-python = ">=3.8" requires-python = ">=3.8"
[project.scripts]
mdbook = "mdbook:_run"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
include = ["mdbook*"] include = ["catch2*"]
exclude = ["catch2-src*"]
[tool.setuptools.package-data] [tool.setuptools.package-data]
mdbook = ["bin/**/*"] 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

@@ -1,46 +0,0 @@
#!/usr/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$DIR"
VERSION="0.5.2"
INSTALL_DIR="$DIR/mdbook/bin"
VERSION_FILE="$INSTALL_DIR/.version"
# Skip if already at correct version
if [ -f "$VERSION_FILE" ] && [ "$(cat "$VERSION_FILE")" = "$VERSION" ]; then
echo "mdbook $VERSION already present, skipping."
exit 0
fi
OS="$(uname -s)"
ARCH="$(uname -m)"
case "${OS}-${ARCH}" in
Linux-x86_64) TARGET="x86_64-unknown-linux-musl" ;;
Linux-aarch64) TARGET="aarch64-unknown-linux-musl" ;;
Darwin-arm64) TARGET="aarch64-apple-darwin" ;;
*)
echo "Unsupported platform: ${OS}-${ARCH}" >&2
exit 1
;;
esac
FILENAME="mdbook-v${VERSION}-${TARGET}.tar.gz"
URL="https://github.com/rust-lang/mdBook/releases/download/v${VERSION}/${FILENAME}"
echo "Downloading $FILENAME ..."
curl -fSL -o "$FILENAME" "$URL"
echo "Extracting ..."
mkdir -p "$INSTALL_DIR"
tar -xzf "$FILENAME" -C "$INSTALL_DIR" mdbook
chmod +x "$INSTALL_DIR/mdbook"
rm -f "$FILENAME"
echo "$VERSION" > "$VERSION_FILE"
echo "Installed mdbook to $INSTALL_DIR"
du -sh "$INSTALL_DIR"

View File

@@ -1,15 +0,0 @@
import os
import sys
BIN_DIR = os.path.join(os.path.dirname(__file__), "bin")
def _run():
binary = os.path.join(BIN_DIR, "mdbook")
os.execvp(binary, [binary] + sys.argv[1:])
def smoketest():
import subprocess
binary = os.path.join(BIN_DIR, "mdbook")
subprocess.run([binary, "--version"], check=True)

View File

@@ -1,58 +0,0 @@
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 BuildMdbook(build_py):
"""Run build.sh to download mdbook 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": BuildMdbook}
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()

View File

@@ -2,6 +2,7 @@
members = [ members = [
"bzip2", "bzip2",
"capnproto", "capnproto",
"catch2",
"cppcheck", "cppcheck",
"eigen", "eigen",
"ffmpeg", "ffmpeg",
@@ -13,7 +14,6 @@ members = [
"libusb", "libusb",
"libjpeg", "libjpeg",
"libyuv", "libyuv",
"mdbook",
"nanosvg", "nanosvg",
"ncurses", "ncurses",
"qt5", "qt5",