diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 1e58ffa..95c38a5 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -17,30 +17,42 @@ jobs: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build wheels - uses: pypa/cibuildwheel@v2.12.3 + uses: pypa/cibuildwheel@v2.16.5 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: pymeshfix-wheels-${{ matrix.os }} path: ./wheelhouse/*.whl build_sdist: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build sdist run: pipx run build --sdist - - uses: actions/upload-artifact@v3 + - name: Install package from sdist + run: pip install dist/*.tar.gz + + - name: Install test requirements + run: pip install -r requirements_test.txt + + - name: Run tests + run: pytest + + - uses: actions/upload-artifact@v4 with: + name: pymeshfix-sdist path: dist/*.tar.gz upload_pypi: @@ -51,12 +63,12 @@ jobs: # alternatively, to publish when a GitHub Release is created, use the following rule: # if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: artifact path: dist - - uses: pypa/gh-action-pypi-publish@v1.8.6 + - uses: pypa/gh-action-pypi-publish@v1.8.11 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f50d295..5a51991 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,32 +5,27 @@ ci: autoupdate_schedule: quarterly repos: - -- repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - -- repo: https://github.com/psf/black - rev: 23.7.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.11 hooks: - - id: black - args: - - --line-length=100 + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + exclude: ^(docs/|tests) + - id: ruff-format - repo: https://github.com/keewis/blackdoc - rev: v0.3.8 + rev: v0.3.9 hooks: - id: blackdoc files: '\.py$' - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: ["--toml", "pyproject.toml"] @@ -44,13 +39,13 @@ repos: exclude: "examples/" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: debug-statements # this validates our github workflow files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.23.3 + rev: 0.28.0 hooks: - id: check-github-workflows diff --git a/MANIFEST.in b/MANIFEST.in index 0f5530e..e97e639 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ +include pymeshfix/cython/*.pyx include pymeshfix/cython/*.h include tests/* \ No newline at end of file diff --git a/doc/conf.py b/doc/conf.py index b2dfd99..e253edd 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,12 +1,12 @@ """Configuration for the documentation generation of pymeshfix.""" + import datetime import os -import numpy as np -import pymeshfix - -# -- pyvista configuration --------------------------------------------------- import pyvista +from sphinx_gallery.sorting import FileNameSortKey + +import pymeshfix # Manage errors pyvista.set_error_output_file("errors.txt") @@ -14,7 +14,7 @@ pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy # Preferred plotting style for documentation pyvista.set_plot_theme("document") -pyvista.rcParams["window_size"] = np.array([1024, 768]) * 2 +pyvista.global_theme.window_size = [1024, 768] # Save figures in specified directory pyvista.FIGURE_PATH = os.path.abspath("./images/") if not os.path.exists(pyvista.FIGURE_PATH): @@ -99,7 +99,9 @@ # Enable the "Edit in GitHub link within the header of each page. "display_github": True, # Set the following variables to generate the resulting github URL for each page. - # Format Template: https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }} + # Format Template: https://{{ github_host|default("github.com") }}/{{ + # github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path + # }}{{ pagename }}{{ suffix }} "github_user": "pyvista", "github_repo": "pymeshfix", "github_version": "master/doc/", @@ -184,8 +186,6 @@ # -- Sphinx Gallery Options -from sphinx_gallery.sorting import FileNameSortKey - sphinx_gallery_conf = { # path to your examples scripts "examples_dirs": [ diff --git a/examples/bunny.py b/examples/bunny.py index b1c0fb2..d339870 100644 --- a/examples/bunny.py +++ b/examples/bunny.py @@ -5,12 +5,12 @@ Repair the holes in the bunny mesh. """ -import pymeshfix as mf - # sphinx_gallery_thumbnail_number = 2 import pyvista as pv from pyvista import examples +import pymeshfix as mf + ################################################################################ bunny = examples.download_bunny() diff --git a/examples/cow.py b/examples/cow.py index bbd320b..985c223 100644 --- a/examples/cow.py +++ b/examples/cow.py @@ -6,12 +6,13 @@ """ import numpy as np -import pymeshfix as mf # sphinx_gallery_thumbnail_number = 1 import pyvista as pv from pyvista import examples +import pymeshfix as mf + ################################################################################ cow = examples.download_cow() diff --git a/examples/repair_planar.py b/examples/repair_planar.py index 8346977..69e8ff0 100644 --- a/examples/repair_planar.py +++ b/examples/repair_planar.py @@ -7,10 +7,11 @@ # sphinx_gallery_thumbnail_number = 1 import numpy as np +import pyvista as pv + from pymeshfix import MeshFix from pymeshfix._meshfix import PyTMesh from pymeshfix.examples import planar_mesh -import pyvista as pv ############################################################################### # plot the holes on the original mesh diff --git a/examples/torso.py b/examples/torso.py index c45f344..b6564b2 100644 --- a/examples/torso.py +++ b/examples/torso.py @@ -6,12 +6,12 @@ parts of the mesh """ -import pymeshfix as mf - # sphinx_gallery_thumbnail_number = 2 import pyvista as pv from pyvista import examples +import pymeshfix as mf + mesh = examples.download_torso() print(mesh) diff --git a/pymeshfix/__init__.py b/pymeshfix/__init__.py index 8fff7a5..684611f 100644 --- a/pymeshfix/__init__.py +++ b/pymeshfix/__init__.py @@ -1,5 +1,5 @@ """PyMeshFix module.""" -from pymeshfix import _meshfix -from pymeshfix._meshfix import PyTMesh, clean_from_arrays, clean_from_file -from pymeshfix._version import __version__ -from pymeshfix.meshfix import * +from pymeshfix import _meshfix # noqa: F401 +from pymeshfix._meshfix import PyTMesh, clean_from_arrays, clean_from_file # noqa: F401 +from pymeshfix._version import __version__ # noqa: F401 +from pymeshfix.meshfix import MeshFix # noqa: F401 diff --git a/pymeshfix/_version.py b/pymeshfix/_version.py index 190a433..64b406b 100644 --- a/pymeshfix/_version.py +++ b/pymeshfix/_version.py @@ -6,5 +6,6 @@ version_info = 0, 27, 'dev0' """ + version_info = 0, 17, "dev0" __version__ = ".".join(map(str, version_info)) diff --git a/pymeshfix/examples/__init__.py b/pymeshfix/examples/__init__.py index 1d0ed13..7a9e882 100644 --- a/pymeshfix/examples/__init__.py +++ b/pymeshfix/examples/__init__.py @@ -1,4 +1,5 @@ """Built-in examples.""" + # get location of the example meshes from os.path import dirname, join, realpath @@ -6,4 +7,4 @@ bunny_scan = join(pth, "StanfordBunny.ply") planar_mesh = join(pth, "planar_mesh.ply") -from pymeshfix.examples.fix import * +from pymeshfix.examples.fix import native, with_vtk # noqa: F401, E402 diff --git a/pymeshfix/examples/fix.py b/pymeshfix/examples/fix.py index 7b0b4d2..3272454 100644 --- a/pymeshfix/examples/fix.py +++ b/pymeshfix/examples/fix.py @@ -1,11 +1,13 @@ """Demonstrate mesh repair on the standford bunny mesh.""" + import os import time import numpy as np +import pyvista as pv + import pymeshfix from pymeshfix.examples import bunny_scan -import pyvista as pv def native(outfile="repaired.ply"): diff --git a/pymeshfix/meshfix.py b/pymeshfix/meshfix.py index 1598a03..4fd761f 100644 --- a/pymeshfix/meshfix.py +++ b/pymeshfix/meshfix.py @@ -1,7 +1,9 @@ """Python module to interface with wrapped meshfix.""" + import ctypes import numpy as np + from pymeshfix import _meshfix try: @@ -12,7 +14,7 @@ PV_INSTALLED = False -class MeshFix(object): +class MeshFix: """Clean and tetrahedralize surface meshes using MeshFix. Parameters diff --git a/pyproject.toml b/pyproject.toml index d83dfb4..69e82db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=42", "wheel>=0.33.0", - "cython>=0.29.32", + "cython>=3.0.0", "oldest-supported-numpy" ] @@ -18,7 +18,7 @@ filterwarnings = [ [tool.cibuildwheel] archs = ["auto64"] # 64-bit only -skip = "pp* *musllinux*" # disable PyPy and musl-based wheels +skip = "pp* *musllinux* cp37-*" # disable PyPy and musl-based wheels and Python<3.8 test-requires = "pytest" test-command = "pytest {project}/tests" @@ -31,9 +31,7 @@ test-skip = ["*_arm64", "*_universal2:arm64"] skip = '*.cxx,*.h,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./doc/build/*,./doc/images/*,./dist/*,*~,.hypothesis*,*.cpp,*.c' quiet-level = 3 -[tool.isort] -profile = "black" -force_sort_within_sections = true -default_section = "THIRDPARTY" -skip_glob = ["__init__.py"] -src_paths = ["doc", "src", "tests"] +[tool.ruff] +line-length = 100 +# pyflakes, pycodestyle, isort +select = ["F", "E", "W", "I001"] \ No newline at end of file diff --git a/setup.py b/setup.py index d8dbe10..83c4c9b 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,11 @@ """Setup for pymeshfix.""" -from io import open as io_open + import os import sys +from io import open as io_open -from Cython.Build import cythonize import numpy as np +from Cython.Build import cythonize from setuptools import Extension, setup filepath = os.path.dirname(__file__)