{"id":45820975,"url":"https://github.com/python-project-templates/hatch-cpp","last_synced_at":"2026-02-26T20:40:16.419Z","repository":{"id":271803922,"uuid":"826428304","full_name":"python-project-templates/hatch-cpp","owner":"python-project-templates","description":"Hatch plugin for C++","archived":false,"fork":false,"pushed_at":"2026-02-25T05:03:18.000Z","size":197,"stargazers_count":3,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-25T07:53:37.509Z","etag":null,"topics":["build","build-tool","cli","cpp","hatch","hatchling","packaging","plugin","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-project-templates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-09T17:31:40.000Z","updated_at":"2026-02-25T05:03:19.000Z","dependencies_parsed_at":"2025-01-10T01:28:24.075Z","dependency_job_id":"9d8dc463-fdd5-4bb4-8535-21e084045e28","html_url":"https://github.com/python-project-templates/hatch-cpp","commit_stats":null,"previous_names":["python-project-templates/hatch-cpp"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/python-project-templates/hatch-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fhatch-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fhatch-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fhatch-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fhatch-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-project-templates","download_url":"https://codeload.github.com/python-project-templates/hatch-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-project-templates%2Fhatch-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29872290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T18:42:30.764Z","status":"ssl_error","status_checked_at":"2026-02-26T18:41:47.936Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","build-tool","cli","cpp","hatch","hatchling","packaging","plugin","python"],"created_at":"2026-02-26T20:40:14.399Z","updated_at":"2026-02-26T20:40:16.414Z","avatar_url":"https://github.com/python-project-templates.png","language":"Python","readme":"# hatch-cpp\n\nHatch plugin for C++ builds\n\n[![Build Status](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yaml/badge.svg?branch=main\u0026event=push)](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yaml)\n[![codecov](https://codecov.io/gh/python-project-templates/hatch-cpp/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/hatch-cpp)\n[![License](https://img.shields.io/github/license/python-project-templates/hatch-cpp)](https://github.com/python-project-templates/hatch-cpp)\n[![PyPI](https://img.shields.io/pypi/v/hatch-cpp.svg)](https://pypi.python.org/pypi/hatch-cpp)\n\n## Overview\n\nA simple, extensible C++ build plugin for [hatch](https://hatch.pypa.io/latest/).\n\n```toml\n[tool.hatch.build.hooks.hatch-cpp]\nlibraries = [\n    {name = \"project/extension\", sources = [\"cpp/project/basic.cpp\"], include-dirs = [\"cpp\"]}\n]\n```\n\nFor more complete systems, see:\n\n- [scikit-build-core](https://github.com/scikit-build/scikit-build-core)\n- [setuptools](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html)\n\n## Configuration\n\nConfiguration is driven from the `[tool.hatch.build.hooks.hatch-cpp]` hatch hook configuration field in a `pyproject.toml`.\nIt is designed to closely match existing Python/C/C++ packaging tools.\n\n```toml\nverbose = true\nlibraries = { Library Args }\ncmake = { CMake Args }\nplatform = { Platform, either \"linux\", \"darwin\", or \"win32\" }\n```\n\nSee the [test cases](./hatch_cpp/tests/) for more concrete examples.\n\n`hatch-cpp` is driven by [pydantic](https://docs.pydantic.dev/latest/) models for configuration and execution of the build.\nThese models can themselves be overridden by setting `build-config-class` / `build-plan-class`.\n\n### Library Arguments\n\n```toml\nname = \"mylib\"\nsources = [\n    \"path/to/file.cpp\",\n]\nlanguage = \"c++\"\n\nbinding = \"cpython\" # or \"pybind11\", \"nanobind\", \"generic\"\nstd = \"\" # Passed to -std= or /std:\n\ninclude_dirs = [\"paths/to/add/to/-I\"]\nlibrary_dirs = [\"paths/to/add/to/-L\"]\nlibraries = [\"-llibraries_to_link\"]\n\nextra_compile_args = [\"--extra-compile-args\"]\nextra_link_args = [\"--extra-link-args\"]\nextra_objects = [\"extra_objects\"]\n\ndefine_macros = [\"-Ddefines_to_use\"]\nundef_macros = [\"-Uundefines_to_use\"]\n\npy_limited_api = \"cp39\"  # limited API to use\n```\n\n### CMake Arguments\n\n`hatch-cpp` has some convenience integration with CMake.\nThough this is not designed to be as full-featured as e.g. `scikit-build`, it should be satisfactory for many small projects.\n\n```toml\nroot = \"path/to/cmake/root\"\nbuild = \"path/to/cmake/build/folder\"\ninstall = \"path/to/cmake/install/folder\"\n\ncmake_arg_prefix = \"MYPROJECT_\"\ncmake_args = {}  # any other cmake args to pass\ncmake_env_args = {} # env-specific cmake args to pass\n\ninclude_flags = {} # include flags to pass -D\n```\n\n### CLI\n\n`hatch-cpp` is integrated with [`hatch-build`](https://github.com/python-project-templates/hatch-build) to allow easy configuration of options via command line:\n\n```bash\nhatch-build \\\n    -- \\\n    --verbose \\\n    --platform linux \\\n    --vcpkg.vcpkg a/path/to/vcpkg.json \\\n    --libraries.0.binding pybind11 \\\n    --libraries.0.include-dirs cpp,another-dir\n```\n\nThis CLI is aware of your `pyproject.toml`-configured setup.\nTo display help for this, run (note the passthrough `--`):\n\n```bash\nhatch-build -- --help\n```\n\nFor example, for the `test_project_basic` in this project's `tests` folder:\n\n```raw\nhatch-build --hooks-only -- --help\n[sdist]\n\n[wheel]\n[2025-11-11T17:31:06-0500][p2a][WARNING]: Only dicts with str, int, float, bool, or enum values are supported - field `cmake_env_args` got value type typing.Dict[str, str]\nusage: hatch-build-extras-model [-h] [--verbose] [--name NAME] [--libraries.0.name LIBRARIES.0.NAME]\n                                [--libraries.0.sources.0 LIBRARIES.0.SOURCES.0] [--libraries.0.sources LIBRARIES.0.SOURCES]\n                                [--libraries.0.language LIBRARIES.0.LANGUAGE] [--libraries.0.binding LIBRARIES.0.BINDING]\n                                [--libraries.0.std LIBRARIES.0.STD] [--libraries.0.include-dirs.0 LIBRARIES.0.INCLUDE_DIRS.0]\n                                [--libraries.0.include-dirs LIBRARIES.0.INCLUDE_DIRS]\n                                [--libraries.0.library-dirs LIBRARIES.0.LIBRARY_DIRS]\n                                [--libraries.0.libraries LIBRARIES.0.LIBRARIES]\n                                [--libraries.0.extra-compile-args LIBRARIES.0.EXTRA_COMPILE_ARGS]\n                                [--libraries.0.extra-link-args LIBRARIES.0.EXTRA_LINK_ARGS]\n                                [--libraries.0.extra-objects LIBRARIES.0.EXTRA_OBJECTS]\n                                [--libraries.0.define-macros LIBRARIES.0.DEFINE_MACROS]\n                                [--libraries.0.undef-macros LIBRARIES.0.UNDEF_MACROS]\n                                [--libraries.0.export-symbols LIBRARIES.0.EXPORT_SYMBOLS]\n                                [--libraries.0.depends LIBRARIES.0.DEPENDS]\n                                [--libraries.0.py-limited-api LIBRARIES.0.PY_LIMITED_API] [--cmake.root CMAKE.ROOT]\n                                [--cmake.build CMAKE.BUILD] [--cmake.install CMAKE.INSTALL]\n                                [--cmake.cmake-arg-prefix CMAKE.CMAKE_ARG_PREFIX] [--cmake.cmake-args CMAKE.CMAKE_ARGS]\n                                [--cmake.include-flags CMAKE.INCLUDE_FLAGS] [--platform.cc PLATFORM.CC]\n                                [--platform.cxx PLATFORM.CXX] [--platform.ld PLATFORM.LD] [--platform.platform PLATFORM.PLATFORM]\n                                [--platform.toolchain PLATFORM.TOOLCHAIN] [--platform.disable-ccache] [--vcpkg.vcpkg VCPKG.VCPKG]\n                                [--vcpkg.vcpkg-root VCPKG.VCPKG_ROOT] [--vcpkg.vcpkg-repo VCPKG.VCPKG_REPO]\n                                [--vcpkg.vcpkg-triplet VCPKG.VCPKG_TRIPLET] [--build-type BUILD_TYPE] [--commands COMMANDS]\n\noptions:\n  -h, --help            show this help message and exit\n  --verbose\n  --name NAME\n  --libraries.0.name LIBRARIES.0.NAME\n  --libraries.0.sources.0 LIBRARIES.0.SOURCES.0\n  --libraries.0.sources LIBRARIES.0.SOURCES\n  --libraries.0.language LIBRARIES.0.LANGUAGE\n  --libraries.0.binding LIBRARIES.0.BINDING\n  --libraries.0.std LIBRARIES.0.STD\n  --libraries.0.include-dirs.0 LIBRARIES.0.INCLUDE_DIRS.0\n  --libraries.0.include-dirs LIBRARIES.0.INCLUDE_DIRS\n  --libraries.0.library-dirs LIBRARIES.0.LIBRARY_DIRS\n  --libraries.0.libraries LIBRARIES.0.LIBRARIES\n  --libraries.0.extra-compile-args LIBRARIES.0.EXTRA_COMPILE_ARGS\n  --libraries.0.extra-link-args LIBRARIES.0.EXTRA_LINK_ARGS\n  --libraries.0.extra-objects LIBRARIES.0.EXTRA_OBJECTS\n  --libraries.0.define-macros LIBRARIES.0.DEFINE_MACROS\n  --libraries.0.undef-macros LIBRARIES.0.UNDEF_MACROS\n  --libraries.0.export-symbols LIBRARIES.0.EXPORT_SYMBOLS\n  --libraries.0.depends LIBRARIES.0.DEPENDS\n  --libraries.0.py-limited-api LIBRARIES.0.PY_LIMITED_API\n  --cmake.root CMAKE.ROOT\n  --cmake.build CMAKE.BUILD\n  --cmake.install CMAKE.INSTALL\n  --cmake.cmake-arg-prefix CMAKE.CMAKE_ARG_PREFIX\n  --cmake.cmake-args CMAKE.CMAKE_ARGS\n  --cmake.include-flags CMAKE.INCLUDE_FLAGS\n  --platform.cc PLATFORM.CC\n  --platform.cxx PLATFORM.CXX\n  --platform.ld PLATFORM.LD\n  --platform.platform PLATFORM.PLATFORM\n  --platform.toolchain PLATFORM.TOOLCHAIN\n  --platform.disable-ccache\n  --vcpkg.vcpkg VCPKG.VCPKG\n  --vcpkg.vcpkg-root VCPKG.VCPKG_ROOT\n  --vcpkg.vcpkg-repo VCPKG.VCPKG_REPO\n  --vcpkg.vcpkg-triplet VCPKG.VCPKG_TRIPLET\n  --build-type BUILD_TYPE\n  --commands COMMANDS\n```\n\n### Environment Variables\n\n`hatch-cpp` will respect standard environment variables for compiler control, e.g. `CC`, `CXX`, `LD`, `CMAKE_GENERATOR`, `OSX_DEPLOYMENT_TARGET`, etc.\n\n\u003e [!NOTE]\n\u003e This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-project-templates%2Fhatch-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-project-templates%2Fhatch-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-project-templates%2Fhatch-cpp/lists"}