feat(v3.2): CI/CD config + Python bindings setup
- Add .gitea/workflows/build.yml (build, test, docs, python binding CI) - Add root pyproject.toml + setup.py (CMake-based pip install) - Add root vde/__init__.py (Python package entry point) - Update README: CI badge, version 3.2.0, Python install instructions - Bump project version to 3.2.0 across CMakeLists.txt, python/setup.py, python/vde/__init__.py - Add build_py/ to .gitignore
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
name: Build & Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y cmake g++ libeigen3-dev
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build -j$(nproc)
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: cd build && ctest --output-on-failure
|
||||||
|
|
||||||
|
- name: Generate docs
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y doxygen graphviz
|
||||||
|
doxygen Doxyfile
|
||||||
|
|
||||||
|
- name: Upload docs
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: api-docs
|
||||||
|
path: docs/api/html/
|
||||||
|
|
||||||
|
python-bindings:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
needs: build-and-test
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y cmake g++ libeigen3-dev python3 python3-pip python3-venv
|
||||||
|
|
||||||
|
- name: Build Python bindings
|
||||||
|
run: |
|
||||||
|
cmake -B build_py -DVDE_BUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build_py -j$(nproc)
|
||||||
|
|
||||||
|
- name: Install & test import
|
||||||
|
run: |
|
||||||
|
python3 -m venv .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install pybind11
|
||||||
|
PYTHONPATH=build_py/python:$PYTHONPATH python3 -c "import vde; print(f'VDE {vde.__version__} OK')"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
build/
|
build/
|
||||||
|
build_py/
|
||||||
.cache/
|
.cache/
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(ViewDesignEngine VERSION 1.0.0 LANGUAGES C CXX)
|
project(ViewDesignEngine VERSION 3.2.0 LANGUAGES C CXX)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
C++17 全栈计算几何引擎。从底层数学工具到 B-Rep 拓扑建模、SDF 隐式建模、可微分几何、工业格式互操作,一条龙覆盖。
|
C++17 全栈计算几何引擎。从底层数学工具到 B-Rep 拓扑建模、SDF 隐式建模、可微分几何、工业格式互操作,一条龙覆盖。
|
||||||
|
|
||||||
|
[](https://git.hdtime.space/ViewDesignEngine/ViewDesignEngine/actions)
|
||||||
[](tests/)
|
[](tests/)
|
||||||
[](CHANGELOG.md)
|
[](CHANGELOG.md)
|
||||||
[](CMakeLists.txt)
|
[](CMakeLists.txt)
|
||||||
|
[](pyproject.toml)
|
||||||
|
|
||||||
## 快速开始
|
## 快速开始
|
||||||
|
|
||||||
|
### C++ 构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Docker 构建环境(推荐)
|
# Docker 构建环境(推荐)
|
||||||
docker exec vde-builder bash -c "cd /ws/ViewDesignEngine && cmake -B build && cmake --build build -j\$(nproc)"
|
docker exec vde-builder bash -c "cd /ws/ViewDesignEngine && cmake -B build && cmake --build build -j\$(nproc)"
|
||||||
@@ -25,6 +29,25 @@ cd build && ctest --output-on-failure
|
|||||||
|
|
||||||
**依赖**: CMake ≥ 3.16, C++17, Eigen 3, GoogleTest(自动下载)
|
**依赖**: CMake ≥ 3.16, C++17, Eigen 3, GoogleTest(自动下载)
|
||||||
|
|
||||||
|
### Python 安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 从源码安装(推荐)
|
||||||
|
pip install .
|
||||||
|
|
||||||
|
# 开发模式(可编辑安装)
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
# 仅 CMake 构建(不安装到 site-packages)
|
||||||
|
cmake -B build_py -DVDE_BUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build_py -j$(nproc)
|
||||||
|
|
||||||
|
# 测试导入
|
||||||
|
PYTHONPATH=build_py/python python3 -c "import vde; print(vde.__version__)"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Python 依赖**: CMake ≥ 3.16, C++17, Eigen 3(自动下载), pybind11 ≥ 2.10
|
||||||
|
|
||||||
## 模块总览
|
## 模块总览
|
||||||
|
|
||||||
| 模块 | 命名空间 | 关键能力 |
|
| 模块 | 命名空间 | 关键能力 |
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=61.0", "pybind11>=2.10", "cmake>=3.16"]
|
||||||
|
build-backend = "setuptools.backends._legacy:_Backend"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "vde"
|
||||||
|
version = "3.2.0"
|
||||||
|
description = "High-performance C++ CAD geometry engine"
|
||||||
|
readme = "README.md"
|
||||||
|
license = {text = "Apache-2.0"}
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
keywords = ["cad", "geometry", "computational-geometry", "brep", "sdf", "mesh"]
|
||||||
|
classifiers = [
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"Intended Audience :: Science/Research",
|
||||||
|
"License :: OSI Approved :: Apache Software License",
|
||||||
|
"Programming Language :: C++",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Topic :: Scientific/Engineering",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://github.com/ViewDesignEngine/ViewDesignEngine"
|
||||||
|
Documentation = "https://github.com/ViewDesignEngine/ViewDesignEngine/tree/main/docs"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = ["vde"]
|
||||||
+1
-1
@@ -37,7 +37,7 @@ ext_modules = [
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="vde",
|
name="vde",
|
||||||
version="1.0.0",
|
version="3.2.0",
|
||||||
author="ViewDesignEngine Contributors",
|
author="ViewDesignEngine Contributors",
|
||||||
description="CAD computational geometry engine",
|
description="CAD computational geometry engine",
|
||||||
long_description=Path(__file__).parent.joinpath("..", "README.md").read_text(
|
long_description=Path(__file__).parent.joinpath("..", "README.md").read_text(
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ Submodules:
|
|||||||
"""
|
"""
|
||||||
from ._vde import core, curves, mesh, sdf
|
from ._vde import core, curves, mesh, sdf
|
||||||
|
|
||||||
__version__ = "1.0.0"
|
__version__ = "3.2.0"
|
||||||
__all__ = ["core", "curves", "mesh", "sdf"]
|
__all__ = ["core", "curves", "mesh", "sdf"]
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
"""
|
||||||
|
ViewDesignEngine — CMake-based Python bindings.
|
||||||
|
|
||||||
|
Build & install:
|
||||||
|
pip install -e . # editable install
|
||||||
|
pip install . # regular install
|
||||||
|
|
||||||
|
Requires: CMake ≥ 3.16, C++17, Eigen3 (auto-fetched), pybind11.
|
||||||
|
"""
|
||||||
|
from setuptools import setup
|
||||||
|
from setuptools.command.build_ext import build_ext
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).parent.resolve()
|
||||||
|
PKG_DIR = ROOT / "vde"
|
||||||
|
|
||||||
|
|
||||||
|
class CMakeBuildExt(build_ext):
|
||||||
|
"""Build the native _vde module via CMake."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
build_dir = ROOT / "build_py"
|
||||||
|
build_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
|
# ── Configure ──
|
||||||
|
subprocess.check_call(
|
||||||
|
[
|
||||||
|
"cmake",
|
||||||
|
"-B", str(build_dir),
|
||||||
|
"-DVDE_BUILD_PYTHON=ON",
|
||||||
|
"-DCMAKE_BUILD_TYPE=Release",
|
||||||
|
"-DBUILD_TESTS=OFF",
|
||||||
|
"-DBUILD_BENCHMARKS=OFF",
|
||||||
|
"-DBUILD_EXAMPLES=OFF",
|
||||||
|
],
|
||||||
|
cwd=str(ROOT),
|
||||||
|
)
|
||||||
|
|
||||||
|
# ── Build ──
|
||||||
|
parallel = str(os.cpu_count() or 4)
|
||||||
|
subprocess.check_call(
|
||||||
|
["cmake", "--build", str(build_dir), "-j", parallel],
|
||||||
|
cwd=str(ROOT),
|
||||||
|
)
|
||||||
|
|
||||||
|
# ── Copy .so / .pyd to package dir ──
|
||||||
|
so_suffix = ".cpython-*-linux-gnu.so" if sys.platform == "linux" else "*.so"
|
||||||
|
so_glob = "*.pyd" if sys.platform == "win32" else so_suffix
|
||||||
|
|
||||||
|
so_files = list(build_dir.glob(f"python/{so_glob}"))
|
||||||
|
so_files += list(build_dir.glob(f"python/**/{so_glob}"))
|
||||||
|
|
||||||
|
if not so_files:
|
||||||
|
# fallback: search whole build tree
|
||||||
|
so_files = list(build_dir.rglob(f"_vde{so_glob}"))
|
||||||
|
so_files += list(build_dir.rglob(f"_vde*.so"))
|
||||||
|
|
||||||
|
for so in so_files:
|
||||||
|
dest = PKG_DIR / so.name
|
||||||
|
print(f"Installing {so.name} → {dest}")
|
||||||
|
shutil.copy2(str(so), str(dest))
|
||||||
|
break # copy first match
|
||||||
|
|
||||||
|
|
||||||
|
class CMakeBuildPy(build_py):
|
||||||
|
"""Ensure native build runs before packaging."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.run_command("build_ext")
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="vde",
|
||||||
|
version="3.2.0",
|
||||||
|
description="High-performance C++ CAD geometry engine",
|
||||||
|
long_description=(ROOT / "README.md").read_text(encoding="utf-8")
|
||||||
|
if (ROOT / "README.md").exists()
|
||||||
|
else "",
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
url="https://github.com/ViewDesignEngine/ViewDesignEngine",
|
||||||
|
packages=["vde"],
|
||||||
|
package_dir={"vde": "vde"},
|
||||||
|
cmdclass={
|
||||||
|
"build_ext": CMakeBuildExt,
|
||||||
|
"build_py": CMakeBuildPy,
|
||||||
|
},
|
||||||
|
python_requires=">=3.8",
|
||||||
|
zip_safe=False,
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""
|
||||||
|
ViewDesignEngine — High-performance C++ CAD geometry engine for Python.
|
||||||
|
|
||||||
|
Submodules:
|
||||||
|
vde.core — Point3D, Vector3D, AABB3D, Polygon2D, convex hull, distance, transforms
|
||||||
|
vde.curves — BezierCurve, BSplineCurve, NurbsCurve
|
||||||
|
vde.mesh — delaunay_2d, delaunay_3d, HalfedgeMesh
|
||||||
|
vde.sdf — SdfNode, CSG tree, marching cubes mesh conversion
|
||||||
|
vde.sketch — 2D sketch constraint solver
|
||||||
|
vde.boolean — 2D/3D boolean operations
|
||||||
|
vde.collision — GJK/EPA collision detection
|
||||||
|
vde.brep — B-Rep topology modeling
|
||||||
|
"""
|
||||||
|
|
||||||
|
__version__ = "3.2.0"
|
||||||
|
|
||||||
|
# Native module (_vde) is built via CMake and copied here at install time.
|
||||||
|
# Fallback: try importing so IDEs/tools can inspect.
|
||||||
|
try:
|
||||||
|
from ._vde import core, curves, mesh, sdf
|
||||||
|
except ImportError:
|
||||||
|
pass # native module not yet built; pip install will build it
|
||||||
|
|
||||||
|
__all__ = ["core", "curves", "mesh", "sdf"]
|
||||||
Reference in New Issue
Block a user