Hatch plugin for C++ builds
Project description
hatch-cpp
Hatch plugin for C++ builds
Overview
A simple, extensible C++ build plugin for hatch.
[tool.hatch.build.hooks.hatch-cpp]
libraries = [
{name = "project/extension", sources = ["cpp/project/basic.cpp"], include-dirs = ["cpp"]}
]
For more complete systems, see:
Configuration
Configuration is driven from the [tool.hatch.build.hooks.hatch-cpp] hatch hook configuration field in a pyproject.toml.
It is designed to closely match existing Python/C/C++ packaging tools.
verbose = true
libraries = { Library Args }
cmake = { CMake Args }
platform = { Platform, either "linux", "darwin", or "win32" }
See the test cases for more concrete examples.
hatch-cpp is driven by pydantic models for configuration and execution of the build.
These models can themselves be overridden by setting build-config-class / build-plan-class.
Library Arguments
name = "mylib"
sources = [
"path/to/file.cpp",
]
language = "c++"
binding = "cpython" # or "pybind11", "nanobind", "generic"
std = "" # Passed to -std= or /std:
include_dirs = ["paths/to/add/to/-I"]
library_dirs = ["paths/to/add/to/-L"]
libraries = ["-llibraries_to_link"]
extra_compile_args = ["--extra-compile-args"]
extra_link_args = ["--extra-link-args"]
extra_objects = ["extra_objects"]
define_macros = ["-Ddefines_to_use"]
undef_macros = ["-Uundefines_to_use"]
py_limited_api = "cp39" # limited API to use
CMake Arguments
hatch-cpp has some convenience integration with CMake.
Though this is not designed to be as full-featured as e.g. scikit-build, it should be satisfactory for many small projects.
root = "path/to/cmake/root"
build = "path/to/cmake/build/folder"
install = "path/to/cmake/install/folder"
cmake_arg_prefix = "MYPROJECT_"
cmake_args = {} # any other cmake args to pass
cmake_env_args = {} # env-specific cmake args to pass
include_flags = {} # include flags to pass -D
Environment Variables
hatch-cpp will respect standard environment variables for compiler control.
| Name | Default | Description |
|---|---|---|
CC |
C Compiler override | |
CXX |
C++ Compiler override | |
LD |
Linker override | |
HATCH_CPP_PLATFORM |
Platform to build | |
HATCH_CPP_DISABLE_CCACHE |
Disable CCache usage |
[!NOTE] This library was generated using copier from the Base Python Project Template repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hatch_cpp-0.1.8.tar.gz.
File metadata
- Download URL: hatch_cpp-0.1.8.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efe69e16e3d501b5640cc17f9a79d352ea5231dd8192791347523a918b9356da
|
|
| MD5 |
c6d69393e196df9066857597d46a0af1
|
|
| BLAKE2b-256 |
8c179235f41a1559069a215f1267941916ce24204dfc8f6b3f1c4044ce81cd7f
|
File details
Details for the file hatch_cpp-0.1.8-py3-none-any.whl.
File metadata
- Download URL: hatch_cpp-0.1.8-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
929a61989c48b6c27ee9da69dedc1ec14a490975bd3a6713e9b7718336c76645
|
|
| MD5 |
686ceade1060d881928e446e8bf8f467
|
|
| BLAKE2b-256 |
ffc32f25bf244a5a813f3b02e4fd4a9ea2f0b9bdeec391e0220b99efa04437af
|