Skip to content

Commit e1d754c

Browse files
committed
Update readme docs
1 parent 40e796a commit e1d754c

File tree

1 file changed

+68
-9
lines changed

1 file changed

+68
-9
lines changed

README.md

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,74 @@ For more complete systems, see:
2323
- [scikit-build-core](https://github.com/scikit-build/scikit-build-core)
2424
- [setuptools](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html)
2525

26-
## Environment Variables
27-
28-
| Name | Default | Description |
29-
| :------------------------- | :------ | :---------- |
30-
| `CC` | | |
31-
| `CXX` | | |
32-
| `LD` | | |
33-
| `HATCH_CPP_PLATFORM` | | |
34-
| `HATCH_CPP_DISABLE_CCACHE` | | |
26+
## Configuration
27+
28+
Configuration is driven from the `[tool.hatch.build.hooks.hatch-cpp]` hatch hook configuration field in a `pyproject.toml`.
29+
It is designed to closely match existing Python/C/C++ packaging tools.
30+
31+
```toml
32+
verbose = true
33+
libraries = { Library Args }
34+
cmake = { CMake Args }
35+
platform = { Platform, either "linux", "darwin", or "win32" }
36+
```
37+
38+
See the [test cases](./hatch_cpp/tests/) for more concrete examples.
39+
40+
### Library Arguments
41+
42+
```toml
43+
name = "mylib"
44+
sources = [
45+
"path/to/file.cpp",
46+
]
47+
language = "c++"
48+
49+
binding = "cpython" # or "pybind11", "nanobind", "generic"
50+
std = "" # Passed to -std= or /std:
51+
52+
include_dirs = ["paths/to/add/to/-I"]
53+
library_dirs = ["paths/to/add/to/-L"]
54+
libraries = ["-llibraries_to_link"]
55+
56+
extra_compile_args = ["--extra-compile-args"]
57+
extra_link_args = ["--extra-link-args"]
58+
extra_objects = ["extra_objects"]
59+
60+
define_macros = ["-Ddefines_to_use"]
61+
undef_macros = ["-Uundefines_to_use"]
62+
63+
py_limited_api = "cp39" # limited API to use
64+
```
65+
66+
### CMake Arguments
67+
68+
`hatch-cpp` has some convenience integration with CMake.
69+
Though this is not designed to be as full-featured as e.g. `scikit-build`, it should be satisfactory for many small projects.
70+
71+
```toml
72+
root = "path/to/cmake/root"
73+
build = "path/to/cmake/build/folder"
74+
install = "path/to/cmake/install/folder"
75+
76+
cmake_arg_prefix = "MYPROJECT_"
77+
cmake_args = {} # any other cmake args to pass
78+
cmake_env_args = {} # env-specific cmake args to pass
79+
80+
include_flags = {} # include flags to pass -D
81+
```
82+
83+
### Environment Variables
84+
85+
`hatch-cpp` will respect standard environment variables for compiler control.
86+
87+
| Name | Default | Description |
88+
| :------------------------- | :------ | :-------------------- |
89+
| `CC` | | C Compiler override |
90+
| `CXX` | | C++ Compiler override |
91+
| `LD` | | Linker override |
92+
| `HATCH_CPP_PLATFORM` | | Platform to build |
93+
| `HATCH_CPP_DISABLE_CCACHE` | | Disable CCache usage |
3594

3695
> [!NOTE]
3796
> 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).

0 commit comments

Comments
 (0)