diff --git a/README b/README.md similarity index 100% rename from README rename to README.md diff --git a/docs/conf.py b/docs/conf.py index 6fc51bd..cace7e3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,31 +5,20 @@ import os import sys +try: + from importlib import metadata +except ImportError: + import importlib_metadata as metadata + # path to autogen'ed modules sys.path.append(os.path.abspath('..')) - -# mock out some extension modules -class Mock: - def __init__(self, *args, **kwargs): - pass - - def __call__(self, *args, **kwargs): - return Mock() - - @classmethod - def __getattr__(self, name): - if name in ('__file__', '__path__'): - return '/dev/null' - elif name[0] == name[0].upper(): - return type(name, (), {}) - else: - return Mock() - -for mod_name in [ 'sympy', 'numpy', 'pyweno.codeprinters', 'pyweno.ccoeffs', 'pyweno.cweno' ]: - sys.modules[mod_name] = Mock() +m = metadata.metadata('PyWENO') # extentions -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax'] +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.mathjax', + ] # general configuration source_suffix = '.rst' @@ -37,16 +26,14 @@ def __getattr__(self, name): # html configuration pygments_style = 'sphinx' -html_theme = 'default' +html_theme = 'sphinx_rtd_theme' html_sidebars = { '**': ['globaltoc.html', 'searchbox.html'], } # project information -project = 'PyWENO' -copyright = '2009, 2010, 2011, Matthew Emmett' - -with open('../version.py') as f: - exec(f.read()) # this sets 'version' -release = version +project = m['Name'] +author = m['Author-email'] +copyright = f'2009, 2010, 2011 {author}' +release = m['Version'] diff --git a/docs/download.rst b/docs/download.rst index 600de1e..3887050 100644 --- a/docs/download.rst +++ b/docs/download.rst @@ -9,23 +9,32 @@ have `pip`_ installed, you can install PyWENO by:: $ pip install pyweno - -From github +From GitHub ----------- The latest source distribution is also available in either zip_ or tar_ format. Finally, you can also obtain the source code on GitHub through the `PyWENO project page`_. +When using the source code from GitHub, keep in mind that PyWENO uses the +`meson-python `__ build system and requires +both ``meson`` and ``ninja`` to be available locally to build the project. For +development, an editable build is recommended:: + + $ pip install --no-build-isolation --editable . + +To create wheels or your own source distributions, you can use:: -Tracking the development repo ------------------------------ + $ python -m build --wheel + $ python -m build --sdist + +Tracking the development repository +----------------------------------- You can clone the project by running:: $ git clone git://github.com/memmett/PyWENO - .. _zip: http://github.com/memmett/PyWENO/zipball/master .. _tar: http://github.com/memmett/PyWENO/tarball/master .. _`PyWENO project page`: http://github.com/memmett/PyWENO diff --git a/docs/reference.rst b/docs/reference.rst index c3b323a..1fde506 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -46,9 +46,3 @@ Non-uniform reconstructions .. automodule:: pyweno.nonuniform :members: - - -Version -------- - -.. automodule:: pyweno.version diff --git a/docs/tutorial.rst b/docs/tutorial.rst index e293dec..d802afc 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -47,11 +47,12 @@ The code to generate the above is in Version information ------------------- -Here we obtain the version of PyWENO:: +PyWENO uses standard Python packaging, so its version information can be obtained +through ``importlib``. However, you can also get it from the module itself:: - >>> import pyweno.version - >>> pyweno.version.version() - >>> pyweno.version.git_version() + >>> from pyweno import __version__ + >>> __version__ + '0.11.2' diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..8ff11bd --- /dev/null +++ b/meson.build @@ -0,0 +1,163 @@ +project('PyWENO', 'c', + version: '0.11.2', + license: 'BSD-3-Clause', + meson_version: '>=1.1.0', + default_options : ['warning_level=2', 'c_std=c99'], +) + +# get dependencies +py_mod = import('python') +py = py_mod.find_installation(pure: false) +py_dep = py.dependency() + +# NOTE: meson does not like absolute paths, so we dance around it +incdir_numpy = run_command(py, + [ + '-c', + '''import os +import numpy as np +try: + incdir = os.path.relpath(np.get_include()) +except Exception: + incdir = np.get_include() +print(incdir) + '''], check: true).stdout().strip() +inc_numpy = include_directories(incdir_numpy) + +# create extension modules +py.extension_module( + 'ccoeffs', [ + 'src/ccoeffs.c', + 'src/coeffs003.c', + 'src/coeffs004.c', + 'src/coeffs005.c', + 'src/coeffs006.c', + 'src/coeffs007.c', + 'src/coeffs008.c', + 'src/coeffs009.c', + ], + include_directories: [inc_numpy], + install: true, + subdir: 'pyweno') + +py.extension_module( + 'cweno', [ + 'src/cweno.c', + 'src/weno_gauss_legendre003002.c', + 'src/weno_gauss_legendre003003.c', + 'src/weno_gauss_legendre004002.c', + 'src/weno_gauss_legendre004004.c', + 'src/weno_gauss_legendre005002.c', + 'src/weno_gauss_legendre005003.c', + 'src/weno_gauss_legendre005004.c', + 'src/weno_gauss_legendre005005.c', + 'src/weno_gauss_legendre006002.c', + 'src/weno_gauss_legendre006004.c', + 'src/weno_gauss_legendre006006.c', + 'src/weno_gauss_legendre007002.c', + 'src/weno_gauss_legendre007003.c', + 'src/weno_gauss_legendre007004.c', + 'src/weno_gauss_legendre007005.c', + 'src/weno_gauss_legendre007006.c', + 'src/weno_gauss_legendre007007.c', + 'src/weno_gauss_legendre008002.c', + 'src/weno_gauss_legendre008004.c', + 'src/weno_gauss_legendre008006.c', + 'src/weno_gauss_legendre008008.c', + 'src/weno_gauss_lobatto003002.c', + 'src/weno_gauss_lobatto003003.c', + 'src/weno_gauss_lobatto004002.c', + 'src/weno_gauss_lobatto004004.c', + 'src/weno_gauss_lobatto005002.c', + 'src/weno_gauss_lobatto005003.c', + 'src/weno_gauss_lobatto005004.c', + 'src/weno_gauss_lobatto005005.c', + 'src/weno_gauss_lobatto006002.c', + 'src/weno_gauss_lobatto006004.c', + 'src/weno_gauss_lobatto006006.c', + 'src/weno_gauss_lobatto007002.c', + 'src/weno_gauss_lobatto007003.c', + 'src/weno_gauss_lobatto007004.c', + 'src/weno_gauss_lobatto007005.c', + 'src/weno_gauss_lobatto007006.c', + 'src/weno_gauss_lobatto007007.c', + 'src/weno_gauss_lobatto008002.c', + 'src/weno_gauss_lobatto008004.c', + 'src/weno_gauss_lobatto008006.c', + 'src/weno_gauss_lobatto008008.c', + 'src/weno_gauss_radau003002.c', + 'src/weno_gauss_radau003003.c', + 'src/weno_gauss_radau004002.c', + 'src/weno_gauss_radau004003.c', + 'src/weno_gauss_radau004004.c', + 'src/weno_gauss_radau005002.c', + 'src/weno_gauss_radau005003.c', + 'src/weno_gauss_radau005004.c', + 'src/weno_gauss_radau005005.c', + 'src/weno_gauss_radau006002.c', + 'src/weno_gauss_radau006003.c', + 'src/weno_gauss_radau006004.c', + 'src/weno_gauss_radau006005.c', + 'src/weno_gauss_radau006006.c', + 'src/weno_gauss_radau007002.c', + 'src/weno_gauss_radau007003.c', + 'src/weno_gauss_radau007004.c', + 'src/weno_gauss_radau007005.c', + 'src/weno_gauss_radau007006.c', + 'src/weno_gauss_radau007007.c', + 'src/weno_gauss_radau008002.c', + 'src/weno_gauss_radau008003.c', + 'src/weno_gauss_radau008004.c', + 'src/weno_gauss_radau008005.c', + 'src/weno_gauss_radau008006.c', + 'src/weno_gauss_radau008007.c', + 'src/weno_gauss_radau008008.c', + 'src/weno_left003001.c', + 'src/weno_left004001.c', + 'src/weno_left005001.c', + 'src/weno_left006001.c', + 'src/weno_left007001.c', + 'src/weno_left008001.c', + 'src/weno_middle003001.c', + 'src/weno_middle005001.c', + 'src/weno_middle007001.c', + 'src/weno_right003001.c', + 'src/weno_right004001.c', + 'src/weno_right005001.c', + 'src/weno_right006001.c', + 'src/weno_right007001.c', + 'src/weno_right008001.c', + 'src/weno_smoothness003.c', + 'src/weno_smoothness004.c', + 'src/weno_smoothness005.c', + 'src/weno_smoothness006.c', + 'src/weno_smoothness007.c', + 'src/weno_smoothness008.c', + 'src/weno_smoothness009.c', + ], + include_directories: [inc_numpy], + install: true, + subdir: 'pyweno') + +py.extension_module( + 'cnonuniform', [ + 'src/nfweno.c', + 'src/poly.c', + ], + include_directories: [inc_numpy], + install: true, + subdir: 'pyweno') + +# add sources +py.install_sources([ + 'pyweno/__init__.py', + 'pyweno/codeprinters.py', + 'pyweno/kernels.py', + 'pyweno/nonuniform.py', + 'pyweno/points.py', + 'pyweno/reconstruction_coeffs.py', + 'pyweno/symbolic.py', + 'pyweno/symbols.py', + 'pyweno/weno.py', + ], + subdir: 'pyweno') diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..84bf1aa --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[build-system] +build-backend = "mesonpy" +requires = [ + "meson-python>=0.14", + "ninja", + "numpy", +] + +[project] +name = "PyWENO" +version = "0.11.2" +description = "Weighted Essentially Non-oscillatory (WENO) reconstructions" +readme = "README.md" +keywords = [ + "finite volume", + "interpolation", + "weno", +] +license = { text = "BSD-3-Clause" } +maintainers = [{ name = "Matthew Emmett", email = "matthew@emmett.ca" }] +authors = [{ name = "Matthew Emmett", email = "matthew@emmett.ca" }] +requires-python = ">=3.6" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: C", + "Programming Language :: Fortran", + "Programming Language :: Python :: 3 :: Only", + "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", +] +dependencies = [ + 'importlib-metadata; python_version < "3.8"', + "numpy", + "sympy", +] +[project.urls] +Documentation = "https://pyweno.readthedocs.io" +Repository = "https://github.com/memmett/PyWENO" diff --git a/pyweno/__init__.py b/pyweno/__init__.py index 6b92e51..db4587c 100644 --- a/pyweno/__init__.py +++ b/pyweno/__init__.py @@ -1,10 +1,28 @@ """The PyWENO module.""" +try: + from importlib import metadata +except ImportError: + import importlib_metadata as metadata + from . import points from . import kernels from . import nonuniform from . import symbolic from . import symbols -from . import version from . import weno from . import cweno + +__version__ = version = metadata.version('PyWENO') + +__all__ = ( + 'points', + 'kernels', + 'nonuniform', + 'symbolic', + 'symbols', + 'weno', + 'cweno', + 'version', + '__version__', + ) diff --git a/pyweno/version.py b/pyweno/version.py deleted file mode 100644 index 85e3d80..0000000 --- a/pyweno/version.py +++ /dev/null @@ -1,28 +0,0 @@ -"""PyWENO version information. - - To obtain the version of PyWENO:: - - >>> import pyweno.version - >>> pyweno.version.version() - >>> pyweno.version.git_version() - - """ - -import imp -import os - -def _version(name): - version_file = os.path.join(os.path.dirname(__file__), name + '.py') - version = imp.load_module('pyweno.pyweno.' + name, - open(version_file), - version_file, - ('.py', 'U', 1)) - return version.version - -def version(): - """Return current version.""" - return _version('__version__') - -def git_version(): - """Return current *git* version (if available).""" - return _version('__git_version__') diff --git a/setup.py b/setup.py index bdc47b1..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,99 +1,3 @@ -'''PyWENO setup script.''' +from setuptools import setup -import glob -import os -import re - -from setuptools import setup, Extension -import numpy as np - - -############################################################################### -# version - -with open('version.py') as f: - exec(f.read()) # this sets 'version' - -with open('README') as file: - long_description = file.read() - - -############################################################################### -# save git version to 'pyweno/__git_version__.py' - -try: - git_head_file = os.path.join(os.path.dirname(__file__), '.git', 'HEAD') - with open(git_head_file) as f: - m = re.match(r'ref: (.+)', f.readline()) - ref = m.group(1) - - git_head_file = os.path.join(os.path.dirname(__file__), '.git', ref) - with open(git_head_file) as f: - git_version = f.readline().rstrip() -except: - git_version = 'not_available' - -git_version_file = os.path.join(os.path.dirname(__file__), - 'pyweno','__git_version__.py') -with open(git_version_file, 'w') as f: - f.write("version = '%s'\n" % (git_version)) - - -############################################################################### -# save version to 'pyweno/__version__.py' - -version_file = os.path.join(os.path.dirname(__file__), - 'pyweno','__version__.py') - -with open(version_file, 'w') as f: - f.write("version = '%s'\n" % (version)) - - -############################################################################### -# setup! - -setup( - - name = "PyWENO", - packages = ['pyweno'], - version = version, - author = "Matthew Emmett", - author_email = "matthew@emmett.ca", - description = "Weighted Essentially Non-oscillatory (WENO) reconstructions.", - license = "BSD", - keywords = "weno, interpolate, interpolation, finite, volume", - url = "http://readthedocs.org/docs/pyweno/en/latest/", - - ext_modules = [ - Extension('pyweno.ccoeffs', - sources = ['src/ccoeffs.c'] + glob.glob('src/coeffs*.c'), - include_dirs=[np.get_include()] - ), - Extension('pyweno.cweno', - sources = ['src/cweno.c'] + glob.glob('src/weno*.c'), - include_dirs=[np.get_include()], - extra_compile_args = ['-std=c99'], - ), - Extension('pyweno.cnonuniform', - sources = ['src/nfweno.c', 'src/poly.c'], - include_dirs=[np.get_include()], - extra_compile_args = ['-std=c99'], - )], - - long_description = long_description, - - classifiers = [ - 'Development Status :: 4 - Beta', - 'Development Status :: 5 - Production/Stable', -# 'Development Status :: 6 - Mature', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python ', - 'Programming Language :: C', - 'Programming Language :: Fortran', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Mathematics', - ], - - ) +setup() diff --git a/version.py b/version.py deleted file mode 100644 index d61e50f..0000000 --- a/version.py +++ /dev/null @@ -1 +0,0 @@ -version = '0.11.2'