add catch2 package (#74)

This commit is contained in:
Adeeb Shihadeh
2026-04-25 13:11:59 -07:00
committed by GitHub
parent 9f9bc38a3e
commit 058ed3c076
5 changed files with 76 additions and 0 deletions

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()