From 44df33e684fef6f93e86eaa2c7694c356e0704fa Mon Sep 17 00:00:00 2001 From: "Leandro G. Almeida" Date: Mon, 1 Jun 2026 09:11:28 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20template:=20expose=20C++=20bind?= =?UTF-8?q?ing=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/repoman/cpp_template/template/README.md.jinja | 8 +++++++- .../cpp_template/template/src/python_bindings.cpp.jinja | 1 + .../template/tests/test_python_bindings.py.jinja | 1 + tests/test_template/test_cpp_template.py | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/repoman/cpp_template/template/README.md.jinja b/src/repoman/cpp_template/template/README.md.jinja index fc203bd..5bf77a0 100644 --- a/src/repoman/cpp_template/template/README.md.jinja +++ b/src/repoman/cpp_template/template/README.md.jinja @@ -41,7 +41,13 @@ make check ``` Python bindings are built by default with pybind11 and expose a module named -`{{ cpp_namespace }}`. Disable them with: +`{{ cpp_namespace }}`. Import the built module from the Meson build directory: + +```bash +PYTHONPATH=build uv run python -c "import {{ cpp_namespace }}; print({{ cpp_namespace }}.add(2, 3))" +``` + +Disable them with: ```bash uv run meson configure build -Dbuild_python_bindings=false diff --git a/src/repoman/cpp_template/template/src/python_bindings.cpp.jinja b/src/repoman/cpp_template/template/src/python_bindings.cpp.jinja index 39b4a1e..606ddd4 100644 --- a/src/repoman/cpp_template/template/src/python_bindings.cpp.jinja +++ b/src/repoman/cpp_template/template/src/python_bindings.cpp.jinja @@ -6,6 +6,7 @@ namespace py = pybind11; PYBIND11_MODULE({{ cpp_namespace }}, module) { module.doc() = "Python bindings for this C++ library."; + module.attr("__version__") = {{ cpp_namespace }}::version(); module.def("version", &{{ cpp_namespace }}::version, "Return the library version."); module.def("add", &{{ cpp_namespace }}::add, py::arg("lhs"), py::arg("rhs"), diff --git a/src/repoman/cpp_template/template/tests/test_python_bindings.py.jinja b/src/repoman/cpp_template/template/tests/test_python_bindings.py.jinja index df6e274..ec69e46 100644 --- a/src/repoman/cpp_template/template/tests/test_python_bindings.py.jinja +++ b/src/repoman/cpp_template/template/tests/test_python_bindings.py.jinja @@ -8,6 +8,7 @@ import importlib def main() -> None: module = importlib.import_module("{{ cpp_namespace }}") assert module.add(2, 3) == 5 + assert module.__version__ == "0.1.0" assert module.version() == "0.1.0" diff --git a/tests/test_template/test_cpp_template.py b/tests/test_template/test_cpp_template.py index 8029637..5736d77 100644 --- a/tests/test_template/test_cpp_template.py +++ b/tests/test_template/test_cpp_template.py @@ -55,6 +55,9 @@ def test_cpp_template_renders_spinach_style_structure(tmp_path: Path) -> None: makefile = _read_text(project_dir / "Makefile") mkdocs = _read_text(project_dir / "config" / "mkdocs.yml") pyproject = _read_text(project_dir / "pyproject.toml") + python_bindings = _read_text(project_dir / "src" / "python_bindings.cpp") + python_bindings_test = _read_text(project_dir / "tests" / "test_python_bindings.py") + readme = _read_text(project_dir / "README.md") github_ci = _read_text(project_dir / ".github" / "workflows" / "ci.yml") assert "subdir('include/sample_cpp')" in meson @@ -63,6 +66,9 @@ def test_cpp_template_renders_spinach_style_structure(tmp_path: Path) -> None: assert "dependency('pybind11')" in meson assert "option('build_python_bindings'" in meson_options assert '"pybind11>=2.13.6"' in pyproject + assert 'module.attr("__version__") = sample_cpp::version();' in python_bindings + assert 'module.__version__ == "0.1.0"' in python_bindings_test + assert "PYTHONPATH=build uv run python" in readme assert "make check-docs" in github_ci assert "make check" in github_ci assert "make test" in github_ci From b09dfae913570b4714f5f3dce8796224f748b57d Mon Sep 17 00:00:00 2001 From: "Leandro G. Almeida" Date: Mon, 1 Jun 2026 12:09:50 -0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20template:=20add=20httpx2=20t?= =?UTF-8?q?est=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/repoman/main_template/pyproject.toml.jinja | 1 + tests/test_template/test_ci.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/repoman/main_template/pyproject.toml.jinja b/src/repoman/main_template/pyproject.toml.jinja index 2a82b08..cb33673 100644 --- a/src/repoman/main_template/pyproject.toml.jinja +++ b/src/repoman/main_template/pyproject.toml.jinja @@ -116,6 +116,7 @@ maintain = [ ci = [ "coverage>=7.13.0", "httpx>=0.28.0", + "httpx2>=2.3.0", "interrogate>=1.7.0", "mypy>=1.19.0", "pytest>=9.0.0", diff --git a/tests/test_template/test_ci.py b/tests/test_template/test_ci.py index b1af05a..2ab03bf 100644 --- a/tests/test_template/test_ci.py +++ b/tests/test_template/test_ci.py @@ -198,6 +198,7 @@ def test_fastapi_template_renders_local_prod_stack_files(tmp_path: Path) -> None compose = _read_text(project_dir / "compose.yml") dockerfile = _read_text(project_dir / "Dockerfile.prod") env_example = _read_text(project_dir / ".env.prod.example") + pyproject = _read_text(project_dir / "pyproject.toml") readme = _read_text(project_dir / "README.md") assert "include make_cmds/prod.mk" in makefile @@ -207,6 +208,7 @@ def test_fastapi_template_renders_local_prod_stack_files(tmp_path: Path) -> None assert 'CMD ["uv", "run", "uvicorn"' in dockerfile assert "RUN uv sync --no-dev --no-editable --no-default-groups" in dockerfile assert "OPENAI_API_KEY=replace-me" in env_example + assert '"httpx2>=2.3.0"' in pyproject assert "make prod" in readme