From 8e224d136200917fa967d4c6c4f73c5b336a25e3 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 16 Nov 2024 23:05:40 +0800 Subject: [PATCH] build: optimize python ffi packing --- src/core/main.cc | 3 --- src/core_ffi/py_ffi/CMakeLists.txt | 4 ++++ src/core_ffi/py_ffi/packing/CMakeLists.txt | 8 +------- src/core_ffi/py_ffi/packing/MANIFEST.in | 20 ++++++++++++++----- src/core_ffi/py_ffi/packing/setup.py | 1 + .../py_ffi/packing/src/CMakeLists.txt | 1 + src/core_ffi/py_ffi/packing/src/core | 1 + src/core_ffi/py_ffi/packing/src/core_ffi | 1 + src/core_ffi/py_ffi/packing/src/project | 1 - src/core_ffi/py_ffi/packing/third_party | 1 + third_party/ThirdParty.cmake | 2 ++ 11 files changed, 27 insertions(+), 16 deletions(-) mode change 100644 => 120000 src/core_ffi/py_ffi/packing/CMakeLists.txt create mode 120000 src/core_ffi/py_ffi/packing/src/CMakeLists.txt create mode 120000 src/core_ffi/py_ffi/packing/src/core create mode 120000 src/core_ffi/py_ffi/packing/src/core_ffi delete mode 120000 src/core_ffi/py_ffi/packing/src/project create mode 120000 src/core_ffi/py_ffi/packing/third_party diff --git a/src/core/main.cc b/src/core/main.cc index 44dbc52..a4f45b0 100644 --- a/src/core/main.cc +++ b/src/core/main.cc @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -16,8 +15,6 @@ #include -#include "../../third_party/thread-pool/include/BS_thread_pool.hpp" - using klotski::mover::MaskMover; using klotski::fast_cal::FastCal; diff --git a/src/core_ffi/py_ffi/CMakeLists.txt b/src/core_ffi/py_ffi/CMakeLists.txt index ed2e2d2..9a2911b 100644 --- a/src/core_ffi/py_ffi/CMakeLists.txt +++ b/src/core_ffi/py_ffi/CMakeLists.txt @@ -23,3 +23,7 @@ pybind11_add_module(klotski_py target_include_directories(klotski_py PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(klotski_py PRIVATE klotski::core) set_target_properties(klotski_py PROPERTIES OUTPUT_NAME _klotski) + +if (SKBUILD) + install(TARGETS klotski_py DESTINATION .) +endif() diff --git a/src/core_ffi/py_ffi/packing/CMakeLists.txt b/src/core_ffi/py_ffi/packing/CMakeLists.txt deleted file mode 100644 index f48e1d0..0000000 --- a/src/core_ffi/py_ffi/packing/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.12) - -project(klotski_py_demo VERSION "0.0.1") - -add_subdirectory(src/project) - -install(TARGETS klotski_py DESTINATION .) diff --git a/src/core_ffi/py_ffi/packing/CMakeLists.txt b/src/core_ffi/py_ffi/packing/CMakeLists.txt new file mode 120000 index 0000000..75f9ac9 --- /dev/null +++ b/src/core_ffi/py_ffi/packing/CMakeLists.txt @@ -0,0 +1 @@ +../../../../CMakeLists.txt \ No newline at end of file diff --git a/src/core_ffi/py_ffi/packing/MANIFEST.in b/src/core_ffi/py_ffi/packing/MANIFEST.in index d36c238..ec9f3f7 100644 --- a/src/core_ffi/py_ffi/packing/MANIFEST.in +++ b/src/core_ffi/py_ffi/packing/MANIFEST.in @@ -1,8 +1,18 @@ -include CMakeLists.txt -include README.md include pyproject.toml include setup.py -include src/klotski/__init__.py -recursive-include src/project * -recursive-exclude src/project/src/core_ffi/py_ffi/packing * +include README.md exclude MANIFEST.in + +include src/klotski/*.py + +include CMakeLists.txt +include src/CMakeLists.txt +include src/core_ffi/CMakeLists.txt + +recursive-include src/core * +recursive-include src/core_ffi/py_ffi * +recursive-exclude src/core_ffi/py_ffi/packing * + +include third_party/ThirdParty.cmake +recursive-include third_party/pybind11 * +recursive-include third_party/parallel-hashmap * diff --git a/src/core_ffi/py_ffi/packing/setup.py b/src/core_ffi/py_ffi/packing/setup.py index d6a760f..43d50f1 100644 --- a/src/core_ffi/py_ffi/packing/setup.py +++ b/src/core_ffi/py_ffi/packing/setup.py @@ -9,5 +9,6 @@ setup( packages=["klotski"], package_dir={"": "src"}, cmake_install_dir="src/klotski", + cmake_args=['-DKLSK_ENABLE_TESTING=OFF', '-DKLSK_ENABLE_BENCHMARK=OFF', '-DKLSK_C_FFI=OFF', '-DKLSK_RUST_FFI=OFF', '-DKLSK_PYTHON_FFI=ON'], python_requires=">=3.9", ) diff --git a/src/core_ffi/py_ffi/packing/src/CMakeLists.txt b/src/core_ffi/py_ffi/packing/src/CMakeLists.txt new file mode 120000 index 0000000..75f9ac9 --- /dev/null +++ b/src/core_ffi/py_ffi/packing/src/CMakeLists.txt @@ -0,0 +1 @@ +../../../../CMakeLists.txt \ No newline at end of file diff --git a/src/core_ffi/py_ffi/packing/src/core b/src/core_ffi/py_ffi/packing/src/core new file mode 120000 index 0000000..58ffb12 --- /dev/null +++ b/src/core_ffi/py_ffi/packing/src/core @@ -0,0 +1 @@ +../../../../core \ No newline at end of file diff --git a/src/core_ffi/py_ffi/packing/src/core_ffi b/src/core_ffi/py_ffi/packing/src/core_ffi new file mode 120000 index 0000000..e461ac9 --- /dev/null +++ b/src/core_ffi/py_ffi/packing/src/core_ffi @@ -0,0 +1 @@ +../../../../core_ffi/ \ No newline at end of file diff --git a/src/core_ffi/py_ffi/packing/src/project b/src/core_ffi/py_ffi/packing/src/project deleted file mode 120000 index 9bc160e..0000000 --- a/src/core_ffi/py_ffi/packing/src/project +++ /dev/null @@ -1 +0,0 @@ -../../../../../../klotski/ \ No newline at end of file diff --git a/src/core_ffi/py_ffi/packing/third_party b/src/core_ffi/py_ffi/packing/third_party new file mode 120000 index 0000000..b5207a7 --- /dev/null +++ b/src/core_ffi/py_ffi/packing/third_party @@ -0,0 +1 @@ +../../../../third_party/ \ No newline at end of file diff --git a/third_party/ThirdParty.cmake b/third_party/ThirdParty.cmake index 78e3af2..6423e21 100644 --- a/third_party/ThirdParty.cmake +++ b/third_party/ThirdParty.cmake @@ -9,6 +9,8 @@ if (KLSK_ENABLE_BENCHMARK) set(BENCHMARK_ENABLE_TESTING OFF) set(BENCHMARK_ENABLE_EXCEPTIONS OFF) add_subdirectory(${KLSK_THIRD_PARTY}/benchmark EXCLUDE_FROM_ALL) + + # TODO: enable bs::thread_pool endif() if (KLSK_ENABLE_TESTING)