diff --git a/MANIFEST.in b/MANIFEST.in index 294f635883..a527d92eb5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -34,12 +34,4 @@ include LICENSE include README* include CONTRIBUTING.md -include *.py -recursive-include contributions * -recursive-include bin * -recursive-include doc *.py *.rst Makefile pip_requirements.txt include src/psyclone/parse/lfric_builtins_mod.f90 -include config/*.cfg -recursive-include examples *.py *.c *.cl *90 *.md Makefile *.mk -recursive-include tutorial *.ipynb -recursive-include lib *.py *.sh *.md Makefile *.mk *.jinja *90 doxyfile diff --git a/changelog b/changelog index 0cc6df4660..31d3976fd0 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,10 @@ - 20) PR #3433 for 3432. Introduces initial support for sub transformations + 21) PR #3434 for #2813. Migrates the setup files to use a + pyproject.toml rather than setup.py. + + 20) PR #3433 for #3432. Introduces initial support for sub transformations and option handling. - 19) PR #3404 for 3403. Modernises the remaining runme examples. + 19) PR #3404 for #3403. Modernises the remaining runme examples. 18) PR #3410 towards #2668. Update more Transformations to use kwargs. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..7d2ee07ede --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,127 @@ +# ----------------------------------------------------------------------------- +# BSD 3-Clause License +# +# Copyright (c) 2026, Science and Technology Facilities Council. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "PSyclone" +dynamic = ["version"] +description = "PSyclone - a source-to-source and DSL Fortran compiler for HPC applications" +readme = "README.md" +authors = [ + { name = "Rupert Ford" }, + { name = "Andrew Porter", email = "andrew.porter@stfc.ac.uk" }, + { name = "Sergi Siso", email = "sergi.siso@stfc.ac.uk" }, + { name = "Aidan Chalk", email = "aidan.chalk@stfc.ac.uk" }, + { name = "Joerg Henrichs", email = "joerg.henrichs@bom.gov.au" } +] +license = { text = "BSD 3-Clause License" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Programming Language :: Fortran", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", + "Topic :: Utilities", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS" +] +dependencies = [ + "pyparsing", + "fparser==0.2.2", + "configparser", + "sympy", + "Jinja2", + "termcolor", + "graphviz" +] + +[project.optional-dependencies] +doc = [ + # Have to pin Sphinx to a pre-9.0 version because of + # https://github.com/sphinx-doc/sphinx/issues/14223 + "sphinx<=8.3", + "sphinxcontrib.bibtex", + "sphinx_design", + "pydata-sphinx-theme", + "sphinx-autodoc-typehints", + "autoapi" +] +test = [ + "flake8", + "pylint", + "pytest-cov", + "pytest-xdist", + "tree-sitter", + "tree-sitter-fortran" +] +treesitter = [ + "tree-sitter", + "tree-sitter-fortran" +] + +[project.urls] +Homepage = "https://github.com/stfc/psyclone" +Download = "https://github.com/stfc/psyclone" + +[tool.setuptools] +package-dir = { "" = "src" } +include-package-data = true +script-files = [ + "bin/psyclone", + "bin/psyclone-kern", + "bin/psyad", + "bin/psyclonefc" +] + +[tool.setuptools.packages.find] +where = ["src"] +exclude = ["psyclone.tests", "psyclone.tests.*"] + +[tool.setuptools.dynamic] +version = { attr = "psyclone.version.__VERSION__" } + +[tool.pytest.ini_options] +# Ensure that any XPASS ("unexpectedly passing") results are reported +# as failures in the test suite. +xfail_strict = true +addopts = "--ignore=external -p no:pep8" +filterwarnings = ["ignore::DeprecationWarning"] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 41783efc63..0000000000 --- a/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -#TODO #2813: This section should be moved to pyproject.toml -[pytest] -addopts = --ignore=external -W ignore::DeprecationWarning -p no:pep8 - diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7a7ca1336d..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,40 +0,0 @@ -# ----------------------------------------------------------------------------- -# BSD 3-Clause License -# -# Copyright (c) 2020-2026, Science and Technology Facilities Council. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# ----------------------------------------------------------------------------- -# Author: A. R. Porter, STFC Daresbury Laboratory. - -# Python packages required for Binder and not installed by default -# when using setup.py. (See README.md for details on launching the -# examples on Binder.) -termcolor -graphviz diff --git a/setup.cfg b/setup.cfg index c0229bc2c2..be5e08c70a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,12 +33,6 @@ # ----------------------------------------------------------------------------- # Author: A. R. Porter -# Ensure that any XPASS ("unexpectedly passing") results are reported -# as failures in the test suite. -[tool:pytest] -xfail_strict=true -filterwarnings=ignore::DeprecationWarning - [flake8] # Ignore E266 too many leading '#' for block comment since we use those for # Doxygen markup. diff --git a/setup.py b/setup.py index 80b0d34604..598891d04f 100644 --- a/setup.py +++ b/setup.py @@ -37,86 +37,32 @@ # I. Kavcic and P. Elson, Met Office # J. Henrichs, Bureau of Meteorology -"""Setup script. Used by easy_install and pip.""" +""" +Metadata and most configuration are now in pyproject.toml. +This script is retained for the dynamic calculation of data_files. +""" import os -from setuptools import setup, find_packages +from setuptools import setup - -BASE_PATH = os.path.dirname(os.path.abspath(__file__)) -SRC_PATH = os.path.join(BASE_PATH, "src") -PACKAGES = find_packages(where=SRC_PATH, - exclude=["psyclone.tests", - "psyclone.tests.test_files", - "psyclone.tests.*"]) - -NAME = 'PSyclone' -AUTHOR = ('Rupert Ford, ' - 'Andrew Porter , ' - 'Sergi Siso , ' - 'Aidan Chalk , ' - 'Joerg Henrichs ') -AUTHOR_EMAIL = 'andrew.porter@stfc.ac.uk' -URL = 'https://github.com/stfc/psyclone' -DOWNLOAD_URL = 'https://github.com/stfc/psyclone' -DESCRIPTION = ('PSyclone - a source-to-source and DSL Fortran compiler for ' - 'HPC applications') -LONG_DESCRIPTION = '''\ -PSyclone is a source-to-source Fortran compiler designed to programmatically -optimise, parallelise and instrument HPC applications via user-provided -transformation scripts. It also supports domain-specific language extensions -to the Fortran language, which simplify the implementation of Finite Element/ -Volume/Difference codes. - -PSyclone is used by the UK Met Office in their new weather model, LFRic -(https://www.metoffice.gov.uk/research/approach/modelling-systems/lfric), and -by the NEMO ocean-modelling framework -(https://sites.nemo-ocean.io/user-guide/psyclone.html). - -See https://github.com/stfc/psyclone for more information. -''' -LICENSE = 'OSI Approved :: BSD 3-Clause License' - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Natural Language :: English', - 'Programming Language :: Fortran', - 'Programming Language :: Python', - 'Topic :: Scientific/Engineering', - 'Topic :: Software Development', - 'Topic :: Utilities', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Operating System :: MacOS'] - -# We read the version number ('__VERSION__') from version.py in the -# src/psyclone directory. Rather than importing it (which would require -# that PSyclone already be installed), we read it and then exec() it: BASE_PATH = os.path.dirname(os.path.abspath(__file__)) -with open(os.path.join(BASE_PATH, "src", "psyclone", "version.py"), - encoding="utf-8") as vfile: - exec(vfile.read()) # pylint:disable=exec-used -VERSION = __VERSION__ # pylint:disable=undefined-variable # noqa: F821 if __name__ == '__main__': - def get_files(directory, install_path, valid_suffixes): + def get_files( + directory: str, install_path: str, valid_suffixes: list[str] + ) -> list[tuple[str, list[str]]]: '''Utility routine that creates a list of 2-tuples, each consisting of the target installation directory and a list of files (specified relative to the project root directory). - :param str directory: the directory containing the required files. - :param str install_path: the location where the files will be placed. + :param directory: the directory containing the required files. + :param install_path: the location where the files will be placed. :param valid_suffixes: the suffixes of the required files. - :type valid_suffixes: [str] - :returns: a list of 2-tuples, each consisting of the target \ - installation directory and a list of files (specified relative \ + :returns: a list of 2-tuples, each consisting of the target + installation directory and a list of files (specified relative to the project root directory). - :rtype: [(str, [str])] ''' examples = [] @@ -135,9 +81,6 @@ def get_files(directory, install_path, valid_suffixes): files)) return examples - # We have all of the example, tutorial and wrapper libraries files - # listed in MANIFEST.in but unless we specify them in the data_files - # argument of setup() they don't seem to get installed. # Since the data_files argument doesn't accept wildcards we have to # explicitly list every file we want. # INSTALL_PATH controls where the files will be installed. @@ -157,40 +100,9 @@ def get_files(directory, install_path, valid_suffixes): VALID_SUFFIXES = ["90", "sh", "py", "md", "Makefile", ".mk", ".jinja", "doxyfile"] LIBS = get_files(LIBS_DIR, INSTALL_PATH, VALID_SUFFIXES) - TS_EXTRAS = ["tree-sitter", "tree-sitter-fortran"] setup( - name=NAME, - version=VERSION, - author=AUTHOR, - author_email=(AUTHOR_EMAIL), - license=LICENSE, - url=URL, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - classifiers=CLASSIFIERS, - packages=PACKAGES, - package_dir={"": "src"}, - install_requires=['pyparsing', 'fparser==0.2.2', 'configparser', - 'sympy', "Jinja2", 'termcolor', 'graphviz'], - # Have to pin Sphinx to a pre-9.0 version because of - # https://github.com/sphinx-doc/sphinx/issues/14223 - extras_require={ - 'doc': ["sphinx<=8.3", "sphinxcontrib.bibtex", "sphinx_design", - "pydata-sphinx-theme", "sphinx-autodoc-typehints", - "autoapi"], - 'test': [ - "flake8", "pylint", "pytest-cov", "pytest-xdist" - ] + TS_EXTRAS, - 'treesitter': TS_EXTRAS, - }, - include_package_data=True, - scripts=[ - 'bin/psyclone', - 'bin/psyclone-kern', - 'bin/psyad', - 'bin/psyclonefc', - ], data_files=[ ('share/psyclone', - ['config/psyclone.cfg'])]+EXAMPLES+TUTORIAL+LIBS,) + ['config/psyclone.cfg'])] + EXAMPLES + TUTORIAL + LIBS, + )