Skip to content
Snippets Groups Projects
Commit c461afa5 authored by Xuefeng Ding's avatar Xuefeng Ding
Browse files

good template now

parent 55f3e971
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,9 @@ project("${SKBUILD_PROJECT_NAME}"
LANGUAGES CXX
VERSION "${SKBUILD_PROJECT_VERSION}")
# include(GNUInstallDirs)
set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 CONFIG REQUIRED)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# include(GNUInstallDirs)
add_subdirectory(cpp)
add_subdirectory(src/myproj/simulation/_csrc)
\ No newline at end of file
add_subdirectory(python/myproj/simulation/_csrc)
\ No newline at end of file
......@@ -8,4 +8,33 @@ use scikit-build-core to setup a python-cmake project that can be installed with
## Conclusion
cannot make packages like import myproj.simulation. It replaces "." with "_"
- cannot make packages like import myproj.simulation. It replaces "." with "_"
- most of the case, check following
```cmake
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/my_main.py DESTINATION .)
```
and set
```
[tool.scikit-build]
wheel.install-dir = "kk/ss"
```
## special variable
- `${SKBUILD_PLATLIB_DIR}`: The original platlib directory. Anything here goes
directly to site-packages when a wheel is installed.
- `${SKBUILD_DATA_DIR}`: The data directory. Anything here goes to the root of
the environment when a wheel is installed (use with care).
- `${SKBUILD_HEADERS_DIR}`: The header directory. Anything in here gets
installed to Python's header directory.
- `${SKBUILD_SCRIPTS_DIR}`: The scripts directory. Anything placed in here will
go to `bin` (Unix) or `Scripts` (Windows).
- `${SKBUILD_METADATA_DIR}`: The dist-info directory. Licenses go in the
`licenses` subdirectory. _Note that CMake is not run in the
`prepare_metadata_\*` hooks, so anything written to this directory will only
be present when writing wheels.\_
- `${SKBUILD_NULL_DIR}`: Anything installed here will not be placed in the
wheel.
......@@ -2,18 +2,17 @@ add_library(hello SHARED src/hello.cc)
target_include_directories(hello PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(
TARGETS hello
LIBRARY DESTINATION ${SKBUILD_SCRIPTS_DIR})
install(TARGETS hello LIBRARY DESTINATION .)
add_library(complex SHARED src/complex.cc)
target_include_directories(complex PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(complex PRIVATE hello)
install(
TARGETS complex
LIBRARY DESTINATION ${SKBUILD_SCRIPTS_DIR})
install(TARGETS complex LIBRARY DESTINATION .)
set_target_properties(complex PROPERTIES
INSTALL_RPATH "$ORIGIN"
)
# install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
......
......@@ -3,7 +3,7 @@ requires = ["scikit-build-core", "pybind11"]
build-backend = "scikit_build_core.build"
[project]
name = "myproj.simulation"
name = "myproj_simulation"
version = "0.2.1"
description = "A great package."
readme = "README.md"
......@@ -36,4 +36,11 @@ Homepage = "https://github.com/organization/package"
Documentation = "https://package.readthedocs.io/"
"Bug Tracker" = "https://github.com/organization/package/issues"
Discussions = "https://github.com/organization/package/discussions"
Changelog = "https://package.readthedocs.io/en/latest/changelog.html"
\ No newline at end of file
Changelog = "https://package.readthedocs.io/en/latest/changelog.html"
[tool.scikit-build.wheel.packages]
"myproj/simulation" = "python/myproj/simulation"
[tool.scikit-build]
wheel.install-dir = "myproj/simulation"
wheel.exclude = ["CMakeLists.txt","*.cc","*.h"]
\ No newline at end of file
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(_hello MODULE _hello_python.cc)
target_link_libraries(_hello PRIVATE hello complex)
install(TARGETS _hello DESTINATION _csrc)
set_target_properties(_hello PROPERTIES
INSTALL_RPATH "$ORIGIN/.."
)
\ No newline at end of file
......@@ -4,7 +4,7 @@
namespace py = pybind11;
PYBIND11_MODULE(hello_python, m) {
PYBIND11_MODULE(_hello, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function which adds two numbers");
......
File moved
pybind11_add_module(_hello MODULE hello_python.cc)
target_link_libraries(_hello PRIVATE hello complex)
install(TARGETS _hello DESTINATION ${SKBUILD_PROJECT_NAME})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment