From ae416776ced85aa354d28c80265734e2a29f49d9 Mon Sep 17 00:00:00 2001 From: Bane Sullivan Date: Sat, 5 Feb 2022 18:12:14 -0700 Subject: [PATCH 1/2] Add note on AGPL in README to resolve #34 --- README.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.rst b/README.rst index c7f5650..1250148 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,18 @@ Brief description from finite volume methods. For more information of TetGen, please take a look at a list of `features `__. +License (AGPL) +-------------- + +The original `TetGen `__ software is under AGPL +(see `LICENSE `_) and thus this +Python wrapper package must adopt that license as well. + +Please look into the terms of this license before creating a dynamic link to this software +in your downstream package and understand commercial use limitations. We are not lawyers +and cannot provide any guidance on the terms of this license. + +Please see https://www.gnu.org/licenses/agpl-3.0.en.html Installation ------------ From 6dc02b00cda220c89182b770b8c71649fc04be86 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Tue, 2 Aug 2022 07:49:32 -0600 Subject: [PATCH 2/2] Add cibuildwheel (#43) * add cibuildwheel * add in test req --- .github/workflows/build-and-deploy.yml | 52 ++++++++ .github/workflows/docbuild.yml | 4 +- .github/workflows/testing-and-deployment.yml | 57 -------- README.rst | 1 - azure-pipelines.yml | 66 ---------- pyproject.toml | 31 +++++ requirements_build.txt | 4 - setup.py | 129 +++++++------------ 8 files changed, 128 insertions(+), 216 deletions(-) create mode 100644 .github/workflows/build-and-deploy.yml delete mode 100644 .github/workflows/testing-and-deployment.yml delete mode 100644 azure-pipelines.yml create mode 100644 pyproject.toml delete mode 100644 requirements_build.txt diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..64f4688 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,52 @@ +name: Build and upload to PyPI + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macos-10.15] + + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.8.0 + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + # upload to PyPI on every tag + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + # 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 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docbuild.yml b/.github/workflows/docbuild.yml index 9c5f523..095d602 100644 --- a/.github/workflows/docbuild.yml +++ b/.github/workflows/docbuild.yml @@ -23,9 +23,7 @@ jobs: .ci/setup_headless_display.sh - name: Install tetgen - run: | - pip install -r requirements_build.txt - pip install . + run: pip install . - name: Build Documentation run: | diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml deleted file mode 100644 index d9b4149..0000000 --- a/.github/workflows/testing-and-deployment.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Unit Testing - -on: - push: - branches: "*" - tags: "*" - pull_request: - branches: "**" - -jobs: - macOS: - runs-on: macos-latest - name: Mac OS Unit Testing - strategy: - matrix: - python-version: ['3.6', '3.7', '3.8', '3.9'] - - env: - SHELLOPTS: 'errexit:pipefail' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Build package - run: | - pip install -r requirements_build.txt - python setup.py bdist_wheel - - - name: Install package - run: | - pip install dist/* - python -c "import pyvista; print(pyvista.Report(gpu=False))" - - - name: Install test dependencies - run: | - pip install -r requirements_test.txt - - - name: Unit testing - run: | - pytest -v - - - name: Validate package - run: | - pip install twine - twine check dist/* - - - name: Upload to PyPi - if: startsWith(github.event.ref, 'refs/tags') - run: | - twine upload -u __token__ --skip-existing dist/* - env: - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} diff --git a/README.rst b/README.rst index 1250148..81a9029 100644 --- a/README.rst +++ b/README.rst @@ -55,7 +55,6 @@ From source at `GitHub `__ git clone https://github.com/pyvista/tetgen cd tetgen - pip install -r requirements_build.txt pip install . diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index dc33f12..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,66 +0,0 @@ -# build tetgen wheels - -variables: - package_name: tetgen - -trigger: - branches: - include: - - '*' - tags: - include: - - '*' - -jobs: -- job: Linux - strategy: - matrix: - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - Python38: - python.version: '3.8' - Python39: - python.version: '3.9' - pool: - vmImage: 'ubuntu-20.04' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' - - script: | - set -ex - docker pull quay.io/pypa/manylinux2010_x86_64 - docker run -e package_name=$(package_name) --rm -v `pwd`:/io quay.io/pypa/manylinux2010_x86_64 /io/.ci/build_wheels.sh $(python.version) - displayName: Build wheel using manylinux2010 - - script: | - pip install dist/*.whl - displayName: Install wheel - - script: | - pip install -r requirements_test.txt - pip install pytest-azurepipelines - (cd tests && pytest --cov $(package_name) --cov-report html) - - template: .ci/azure-publish-dist.yml - - -- job: Windows - pool: - vmIMage: 'windows-2019' - variables: - python.architecture: 'x64' - strategy: - matrix: - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - Python38: - python.version: '3.8' - Python39: - python.version: '3.9' - steps: - - template: .ci/azure-setup.yml - - template: .ci/azure-steps.yml - - template: .ci/azure-publish-dist.yml \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cd3b962 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,31 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel>=0.33.0", + "cython>=0.29.0", + "oldest-supported-numpy" +] + +build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +junit_family= "legacy" +filterwarnings = [ + "ignore::FutureWarning", + "ignore::PendingDeprecationWarning", + "ignore::DeprecationWarning", + # bogus numpy ABI warning (see numpy/#432) + "ignore:.*numpy.dtype size changed.*:RuntimeWarning", + "ignore:.*numpy.ufunc size changed.*:RuntimeWarning" +] + +[tool.cibuildwheel] +archs = ["auto64"] # 64-bit only +skip = "pp* *musllinux*" # disable PyPy and musl-based wheels +test-requires = "pytest pymeshfix" +test-command = "pytest {project}/tests" + +[tool.cibuildwheel.macos] +# https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon +archs = ["x86_64", "universal2"] +test-skip = ["*_arm64", "*_universal2:arm64"] diff --git a/requirements_build.txt b/requirements_build.txt deleted file mode 100644 index cf68ff4..0000000 --- a/requirements_build.txt +++ /dev/null @@ -1,4 +0,0 @@ -setuptools>=41.0.0 -wheel>=0.33.0 -numpy<1.20.0 -cython>=0.29.0 diff --git a/setup.py b/setup.py index 6319da4..136714b 100644 --- a/setup.py +++ b/setup.py @@ -1,106 +1,65 @@ -"""Setup for tetgen""" +"""Setup for tetgen.""" import os import sys import builtins from setuptools import setup, Extension -from setuptools.command.build_ext import build_ext as _build_ext +from Cython.Build import cythonize from io import open as io_open - +import numpy as np # Version from file __version__ = None -version_file = os.path.join(os.path.dirname(__file__), 'tetgen', '_version.py') -with io_open(version_file, mode='r') as fd: +version_file = os.path.join(os.path.dirname(__file__), "tetgen", "_version.py") +with io_open(version_file, mode="r") as fd: exec(fd.read()) -def needs_cython(): - """Check if cython source exist""" - tgt_path = os.path.join('tetgen', 'cython', 'tetgen') - has_cython_src = any(['_tetgen.cxx' in fname for fname in os.listdir(tgt_path)]) - if not has_cython_src: - try: - import cython - except ImportError: - raise ImportError('Please install cython to build ``tetgen``') - return not has_cython_src - - -def needs_numpy(): - """Check if cython source exist""" - tgt_path = os.path.join('tetgen') - has_cython_src = any(['_tetgen' in fname for fname in os.listdir(tgt_path)]) - return not has_cython_src - - -setup_requires = [] -if needs_cython(): - setup_requires.extend(['cython']) - -# for: the cc1plus: warning: command line option '-Wstrict-prototypes' -class build_ext(_build_ext): - def finalize_options(self): - _build_ext.finalize_options(self) - # prevent numpy from thinking it is still in its setup process: - try: - del builtins.__NUMPY_SETUP__ - except AttributeError: - pass - import numpy - self.include_dirs.append(numpy.get_include()) - - def build_extensions(self): - try: - self.compiler.compiler_so.remove("-Wstrict-prototypes") - except (AttributeError, ValueError): - pass - _build_ext.build_extensions(self) - - # compiler args -if os.name == 'nt': # windows - extra_compile_args = ['/openmp', '/O2', '/w', '/GS'] -elif os.name == 'posix': # linux org mac os - extra_compile_args = ['-std=gnu++11', '-O3', '-w'] +if os.name == "nt": # windows + extra_compile_args = ["/openmp", "/O2", "/w", "/GS"] +elif os.name == "posix": # linux org mac os + extra_compile_args = ["-std=gnu++11", "-O3", "-w"] else: - raise Exception('Unsupported OS %s' % os.name) + raise Exception(f"Unsupported OS {os.name}") setup( - name='tetgen', - packages=['tetgen'], + name="tetgen", + packages=["tetgen"], version=__version__, - description='Python interface to tetgen', - long_description=open('README.rst').read(), - long_description_content_type='text/x-rst', - - author='Alex Kaszynski', - author_email='akascap@gmail.com', - url='https://github.com/pyvista/tetgen', - + description="Python interface to tetgen", + long_description=open("README.rst").read(), + long_description_content_type="text/x-rst", + author="Alex Kaszynski", + author_email="akascap@gmail.com", + url="https://github.com/pyvista/tetgen", classifiers=[ - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: GNU Affero General Public License v3', - 'Development Status :: 4 - Beta', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ], - # Build cython modules - cmdclass={'build_ext': build_ext}, - ext_modules=[Extension("tetgen._tetgen", - ['tetgen/cython/tetgen/_tetgen.pyx', - 'tetgen/cython/tetgen/tetgen.cxx', - 'tetgen/cython/tetgen/predicates.cxx', - 'tetgen/cython/tetgen/tetgen_wrap.cxx'], - language='c++', - extra_compile_args=extra_compile_args, - define_macros=[('TETLIBRARY', None)]), - ], - keywords='TetGen', - install_requires=['numpy>1.16.0', - 'pyvista>=0.31.0'], - setup_requires=setup_requires, + ext_modules=cythonize( + [ + Extension( + "tetgen._tetgen", + [ + "tetgen/cython/tetgen/_tetgen.pyx", + "tetgen/cython/tetgen/tetgen.cxx", + "tetgen/cython/tetgen/predicates.cxx", + "tetgen/cython/tetgen/tetgen_wrap.cxx", + ], + language="c++", + extra_compile_args=extra_compile_args, + include_dirs=[np.get_include()], + define_macros=[("TETLIBRARY", None)], + ), + ], + ), + keywords="TetGen", + install_requires=["numpy>1.16.0", "pyvista>=0.31.0"], )