@@ -18,12 +18,13 @@ path = "."
1818module = " project"
1919```
2020
21- ### Shared C ABI libraries
21+ ### Rust artifacts and C ABI libraries
2222
23- Projects can declare multiple Rust artifacts in one hook. A ` python-extension `
24- artifact keeps the existing PyO3 extension flow, while a ` shared-library `
25- artifact builds a standalone ` cdylib ` , copies the exact platform library name to
26- the configured destination, and includes it in the wheel.
23+ Projects can declare multiple Rust artifacts in one hook. Artifact ` name ` is the
24+ Cargo output stem used for exact file discovery, and ` crate-type ` defaults to
25+ ` cdylib ` . A destination containing ` {python_extension_name} ` packages that
26+ ` cdylib ` as a Python extension module; other Rust artifact destinations package
27+ the platform shared library name for standalone C ABI consumers.
2728
2829``` toml
2930[tool .hatch .build .hooks .hatch-rs ]
@@ -33,35 +34,30 @@ module = "project"
3334target-dir = " isolated"
3435
3536[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
36- name = " python-extension"
37- kind = " python-extension"
37+ name = " project"
3838manifest = " Cargo.toml"
39- library = " project"
39+ destination = " project/{python_extension_name} "
4040
4141[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
42- name = " c-abi"
43- kind = " shared-library"
42+ name = " project_ffi"
4443manifest = " rust/Cargo.toml"
45- library = " project_ffi"
46- crate-type = " cdylib"
4744destination = " project/lib/{shared_library}"
4845```
4946
50- Destination templates support ` {module} ` , ` {target} ` , ` {profile} ` , ` {library } ` ,
51- ` {shared_library} ` , and ` {python_extension_name} ` .
47+ Destination templates support ` {module} ` , ` {target} ` , ` {profile} ` , ` {name } ` ,
48+ ` {shared_library} ` , ` {import_library} ` , and ` {python_extension_name} ` .
5249
5350### Generated files and headers
5451
55- ` command ` artifacts run an argv-list command and then validate explicit outputs.
56- Outputs can be packaged into the wheel, installed as wheel shared data, or used
57- only as required validation checks. ` header ` artifacts are a typed shorthand for
58- validated header outputs and can also use ` generator = "cbindgen" ` in CLI or
59- build-script mode .
52+ Artifacts with ` command ` run an argv-list command and then validate explicit
53+ outputs. Outputs can be packaged into the wheel, installed as wheel shared data,
54+ or used only as required validation checks. The same ` outputs ` table can be used
55+ for generated headers, either on a command artifact or on the Rust artifact whose
56+ build produced the file .
6057
6158``` toml
6259[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
6360name = " generated-package-files"
64- kind = " command"
6561command = [" python" , " scripts/write_generated_files.py" ]
6662inputs = [" scripts/write_generated_files.py" ]
6763
@@ -72,19 +68,20 @@ install-scheme = "package"
7268
7369[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
7470name = " public-c-header"
75- kind = " header"
71+
72+ [[tool .hatch .build .hooks .hatch-rs .artifacts .outputs ]]
7673source = " project/include/project.h"
7774destination = " include/project/project.h"
7875install-scheme = " shared-data"
7976```
8077
8178### ABI validation and artifact metadata
8279
83- Shared-library artifacts can validate the copied C ABI library before the wheel
84- is finalized. The hook can check expected exported symbols, verify headers and
85- ABI strings/macros, load the copied library with ` ctypes.CDLL ` , run project
86- validation commands, include Windows import libraries, and emit a package-local
87- artifact manifest.
80+ ` cdylib ` artifacts can validate the copied C ABI library before the wheel is
81+ finalized. The hook can check expected exported symbols, verify headers and ABI
82+ strings/macros, load the copied library with ` ctypes.CDLL ` when ` validate = true ` ,
83+ run project validation commands, include Windows import libraries, and emit a
84+ package-local artifact manifest.
8885
8986``` toml
9087[tool .hatch .build .hooks .hatch-rs ]
@@ -93,16 +90,13 @@ target-dir = "isolated"
9390artifact-manifest = true
9491
9592[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
96- name = " c-abi"
97- kind = " shared-library"
93+ name = " project_ffi"
9894manifest = " rust/Cargo.toml"
99- library = " project_ffi"
100- crate-type = " cdylib"
10195destination = " project/lib/{shared_library}"
10296expected-symbols = [" project_ffi_answer" ]
10397expected-headers = [" project/include/project.h" ]
10498expected-abi-strings = [" PROJECT_ABI_VERSION" ]
105- runtime-load = true
99+ validate = true
106100include-import-lib = true
107101
108102[[tool .hatch .build .hooks .hatch-rs .artifacts .validation-commands ]]
@@ -130,17 +124,13 @@ module = "project"
130124target-dir = " isolated"
131125
132126[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
133- name = " python-extension"
134- kind = " python-extension"
127+ name = " project"
135128manifest = " Cargo.toml"
136- library = " project"
129+ destination = " project/{python_extension_name} "
137130
138131[[tool .hatch .build .hooks .hatch-rs .artifacts ]]
139- name = " c-abi"
140- kind = " shared-library"
132+ name = " project_ffi"
141133manifest = " rust/Cargo.toml"
142- library = " project_ffi"
143- crate-type = " cdylib"
144134destination = " project/lib/{shared_library}"
145135
146136[tool .cibuildwheel ]
0 commit comments