Skip to content

Commit ad1a2f3

Browse files
w1th0utnam3Fek04
andauthored
Python bindings (#223)
* Add placeholder for Python bindings * transferred current state * reconstruct_surface aabb parameters * reconstruct_surface SpatialDecomposition parameters * single and double precision reconstruct_surface by exposing two methods * conda environment file * Working on post processing pipeline * Post processing in working but unpolished state * Exposed reconstruct surface method now infers float precision based on input * Code cleanup * Split pyfunctions into their own files * Binding of TriMesh and UniformGrid * SurfaceReconstruction binding * Dynamic marching cubes cleanup method * Dynamic post processing method * Updated docstrings * More parameters for post processing * Removed some copies * Reconstruct surface now as other methods exposed * Decimation * Laplacian smoothing inplace * MeshWithData struct * Smoothed normals computation * Smoothed normals f64 * PyMeshWithData struct improvements * MeshWithData dynamic python function to push attributes * PySphInterpolator classes * Normal laplacian smoothing * Reconstruction pipeline mostly ported to python * TriMesh to MixedTriQuadMesh conversion possible * Code restructure * Rudimentary Sphinx integration * Slight documentation improvements * Workflow to create wheels * Started to compare pipeline with binary * Implemented take methods where possible * Updated python environment file * Pipeline tests working * Wrote reconstruction pipeline in rust * MeshWithData improvements * Constructor methods * Attributes are now written to the ouput file + Better mesh distance test using trimesh * Made relevant methods callable with both Mesh and MeshWithData objects * All Aabb Methods exposed * SphInterpolator methods * Removed Py tag from exposed classes * bgeo file format meshio extension * Stub file generation using the crate `pyo3-stub-gen` * Pipeline can now read and interpolate existing attributes * Pipeline now additionally returns surfacereconstruction object * Documentation update * Documentation workflow * Readme update * Readme embedded in sphinx documentation * Relative splashsurf lib import * Github workflow for calling tests * MeshWithData attributes to pydict methods * Write to file method * Convert Tris to Quads Method now compatible with MeshWithData objects * Readme update * Combine actions in CI * Made meshio support optional * Slight Documentation update * Rebased on main * Docs + Metadata improvements * Meshio optional dependency explained in Readme * Update readme * Update default parameters * Update some comments * Update pyproject.toml * Update CI workflow for bindings * Add push trigger to Python workflow * Add license * Update dependencies * Fix * Fix typo * Run cargo fmt * Some code cleanup * Run check fmt in python project --------- Co-authored-by: Felix Kern <[email protected]>
1 parent 0ae5ef6 commit ad1a2f3

36 files changed

+5857
-0
lines changed
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# This file is autogenerated by maturin v1.8.2
2+
# To update, run
3+
#
4+
# maturin generate-ci github
5+
#
6+
name: PySplashsurf CI
7+
8+
on:
9+
push:
10+
workflow_dispatch:
11+
release:
12+
types: [published]
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
check_format:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Check formatting of PySplashsurf
23+
run: cargo fmt -- --check
24+
working-directory: pysplashsurf
25+
26+
generate-stub:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- uses: moonrepo/setup-rust@v1
31+
- run: |
32+
cargo run --bin stub_gen
33+
working-directory: pysplashsurf
34+
- name: Upload stub as artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: pysplashsurf.pyi
38+
path: pysplashsurf/pysplashsurf/
39+
40+
linux:
41+
needs: generate-stub
42+
runs-on: ${{ matrix.platform.runner }}
43+
strategy:
44+
matrix:
45+
platform:
46+
- runner: ubuntu-24.04
47+
target: x86_64
48+
- runner: ubuntu-24.04
49+
target: x86
50+
- runner: ubuntu-24.04
51+
target: aarch64
52+
- runner: ubuntu-24.04
53+
target: armv7
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Download stub artifact
57+
uses: actions/download-artifact@v4
58+
with:
59+
name: pysplashsurf.pyi
60+
path: pysplashsurf/pysplashsurf/
61+
- uses: actions/setup-python@v5
62+
with:
63+
python-version: 3.x
64+
- name: Build wheels
65+
uses: PyO3/maturin-action@v1
66+
with:
67+
target: ${{ matrix.platform.target }}
68+
args: --release --out dist -m pysplashsurf/Cargo.toml
69+
# sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
70+
manylinux: auto
71+
- name: Upload wheels
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: wheels-linux-${{ matrix.platform.target }}
75+
path: dist
76+
77+
windows:
78+
needs: generate-stub
79+
runs-on: ${{ matrix.platform.runner }}
80+
strategy:
81+
matrix:
82+
platform:
83+
- runner: windows-latest
84+
target: x64
85+
- runner: windows-latest
86+
target: x86
87+
steps:
88+
- uses: actions/checkout@v4
89+
- name: Download stub artifact
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: pysplashsurf.pyi
93+
path: pysplashsurf/pysplashsurf/
94+
- uses: actions/setup-python@v5
95+
with:
96+
python-version: 3.x
97+
architecture: ${{ matrix.platform.target }}
98+
- name: Build wheels
99+
uses: PyO3/maturin-action@v1
100+
with:
101+
target: ${{ matrix.platform.target }}
102+
args: --release --out dist -m pysplashsurf\Cargo.toml
103+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
104+
- name: Upload wheels
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: wheels-windows-${{ matrix.platform.target }}
108+
path: dist
109+
110+
macos:
111+
needs: generate-stub
112+
runs-on: ${{ matrix.platform.runner }}
113+
strategy:
114+
matrix:
115+
platform:
116+
- runner: macos-13
117+
target: x86_64
118+
- runner: macos-14
119+
target: aarch64
120+
steps:
121+
- uses: actions/checkout@v4
122+
- name: Download stub artifact
123+
uses: actions/download-artifact@v4
124+
with:
125+
name: pysplashsurf.pyi
126+
path: pysplashsurf/pysplashsurf/
127+
- uses: actions/setup-python@v5
128+
with:
129+
python-version: 3.x
130+
- name: Build wheels
131+
uses: PyO3/maturin-action@v1
132+
with:
133+
target: ${{ matrix.platform.target }}
134+
args: --release --out dist -m pysplashsurf/Cargo.toml
135+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
136+
- name: Upload wheels
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: wheels-macos-${{ matrix.platform.target }}
140+
path: dist
141+
142+
sdist:
143+
needs: generate-stub
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v4
147+
- name: Download stub artifact
148+
uses: actions/download-artifact@v4
149+
with:
150+
name: pysplashsurf.pyi
151+
path: pysplashsurf/pysplashsurf/
152+
- name: Build sdist
153+
uses: PyO3/maturin-action@v1
154+
with:
155+
command: sdist
156+
args: --out dist -m pysplashsurf/Cargo.toml
157+
- name: Upload sdist
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: wheels-sdist
161+
path: dist
162+
163+
release:
164+
name: Release
165+
runs-on: ubuntu-latest
166+
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
167+
needs: [linux, windows, macos, sdist]
168+
permissions:
169+
# Use to sign the release artifacts
170+
id-token: write
171+
# Used to upload release artifacts
172+
contents: write
173+
# Used to generate artifact attestation
174+
attestations: write
175+
steps:
176+
- uses: actions/download-artifact@v4
177+
#- name: Generate artifact attestation
178+
# uses: actions/attest-build-provenance@v1
179+
# with:
180+
# subject-path: 'wheels-*/*'
181+
- name: Publish to PyPI
182+
#if: ${{ startsWith(github.ref, 'refs/tags/') }}
183+
uses: PyO3/maturin-action@v1
184+
env:
185+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
186+
with:
187+
command: upload
188+
args: --non-interactive --skip-existing wheels-*/*
189+
190+
build_wheel:
191+
runs-on: ubuntu-latest
192+
outputs:
193+
filename: ${{ steps.get_filename.outputs.file_name }}
194+
steps:
195+
- uses: actions/checkout@v4
196+
- uses: actions/setup-python@v5
197+
with:
198+
python-version: 3.x
199+
- name: Build wheels
200+
uses: PyO3/maturin-action@v1
201+
with:
202+
target: x86_64
203+
args: --release --out dist -m pysplashsurf/Cargo.toml
204+
manylinux: auto
205+
- name: Get wheel name
206+
id: get_filename
207+
run: |
208+
FILE_NAME=$(ls dist)
209+
echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
210+
- name: Upload wheel
211+
uses: actions/upload-artifact@v4
212+
with:
213+
name: doc_tests_wheel
214+
path: dist
215+
216+
docs:
217+
needs: build_wheel
218+
runs-on: ubuntu-latest
219+
steps:
220+
- uses: actions/checkout@v4
221+
- uses: actions/setup-python@v5
222+
with:
223+
python-version: 3.x
224+
- name: Download wheel
225+
uses: actions/download-artifact@v4
226+
with:
227+
name: doc_tests_wheel
228+
path: dist/
229+
- name: Append output to file
230+
run: |
231+
echo "./dist/${{ needs.build_wheel.outputs.filename }}" >> pysplashsurf/pysplashsurf/docs/requirements.txt
232+
- uses: ammaraskar/[email protected]
233+
with:
234+
docs-folder: "pysplashsurf/pysplashsurf/docs/"
235+
- uses: actions/upload-artifact@v4
236+
with:
237+
name: DocumentationHTML
238+
path: pysplashsurf/pysplashsurf/docs/build/html/
239+
240+
tests:
241+
needs: build_wheel
242+
defaults:
243+
run:
244+
shell: bash -l {0}
245+
runs-on: ubuntu-latest
246+
steps:
247+
- uses: actions/checkout@v4
248+
- uses: actions/setup-python@v5
249+
with:
250+
python-version: 3.x
251+
- uses: mamba-org/setup-micromamba@v2
252+
with:
253+
environment-file: pysplashsurf/python_environment.yaml
254+
init-shell: >-
255+
bash
256+
- run: |
257+
conda info
258+
conda list
259+
- name: Download wheel
260+
uses: actions/download-artifact@v4
261+
with:
262+
name: doc_tests_wheel
263+
path: dist/
264+
- run: pip install dist/${{ needs.build_wheel.outputs.filename }}
265+
- name: Install splashsurf CLI
266+
run: cargo install splashsurf
267+
- name: Run pytest
268+
uses: pavelzw/pytest-action@v2
269+
with:
270+
verbose: true
271+
emoji: false
272+
job-summary: true
273+
click-to-expand: true
274+
report-title: 'Pytest Report'

pysplashsurf/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dist/
2+
*.egg-info/
3+
target/
4+
**/__pycache__/
5+
*.so
6+
test.vtk
7+
test_bin.vtk
8+
env/
9+
envs/
10+
11+
# Sphinx
12+
pysplashsurf/docs/build/

0 commit comments

Comments
 (0)