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

use ruff; build python3.12 #61

Merged
merged 6 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 19 additions & 7 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected].6
- uses: pypa/[email protected].11
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
Expand Down
27 changes: 11 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include pymeshfix/cython/*.pyx
include pymeshfix/cython/*.h
include tests/*
16 changes: 8 additions & 8 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""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")
# Ensure that offscreen rendering is used for docs generation
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):
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -184,8 +186,6 @@


# -- Sphinx Gallery Options
from sphinx_gallery.sorting import FileNameSortKey

sphinx_gallery_conf = {
# path to your examples scripts
"examples_dirs": [
Expand Down
4 changes: 2 additions & 2 deletions examples/bunny.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion examples/cow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion examples/repair_planar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/torso.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions pymeshfix/__init__.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions pymeshfix/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
version_info = 0, 27, 'dev0'

"""

version_info = 0, 17, "dev0"
__version__ = ".".join(map(str, version_info))
3 changes: 2 additions & 1 deletion pymeshfix/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Built-in examples."""

# get location of the example meshes
from os.path import dirname, join, realpath

pth = dirname(realpath(__file__))
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
4 changes: 3 additions & 1 deletion pymeshfix/examples/fix.py
Original file line number Diff line number Diff line change
@@ -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"):
Expand Down
4 changes: 3 additions & 1 deletion pymeshfix/meshfix.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Python module to interface with wrapped meshfix."""

import ctypes

import numpy as np

from pymeshfix import _meshfix

try:
Expand All @@ -12,7 +14,7 @@
PV_INSTALLED = False


class MeshFix(object):
class MeshFix:
"""Clean and tetrahedralize surface meshes using MeshFix.

Parameters
Expand Down
14 changes: 6 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires = [
"setuptools>=42",
"wheel>=0.33.0",
"cython>=0.29.32",
"cython>=3.0.0",
"oldest-supported-numpy"
]

Expand All @@ -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"

Expand All @@ -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"]
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down
Loading