Skip to content

Commit db93f2f

Browse files
committed
```
build(workflow): 添加依赖下载后的调试信息并引入 CMakeLists.txt 在 GitHub 工作流中添加了列出下载依赖内容的命令,便于调试依赖项是否正确下载。 新增 CMakeLists.txt 文件以支持通过 pybind11 构建 Python 扩展模块, 包括自动查找 pybind11 路径、配置项目结构及设置输出目录。 ```
1 parent a02feff commit db93f2f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/template-python-build-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ jobs:
8585
with:
8686
name: deps-artifact
8787
path: ${{ inputs.download-dependencies-path }}
88+
run: |
89+
echo "Downloaded dependencies artifact "
90+
ls -R ${{ inputs.download-dependencies-path }}
8891
8992
- name: Set up Python
9093
uses: actions/setup-python@v5

CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
project(geodesy LANGUAGES CXX)
3+
4+
# 查找 pybind11
5+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
6+
7+
# 自动获取 pybind11 的 cmake 路径
8+
execute_process(
9+
COMMAND "${Python3_EXECUTABLE}" -m pybind11 --cmakedir
10+
OUTPUT_VARIABLE pybind11_DIR
11+
OUTPUT_STRIP_TRAILING_WHITESPACE
12+
)
13+
find_package(pybind11 CONFIG REQUIRED HINTS ${pybind11_DIR})
14+
message(STATUS "Found pybind11 in: ${pybind11_DIR}")
15+
16+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pybindStudy/Cplus/include)
17+
18+
file(GLOB SOURCES "./pybindStudy/Cplus/source/*.cpp")
19+
pybind11_add_module(
20+
function MODULE ${SOURCES}
21+
)
22+
23+
set(PYBIND_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python) # 路径可自行选择
24+
set_target_properties(function PROPERTIES
25+
LIBRARY_OUTPUT_DIRECTORY ${PYBIND_OUTPUT_DIR} # 输出路径
26+
)

0 commit comments

Comments
 (0)