Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Hatch plugin for C++

License

NotificationsYou must be signed in to change notification settings

python-project-templates/hatch-cpp

Repository files navigation

Hatch plugin for C++ builds

Build StatuscodecovLicensePyPI

Overview

A simple, extensible C++ build plugin forhatch.

[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 apyproject.toml.It is designed to closely match existing Python/C/C++ packaging tools.

verbose =truelibraries = { Library Args }cmake = { CMake Args }platform = { Platform, either "linux", "darwin", or "win32" }

See thetest cases for more concrete examples.

hatch-cpp is driven bypydantic models for configuration and execution of the build.These models can themselves be overridden by settingbuild-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 passcmake_env_args = {}# env-specific cmake args to passinclude_flags = {}# include flags to pass -D

Environment Variables

hatch-cpp will respect standard environment variables for compiler control.

NameDefaultDescription
CCC Compiler override
CXXC++ Compiler override
LDLinker override
HATCH_CPP_PLATFORMPlatform to build
HATCH_CPP_DISABLE_CCACHEDisable CCache usage

Note

This library was generated usingcopier from theBase Python Project Template repository.


[8]ページ先頭

©2009-2025 Movatter.jp