diff --git a/catch2/build.sh b/catch2/build.sh new file mode 100755 index 0000000..6919c89 --- /dev/null +++ b/catch2/build.sh @@ -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" diff --git a/catch2/catch2/__init__.py b/catch2/catch2/__init__.py new file mode 100644 index 0000000..ea730a7 --- /dev/null +++ b/catch2/catch2/__init__.py @@ -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" diff --git a/catch2/pyproject.toml b/catch2/pyproject.toml new file mode 100644 index 0000000..2c8f6f8 --- /dev/null +++ b/catch2/pyproject.toml @@ -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/**/*"] diff --git a/catch2/setup.py b/catch2/setup.py new file mode 100644 index 0000000..93d7f1e --- /dev/null +++ b/catch2/setup.py @@ -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() diff --git a/pyproject.toml b/pyproject.toml index d65860c..575c582 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ members = [ "bzip2", "capnproto", + "catch2", "cppcheck", "eigen", "ffmpeg",