Skip to content

Commit f127dd0

Browse files
feat: add hatchling example (#44)
* feat: add hatchling example Signed-off-by: Henry Schreiner <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 258ecf8 commit f127dd0

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

noxfile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
hello_list = ["hello-pure", "hello-cpp", "hello-pybind11", "hello-cython"]
99
if not sys.platform.startswith("win"):
1010
hello_list.extend(["hello-cmake-package", "pi-fortran"])
11-
long_hello_list = [*hello_list, "pen2-cython", "core-c-hello", "core-pybind11-hello"]
11+
long_hello_list = [
12+
*hello_list,
13+
"pen2-cython",
14+
"core-c-hello",
15+
"core-pybind11-hello",
16+
"hatchling-pybind11-hello",
17+
]
1218

1319

1420
@nox.session
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.15...3.29)
2+
3+
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX)
4+
5+
set(PYBIND11_FINDPYTHON ON)
6+
find_package(pybind11 CONFIG REQUIRED)
7+
8+
pybind11_add_module(_core MODULE cpp/_core.cpp)
9+
10+
install(TARGETS _core DESTINATION skcdemo)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <pybind11/pybind11.h>
2+
3+
namespace py = pybind11;
4+
5+
PYBIND11_MODULE(_core, m) {
6+
m.def("hello", [](){
7+
py::print("Hello, scikit-build!");
8+
});
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[build-system]
2+
requires = ["hatchling", "scikit-build-core~=0.9.0", "pybind11"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "skcdemo"
7+
version = "0.1.0"
8+
9+
[tool.hatch.build.targets.wheel.hooks.scikit-build]
10+
experimental = true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ._core import hello
2+
3+
__all__ = ["hello"]

0 commit comments

Comments
 (0)