Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wrapper #2

Merged
merged 70 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7944276
Update FTetWildWrapper.cpp
akaszynski Feb 28, 2024
734c002
Add workflow
akaszynski Feb 28, 2024
5b7a457
Update setup.py
akaszynski Feb 28, 2024
cc0c5fa
Update setup.py
akaszynski Feb 28, 2024
b5722b2
Create _version.py
akaszynski Feb 28, 2024
28b5c16
Create _version.py
akaszynski Feb 28, 2024
3ab06b5
Update README.rst
akaszynski Feb 28, 2024
b4d14a3
Update build-and-deploy.yml
akaszynski Feb 28, 2024
053b78a
Create build-and-deploy.yml
akaszynski Feb 28, 2024
e11c5b6
Delete .github/workflows/.github/workflows/build-and-deploy.yml
akaszynski Feb 28, 2024
48d4fee
Delete _version.py
akaszynski Feb 28, 2024
b1a559a
use cmake; fix wrapper
akaszynski Feb 29, 2024
9497cca
Update setup.py
akaszynski Feb 29, 2024
37679f7
Create pyproject.toml
akaszynski Feb 29, 2024
3d571df
Update setup.py
akaszynski Feb 29, 2024
76072e5
fix setup.py
akaszynski Feb 29, 2024
ec249b5
fix skbuild
akaszynski Feb 29, 2024
ceb2fc5
Update build-and-deploy.yml
akaszynski Feb 29, 2024
f3741e6
Update setup.py
akaszynski Feb 29, 2024
0d9592b
Update CMakeLists.txt
akaszynski Feb 29, 2024
848edb6
Update build-and-deploy.yml
akaszynski Feb 29, 2024
d0f2519
Update CMakeLists.txt
akaszynski Feb 29, 2024
00aaa83
Update CMakeLists.txt
akaszynski Feb 29, 2024
3162c96
Update build-and-deploy.yml
akaszynski Feb 29, 2024
a518948
Update CMakeLists.txt
akaszynski Feb 29, 2024
09fd105
Update FTetWildWrapper.cpp
akaszynski Feb 29, 2024
d3d4313
add pybind
akaszynski Feb 29, 2024
de03224
Update CMakeLists.txt
akaszynski Feb 29, 2024
5fdeed0
update wrapper
akaszynski Mar 1, 2024
75a591f
Create pytetwild.py
akaszynski Mar 1, 2024
42ad1eb
Update __init__.py
akaszynski Mar 1, 2024
cf749ff
Create test_pytetwild.py
akaszynski Mar 1, 2024
9ef4530
Update test_pytetwild.py
akaszynski Mar 1, 2024
1ce1997
Create .pre-commit-config.yaml
akaszynski Mar 1, 2024
b7b8370
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
81be177
Delete src/FTetWildWrapper.h
akaszynski Mar 1, 2024
2e04e21
pre-commit fixes
akaszynski Mar 1, 2024
8492867
use scikit-build-core
akaszynski Mar 2, 2024
d2cb1d5
fix inplace build
akaszynski Mar 2, 2024
67043af
update .gitignore
akaszynski Mar 2, 2024
adb80e2
add in pyvista to dev dependencies
akaszynski Mar 2, 2024
dc1f98c
get version from metadata
akaszynski Mar 2, 2024
ab40848
update contributing, test sdist
akaszynski Mar 2, 2024
3c44ad4
add cibuildwheel
akaszynski Mar 2, 2024
547e8f8
add conditional linux apt packages
akaszynski Mar 2, 2024
a1ffc71
submodules
akaszynski Mar 2, 2024
05b13c7
fix linux wheel build
akaszynski Mar 2, 2024
bc7b9a0
attempt windows build
akaszynski Mar 2, 2024
bc4d348
fix windows build
akaszynski Mar 2, 2024
c321c9e
fix library path
akaszynski Mar 2, 2024
b03e87c
fix contributing; fix env var windows ci
akaszynski Mar 2, 2024
d93eed6
clean before build on windows
akaszynski Mar 2, 2024
e713d52
fix mac build
akaszynski Mar 2, 2024
77d53a5
fix before-build command for windows
akaszynski Mar 2, 2024
9b8c861
attempt source dist fix
akaszynski Mar 2, 2024
1860e91
drop macOS build
akaszynski Mar 2, 2024
a57cbcf
move env settings to gh actions
akaszynski Mar 2, 2024
0c45833
pass var on linux
akaszynski Mar 2, 2024
1ef5186
try gcc < 11
akaszynski Mar 2, 2024
486009f
output reproduces default settings in fTetWild - preparing for switches
danpak94 Mar 3, 2024
7a0ed1b
fix compiler settings
akaszynski Mar 3, 2024
38260c6
Merge branch 'feat/wrapper' into switches
danpak94 Mar 3, 2024
e7a2f2a
adding unit tests for output mesh accuracy
danpak94 Mar 3, 2024
21527f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2024
9685662
Merge pull request #3 from pyvista/switches
akaszynski Mar 4, 2024
e456dc9
fix windows build
akaszynski Mar 4, 2024
fa94e28
add release
akaszynski Mar 4, 2024
118c240
fix dynamic tag; fix readme; build all
akaszynski Mar 4, 2024
300d3e8
remove dynamic license in pyproject
akaszynski Mar 4, 2024
6666eea
Make release conditional
akaszynski Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Build and upload

on:
pull_request:
push:
tags:
- "*"
branches:
- "main"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Miniconda (Windows)
if: runner.os == 'Windows'
uses: conda-incubator/[email protected]

- name: Install Dependencies (Windows)
if: runner.os == 'Windows'
shell: powershell
run: conda install -c conda-forge mpir -y

- name: Set env (Windows)
if: runner.os == 'Windows'
run: |
echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
echo "GMP_INC=C:\Miniconda\envs\test\Library\include" >> ${env:GITHUB_ENV}
echo "GMP_LIB=C:\Miniconda\envs\test\Library\lib" >> ${env:GITHUB_ENV}

- name: Build wheels
uses: pypa/[email protected]

- name: List generated wheels
run: ls ./wheelhouse/*

- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: pytetwild-wheel-${{ matrix.os }}

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install \
libblas-dev \
libboost-filesystem-dev \
libboost-system-dev \
libboost-thread-dev \
libglu1-mesa-dev \
libsuitesparse-dev \
xorg-dev \
ccache

- name: Build source distribution
run: |
pipx run build --sdist

- name: Validate
run: |
pip install twine
twine check dist/*

- name: Install from dist/
run: pip install --find-links=dist/ pytetwild[dev]

- name: Test
run: pytest -vv

- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: pytetwild-sdist

release:
name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pytetwild
permissions:
id-token: write # this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
- name: Flatten directory structure
run: |
mkdir -p dist/
find . -name '*.whl' -exec mv {} dist/ \;
find . -name '*.tar.gz' -exec mv {} dist/ \;
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
./**/*.whl
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dist/

# MISC
.mypy_cache
__tracked_surface.stl

# Mac
.DS_Store
Expand All @@ -41,3 +42,36 @@ venv/

# VSCode
.vscode/

# skbuild
_skbuild/

# cmake
.ninja_deps
.ninja_log
CMakeCache.txt
CMakeFiles/
CMakeInit.txt
CPackConfig.cmake
CPackSourceConfig.cmake
build.ninja
cmake_install.cmake
lib/
ALL_BUILD.vcxproj
ALL_BUILD.vcxproj.filters
INSTALL.vcxproj
INSTALL.vcxproj.filters
PACKAGE.vcxproj
PACKAGE.vcxproj.filters
PyfTetWildWrapper.dir/
PyfTetWildWrapper.vcxproj
PyfTetWildWrapper.vcxproj.filters
ZERO_CHECK.vcxproj
ZERO_CHECK.vcxproj.filters
fTetWildWrapper.sln
x64/
Release/
mpir.dll

# cibuildwheel
wheelhouse
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/fTetWild"]
path = src/fTetWild
url = https://github.com/wildmeshing/fTetWild
[submodule "src/pybind11"]
path = src/pybind11
url = https://github.com/pybind/pybind11.git
66 changes: 66 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: ^(docs|tests)
- id: ruff-format

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
exclude: README.rst

- repo: https://github.com/numpy/numpydoc
rev: v1.6.0
hooks:
- id: numpydoc-validation
files: ^src/pytetwild

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: ["--skip=*.vt*"]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [tomli==2.0.1]
files: ^src/pytetwild/.*\.py

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
files: |
(?x)^(
src/FTetWildWrapper.cpp
)$

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.7.0
# hooks:
# - id: mypy
# exclude: ^(docs/|tests)
# additional_dependencies: [
# "mypy-extensions==1.0.0",
# "toml==0.10.2",
# "types-PyYAML",
# "numpy",
# ]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.15...3.26)
project(fTetWildWrapper)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ./src/pytetwild)

if($ENV{USE_MAVX})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
endif()

# Set the path to the fTetWild project
set(fTetWild_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/fTetWild")

# Add the pybind11 submodule
set(PYBIND11_NEWPYTHON ON)
set(pybind11_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/pybind11")
add_subdirectory(${pybind11_DIR})

# Include the fTetWild project as a subdirectory
add_subdirectory(${fTetWild_DIR} EXCLUDE_FROM_ALL)

pybind11_add_module(PyfTetWildWrapper MODULE "${CMAKE_CURRENT_SOURCE_DIR}/src/FTetWildWrapper.cpp")

# Include directories from fTetWild required for the wrapper
target_include_directories(PyfTetWildWrapper PUBLIC ${fTetWild_DIR}/src)

# Link the FloatTetwild library (from fTetWild)
target_link_libraries(PyfTetWildWrapper PRIVATE FloatTetwild)
target_compile_features(PyfTetWildWrapper PUBLIC cxx_std_11)

if(WIN32)
set_target_properties(PyfTetWildWrapper PROPERTIES SUFFIX ".pyd")
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG_UPPER)
set_target_properties(PyfTetWildWrapper PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} "${CMAKE_CURRENT_SOURCE_DIR}/src/pytetwild"
LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} "${CMAKE_CURRENT_SOURCE_DIR}/src/pytetwild"
)
endforeach()
endif()

install(TARGETS PyfTetWildWrapper LIBRARY DESTINATION ./pytetwild)
84 changes: 84 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributing to Our Project

Thank you for considering contributions to our project! Here's how you can help:

## Setting Up for Development

We're using [scikit-build-core](https://github.com/scikit-build/scikit-build-core) for our build system and building using ``cmake``. You'll need a handful of system dependencies to build locally.


### Linux
On Linux, install the following OS dependencies with:

```
sudo apt-get update
sudo apt-get install libblas-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libglu1-mesa-dev libsuitesparse-dev xorg-dev ccache -y
```

### Windows

For contributors using Windows, we also have a setup process to ensure you can compile and test changes locally. Here's how to set up your development environment on Windows:

1. **Install Miniconda**: We use Miniconda to manage dependencies. Install it from [here](https://docs.anaconda.com/free/miniconda/index.html).

2. **Setup Miniconda and Install Dependencies**:
```
conda install -c conda-forge mpir -y
```

3. **Configure Environment Variables**:
Set the required environment variables for the build. This assumes PowerShell.

```
$Env:GMP_INC = "C:\Miniconda\Library\include"
$Env:GMP_LIB = "C:\Miniconda\Library\lib"
```

Note: You may need to adjust these paths depending on if you use a non-global conda environment.

### Installation
To install the library in editable mode:

1. Clone the repository:
```
git clone https://github.com/pyvista/pytetwild
```
2. Initialize submodules:
```
git submodule update --init --recursive
```
3. Install the project in editable mode and include development dependencies:
```
pip install -e .[dev]
```

**Note:** On windows, you'll need to copy the `mpir.dll` to your source directory with:
```
python -c "import shutil, os; shutil.copy(os.path.join(os.getenv('GMP_LIB'), '..', 'bin', 'mpir.dll'), './src/pytetwild')"
```

## Code Style and Quality

- **Documentation**: Follow the `numpydoc` style for docstrings.
- **Linting**: We use `ruff` for code styling to ensure consistency.
- **Pre-commit**: Utilize `pre-commit` hooks to automate checks before commits. Set up your local environment with:
```
pip install pre-commit
pre-commit install
```
- **Testing**: Write tests for new features or bug fixes and run them using `pytest`. Tests are located in the `tests` directory.

## How to Contribute

- **Bugs and Feature Requests**: Submit them through our [issues page](https://github.com/pyvista/pytetwild/issues).
- **Code Contributions**: Make changes in a fork of this repository and submit a pull request (PR) through our [PR page](https://github.com/pyvista/pytetwild/pulls). Follow the standard fork-and-PR workflow for contributions.

## Community and Conduct

- We expect all contributors to follow our [Code of Conduct](https://github.com/pyvista/pyvista/blob/main/CODE_OF_CONDUCT.md) to maintain a welcoming and inclusive community.

## License

- Contributions are subject to the project's license as found in the [LICENSE.md](./LICENSE.md) file.

We welcome your contributions and look forward to collaborating with you!
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Mozilla Public License Version 2.0
means any form of the work other than Source Code Form.

1.7. "Larger Work"
means a work that combines Covered Software with other material, in
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.

1.8. "License"
Expand Down
Loading