build(python): MSVC native _vde helper

This commit is contained in:
hm
2026-10-30 00:27:52 +08:00
parent 1b73fe4a8f
commit 6aeefff2c0
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -5,6 +5,8 @@
1. **原生 pybind11 模块 `_vde`**(`-DVDE_BUILD_PYTHON=ON`):类型化 API 子集
(core/curves/mesh/brep/sdf/cam),需要与 CPython 解释器 ABI 兼容的工具链
(Windows 上为 MSVC)编译。**当前原生子集不含 assembly**;assembly 走 ctypes。
已验证 MSVC + CPython 3.11/3.14(`_vde.cp311` / `_vde.cp314`);构建脚本见
`python/build_native_msvc.ps1`。
2. **ctypes 路径 `vde._ctypes`(默认推荐,离线可用)**:不依赖编译器/ABI,
通过 `vde_capi_shared` 目标生成的 `vde_capi.dll`(Linux/macOS 为 `.so/.dylib`)
直接调用 C API:`include/vde/capi/vde_capi.h` 当前声明 **61 个函数**,ctypes 包装
+18
View File
@@ -0,0 +1,18 @@
# Build the native _vde pybind11 subset with MSVC (no assembly binding).
# Usage:
# powershell -ExecutionPolicy Bypass -File python/build_native_msvc.ps1 -PythonRoot C:\Python314 -PybindDir build\pybind11-install\share\cmake\pybind11
param(
[string]$PythonRoot = "C:\Python314",
[string]$PybindDir = "",
[string]$BuildDir = "build/native",
[string]$SourceDir = "."
)
$ErrorActionPreference = "Stop"
$pythonExe = Join-Path $PythonRoot "python.exe"
if (-not (Test-Path $pythonExe)) { throw "python.exe not found under $PythonRoot" }
if (-not $PybindDir) { throw "-PybindDir is required (pybind11Config.cmake directory)" }
cmake -S $SourceDir -B $BuildDir -G "Visual Studio 17 2022" -A x64 -DVDE_BUILD_PYTHON=ON -DVDE_PYBIND11_DIR=$PybindDir -DPython_EXECUTABLE=$pythonExe -DPython_ROOT_DIR=$PythonRoot
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cmake --build $BuildDir --config Release --target _vde -- /m:8
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host "native _vde built; copy python/Release/_vde.*.pyd into the vde package for local import."