Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/repoman/cpp_template/template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
1 change: 1 addition & 0 deletions src/repoman/main_template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_template/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
6 changes: 6 additions & 0 deletions tests/test_template/test_cpp_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading