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

Maintenance updates #94

Merged
merged 8 commits into from
Sep 2, 2023
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
20 changes: 7 additions & 13 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build wheels and test
uses: pypa/[email protected]
env:
# disable builds for PyPy, all 32-bit, musl
CIBW_SKIP: "pp* *-win32 *-manylinux_i686 *-musllinux*"
# testing
CIBW_TEST_REQUIRES: pytest pandas
CIBW_TEST_COMMAND: pytest {package}/tests
uses: pypa/[email protected]

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand All @@ -44,13 +40,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
# this makes cythonize work so .c files are included in the sdist
run: python -m pip install numpy cython
with:
fetch-depth: 0

- name: Build sdist
run: python setup.py sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ build/
_bspl.*.pyd
_bspl.c
docs/auto_*
ndsplines/version.py
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

5 changes: 1 addition & 4 deletions ndsplines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ def set_impl(name):
evaluate_spline = _bspl.evaluate_spline
_impl = "cython"
except ImportError:
raise ImportError(
"Can't use cython implementation. Install cython then reinstall "
"ndsplines."
)
raise ImportError("Cython implementation not installed.")
elif name == "numpy":
from . import _npy_bspl

Expand Down
1 change: 0 additions & 1 deletion ndsplines/version.py

This file was deleted.

51 changes: 47 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
[project]
name = "ndsplines"
dynamic = ["version"]
description = "Multi-dimensional splines"
readme = "readme.rst"
authors = [
{name = "Benjamin Margolis", email = "[email protected]"},
]
maintainers = [
{name = "Kenneth Lyons", email = "[email protected]"},
]
license = {file = "LICENSE"}
classifiers=[
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
requires-python = ">=3.7"

dependencies = ["numpy", "scipy"]

[project.optional-dependencies]
test = ["pytest", "pandas"]
examples = ["matplotlib"]
docs = ["sphinx", "sphinx_gallery"]

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=42",
"wheel",
"Cython",
"setuptools>=45",
"setuptools_scm[toml]",
"cython",
"oldest-supported-numpy",
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
# autodiscovery doesn't exclude paper/
packages = ["ndsplines"]

[tool.setuptools_scm]
write_to = "ndsplines/version.py"

[tool.cibuildwheel]
# disable builds for PyPy, all 32-bit, musl
skip = "pp* *-win32 *-manylinux_i686 *-musllinux*"
test-extras = ["test"]
test-command = "pytest {project}/tests"
16 changes: 8 additions & 8 deletions readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ Install ndsplines with pip::

$ pip install ndsplines

or from source::
Wheels are provided for a range of Python versions and platforms, so no
compilation is required to get the better-performing Cython-based implementation
in many cases.

$ git clone https://github.com/kb-press/ndsplines
$ cd ndsplines
$ pip install .
If no matching wheel is found, pip will install build dependencies and attempt
to compile the Cython-based extension module. If this is not desired, set the
environment variable ``NDSPLINES_NUMPY_ONLY=1``, e.g.::

Reasonably recent versions of ``pip`` will automatically pull Cython and NumPy
to build the compiled implementation. If you need to install ndsplines without
compiling, try ``python setup.py install`` instead of using ``pip install``.
$ NDSPLINES_NUMPY_ONLY=1 pip install ndsplines

Usage
-----
Expand Down Expand Up @@ -82,7 +82,7 @@ evaluate it over a denser mesh.

.. code:: python
# create the interpolating splane
# create the interpolating spline
interp = ndsplines.make_interp_spline(gridxy, meshf)
# generate denser grid of independent variables to interpolate
Expand Down
88 changes: 15 additions & 73 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,22 @@
import os
from setuptools import setup, Extension

try:
import numpy
except ImportError:
use_numpy = False
else:
use_numpy = True
import numpy
from Cython.Build import cythonize
from setuptools import Extension, setup

try:
from Cython.Build import cythonize
except ImportError:
use_cython = False
else:
use_cython = True
numpy_only = os.environ.get("NDSPLINES_NUMPY_ONLY") == "1"

name = "ndsplines"
extname = '_bspl'
ext_modules = []

if use_cython and use_numpy:
extensions = cythonize([
Extension("{}.{}".format(name, extname),
[os.path.join(name, "{}.pyx".format(extname))],
include_dirs=[numpy.get_include()],
depends=[os.path.join(name, "{}.h".format(extname))]),
])

elif use_numpy:
extensions = [
Extension("{}.{}".format(name, extname),
[os.path.join(name, "{}.c".format(extname))],
include_dirs=[numpy.get_include()],
depends=[os.path.join(name, "{}.h".format(extname)),],
optional=True)
]
else:
extensions = []

exec(open('ndsplines/version.py').read())

here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'readme.rst'), encoding='utf-8') as f:
long_description = f.read()

long_description = long_description.replace(
"https://ndsplines.readthedocs.io/en/latest/",
"https://ndsplines.readthedocs.io/en/v{}/".format(
'.'.join(__version__.split('.')[:3])
if not numpy_only:
ext_modules.extend(
cythonize(
Extension(
"ndsplines._bspl",
[os.path.join("ndsplines", "_bspl.pyx")],
include_dirs=["ndsplines", numpy.get_include()],
)
)
)
)

setup(
name=name,
version=__version__,
description="Multi-dimensional splines",
url="https://github.com/kb-press/ndsplines",
author="Benjamin Margolis",
author_email="[email protected]",
classifiers=[
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
packages=["ndsplines"],
ext_modules=extensions,
long_description=long_description,
license='BSD',
install_requires=['numpy', 'scipy'],
extras_require={
'test': ['pytest', 'pandas'],
'examples': ['matplotlib'],
'build_ext': ['cython'],
'docs': ['sphinx', 'sphinx_gallery']
},
)
setup(ext_modules=ext_modules)