-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
62 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
src/scicookie/{{cookiecutter.project_slug}}/build-system/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
{% if cookiecutter.build_system == "scikit-build-core" -%} | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
|
||
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX) | ||
|
||
{% if cookiecutter.build_system == "scikit-build-core" -%} | ||
|
||
find_package(pybind11 CONFIG REQUIRED) | ||
|
||
pybind11_add_module(skcdemo MODULE skcdemo.cpp) | ||
|
||
install(TARGETS skcdemo DESTINATION .) | ||
|
||
{% elif cookiecutter.build_system == "pybind11" -%} | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
|
||
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX) | ||
|
||
find_package(pybind11 CONFIG REQUIRED) | ||
|
||
pybind11_add_module(pybind11 MODULE pybind11.cpp) | ||
pybind11_add_module(_core MODULE src/main.cpp) | ||
|
||
install(TARGETS pybind11 DESTINATION .) | ||
install(TARGETS _core DESTINATION .) | ||
|
||
{%- endif %} |
28 changes: 28 additions & 0 deletions
28
src/scicookie/{{cookiecutter.project_slug}}/build-system/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <pybind11/pybind11.h> | ||
|
||
int add(int i, int j) { return i + j; } | ||
|
||
namespace py = pybind11; | ||
|
||
PYBIND11_MODULE(_core, m) { | ||
m.doc() = R"pbdoc( | ||
Pybind11 example plugin | ||
----------------------- | ||
.. currentmodule:: python_example | ||
.. autosummary:: | ||
:toctree: _generate | ||
add | ||
subtract | ||
)pbdoc"; | ||
|
||
m.def("add", &add, R"pbdoc( | ||
Add two numbers | ||
Some other explanation about the add function. | ||
)pbdoc"); | ||
|
||
m.def( | ||
"subtract", [](int i, int j) { return i - j; }, R"pbdoc( | ||
Subtract two numbers | ||
Some other explanation about the subtract function. | ||
)pbdoc"); | ||
} |
9 changes: 0 additions & 9 deletions
9
src/scicookie/{{cookiecutter.project_slug}}/build-system/pybind11.cpp
This file was deleted.
Oops, something went wrong.
32 changes: 19 additions & 13 deletions
32
src/scicookie/{{cookiecutter.project_slug}}/build-system/setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
from setuptools import setup # isort:skip | ||
|
||
# Available at setup time due to pyproject.toml | ||
from pybind11.setup_helpers import Pybind11Extension | ||
from setuptools import setup | ||
from pybind11.setup_helpers import Pybind11Extension # isort:skip | ||
|
||
# Note: | ||
# Sort input source files if you glob sources to ensure bit-for-bit | ||
# reproducible builds (https://github.com/pybind/python_example/pull/53) | ||
|
||
ext_modules = [ | ||
Pybind11Extension( | ||
"{{ cookiecutter.project_slug }}._core", | ||
["src/main.cpp"], | ||
cxx_std=11, | ||
), | ||
] | ||
|
||
|
||
setup( | ||
name="OSL Python package", | ||
author="{{cookiecutter.author_full_name}}", | ||
author_email="{{cookiecutter.author_email}}", | ||
url="https://{{ cookiecutter.project_slug }}.com", | ||
description="A test project using pybind11", | ||
long_description="", | ||
#extras_require={"test": "pytest"}, | ||
# Currently, build_ext only provides an optional "highest supported C++ | ||
# level" feature, but in the future it may provide more features. | ||
python_requires=">=3.7", | ||
) | ||
ext_modules=ext_modules, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters