From e224e9c9ed1849bc79a2870c49285d4252cb03d9 Mon Sep 17 00:00:00 2001 From: Eivind Fonn Date: Wed, 12 Apr 2023 22:00:37 +0200 Subject: [PATCH] Move to poetry --- .github/workflows/python-package.yml | 10 +- Makefile | 26 ++++ build_ext.py | 19 +++ poetry.lock | 198 +++++++++++++++++++++++++++ pyproject.toml | 66 +++++++++ setup.py => setup-old.py | 0 6 files changed, 312 insertions(+), 7 deletions(-) create mode 100644 Makefile create mode 100644 build_ext.py create mode 100644 poetry.lock create mode 100644 pyproject.toml rename setup.py => setup-old.py (100%) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4bb9683..b5da65f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -26,15 +26,11 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel - pip install -r requirements.txt - pip install -r requirements.dev.txt - - name: Install package - run: | - pip install -vvv . + python -m pip install --upgrade pip poetry + make install - name: Test with pytest run: | - pytest --benchmark-skip + make pytest build_wheels: name: Build wheels diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aa81946 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +.PHONY: install mypy lint pytest test fmt fmtcheck + +install: + poetry install --with=dev + +mypy: + poetry run mypy splipy + +lint: + poetry run ruff splipy + +pytest: + poetry run pytest --benchmark-skip + +bench: + poetry run pytest --benchmark-only + +fmt: + poetry run black splipy + poetry run isort splipy + +fmtcheck: + poetry run black splipy --check + poetry run isort splipy --check + +test: mypy pytest lint fmtcheck diff --git a/build_ext.py b/build_ext.py new file mode 100644 index 0000000..4a30b53 --- /dev/null +++ b/build_ext.py @@ -0,0 +1,19 @@ +import os +import sys + +from setuptools import Extension +from Cython.Build import cythonize +import numpy as np + +extensions = cythonize( + Extension( + "splipy.basis_eval", + ["splipy/basis_eval.pyx"], + include_dirs=[np.get_include()], + ) +) + +def build(setup_kwargs): + setup_kwargs.update({ + "ext_modules": extensions, + }) diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..443bc84 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,198 @@ +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" + +[[package]] +name = "cython" +version = "0.29.34" +description = "The Cython compiler for writing C extensions for the Python language." +category = "main" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "exceptiongroup" +version = "1.1.1" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "mypy" +version = "1.2.0" +description = "Optional static typing for Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=3.10" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +python2 = ["typed-ast (>=1.4.0,<2)"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +category = "dev" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "numpy" +version = "1.24.2" +description = "Fundamental package for array computing in Python" +category = "main" +optional = false +python-versions = ">=3.8" + +[[package]] +name = "packaging" +version = "23.0" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "py-cpuinfo" +version = "9.0.0" +description = "Get CPU info with pure Python" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "pytest" +version = "7.3.0" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] + +[[package]] +name = "pytest-benchmark" +version = "4.0.0" +description = "A ``pytest`` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +py-cpuinfo = "*" +pytest = ">=3.8" + +[package.extras] +aspect = ["aspectlib"] +elasticsearch = ["elasticsearch"] +histogram = ["pygal", "pygaljs"] + +[[package]] +name = "scipy" +version = "1.10.1" +description = "Fundamental algorithms for scientific computing in Python" +category = "main" +optional = false +python-versions = "<3.12,>=3.8" + +[package.dependencies] +numpy = ">=1.19.5,<1.27.0" + +[package.extras] +test = ["pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "asv", "mpmath", "gmpy2", "threadpoolctl", "scikit-umfpack", "pooch"] +doc = ["sphinx (!=4.1.0)", "pydata-sphinx-theme (==0.9.0)", "sphinx-design (>=0.2.0)", "matplotlib (>2)", "numpydoc"] +dev = ["mypy", "typing-extensions", "pycodestyle", "flake8", "rich-click", "click", "doit (>=0.36.0)", "pydevtool"] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "typing-extensions" +version = "4.5.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "dev" +optional = false +python-versions = ">=3.7" + +[extras] +FiniteElement = [] +Images = [] +Rhino = [] + +[metadata] +lock-version = "1.1" +python-versions = ">=3.8,<3.12" +content-hash = "6caa374f4015f464542342452ab344e9c6952d0b6d271881a07189a99cb72853" + +[metadata.files] +colorama = [] +cython = [] +exceptiongroup = [] +iniconfig = [] +mypy = [] +mypy-extensions = [] +numpy = [] +packaging = [] +pluggy = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] +py-cpuinfo = [] +pytest = [] +pytest-benchmark = [] +scipy = [] +tomli = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] +typing-extensions = [] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..71932b2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ +[tool.poetry] +name = "splipy" +version = "1.7.4" +description = "Spline modelling library for Python" +authors = [ + "Kjetil Andre Johannessen ", + "Eivind Fonn ", +] +maintainers = [ + "Kjetil Andre Johannessen ", + "Eivind Fonn ", +] +license = "GLP-3.0-only" +readme = "README.rst" +homepage = "https://github.com/SINTEF/Splipy" +repository = "https://github.com/SINTEF/Splipy" +documentation = "https://sintef.github.io/Splipy/" +keywords = [ + "Bspline", + "Splines", + "NURBS", + "Curve", + "Surface", + "Volume", + "Interpolation", + "Approximation", + "Fit", + "Integration", + "Differentiation", +] +classifiers = [ + "Development Status :: 5 - Beta", + "Topic :: Multimedia :: Graphics :: 3D Modeling", + "Topic :: Scientific/Engineering :: Mathematics", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3", +] +include = [ + "splipy/templates/*.bpt", + { path = "splipy/*.so", format="wheel" }, +] + +[tool.poetry.build] +script = "build_ext.py" +generate-setup-file = true + +[tool.poetry.dependencies] +python = ">=3.8,<3.12" +cython = "^0.29.34" +numpy = "^1.24.2" +scipy = "^1.10.1" + +[tool.poetry.extras] +FiniteElement = ["nutils"] +Images = ["opencv-python"] +Rhino = ["rhino3dm"] + +[tool.poetry.group.dev.dependencies] +mypy = "^1.2.0" +pytest = "^7.3.0" +pytest-benchmark = "^4.0.0" + +[build-system] +requires = ["poetry-core", "cython", "numpy", "wheel", "setuptools"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.py b/setup-old.py similarity index 100% rename from setup.py rename to setup-old.py