diff --git a/.gitignore b/.gitignore index 54ab513d..efe9a421 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,5 @@ src/fparser/_version.py doc/build doc/source/autogenerated doc/source/doxygen +doc/source/autoapi build diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3b6f98..f2f6f742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ Modifications by (in alphabetical order): * P. Vitt, University of Siegen, Germany * A. Voysey, UK Met Office +04/06/2026 PR #507 for #506. Remove setuptools_scm_git dependency. Version + information is now always obtained using importlib.metadata.version. + 04/06/2026 PR #509 for #505. Fix truncated syntax error reporting when files have line breaks before the module or program. diff --git a/doc/doxygen.config b/doc/doxygen.config index 895787e1..6ece9a6c 100644 --- a/doc/doxygen.config +++ b/doc/doxygen.config @@ -38,7 +38,7 @@ PROJECT_NAME = "fparser" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.0.16 +PROJECT_NUMBER = 0.2.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/source/conf.py b/doc/source/conf.py index 04b36111..53dc7d56 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -6,14 +6,13 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information import subprocess -import fparser project = 'fparser' -copyright = '2017-2024, Science and Technology Facilities Council' -author = 'Andrew Porter, Rupert Ford, Balthasar Reuter, Joerg Henrichs and Pearu Peterson' - -version = fparser._get_version() -release = fparser._get_version() +copyright = '2017-2026, Science and Technology Facilities Council' +author = ( + 'Andrew Porter, Rupert Ford, Balthasar Reuter, Joerg Henrichs, ' + 'Sergi Siso and Pearu Peterson' +) # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/doc/source/developers_guide.rst b/doc/source/developers_guide.rst index 1244b6ff..63d7f558 100644 --- a/doc/source/developers_guide.rst +++ b/doc/source/developers_guide.rst @@ -1,4 +1,4 @@ -.. Copyright (c) 2017-2023 Science and Technology Facilities Council. +.. Copyright (c) 2017-2026 Science and Technology Facilities Council. All rights reserved. diff --git a/doc/source/fparser.rst b/doc/source/fparser.rst index 64ebefbd..ca83bcb6 100644 --- a/doc/source/fparser.rst +++ b/doc/source/fparser.rst @@ -1,7 +1,7 @@ .. -*- rest -*- .. - Copyright (c) 2017-2023 Science and Technology Facilities Council. + Copyright (c) 2017-2026 Science and Technology Facilities Council. All rights reserved. diff --git a/doc/source/fparser2.rst b/doc/source/fparser2.rst index a7571db7..081438d2 100644 --- a/doc/source/fparser2.rst +++ b/doc/source/fparser2.rst @@ -1,4 +1,4 @@ -.. Copyright (c) 2017-2024 Science and Technology Facilities Council. +.. Copyright (c) 2017-2026 Science and Technology Facilities Council. All rights reserved. diff --git a/doc/source/index.rst b/doc/source/index.rst index 231e57bc..ddd2e30f 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -3,7 +3,7 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. - Modified work Copyright (c) 2017-2022 Science and Technology Facilities + Modified work Copyright (c) 2017-2026 Science and Technology Facilities Council. Original work Copyright (c) 1999-2008 Pearu Peterson diff --git a/doc/source/introduction.rst b/doc/source/introduction.rst index 3986f194..306818c2 100644 --- a/doc/source/introduction.rst +++ b/doc/source/introduction.rst @@ -1,4 +1,4 @@ -.. Copyright (c) 2017-2019 Science and Technology Facilities Council. +.. Copyright (c) 2017-2026 Science and Technology Facilities Council. All rights reserved. diff --git a/doc/source/license.rst b/doc/source/license.rst index db825cd5..6b16db19 100644 --- a/doc/source/license.rst +++ b/doc/source/license.rst @@ -4,7 +4,7 @@ License ======= -| Modified work Copyright (c) 2017-2021 Science and Technology Facilities Council +| Modified work Copyright (c) 2017-2026 Science and Technology Facilities Council | Authors: **Andrew Porter** and **Rupert Ford**, STFC Daresbury Laboratory, | **Balthasar Reuter**, ECMWF, and | **Joerg Henrichs**, Bureau of Meteorology diff --git a/pyproject.toml b/pyproject.toml index ad1dff09..504d9f59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,7 @@ [build-system] requires = [ - "setuptools >= 61", - "setuptools_scm[toml] >= 6.2", - "setuptools_scm_git_archive", + "setuptools >= 80", + "setuptools_scm[toml] >= 8", "wheel >= 0.29.0", ] build-backend = "setuptools.build_meta" @@ -11,7 +10,8 @@ build-backend = "setuptools.build_meta" name = "fparser" authors = [{name = "Pearu Peterson"}, {name = "Rupert Ford"}, - {name = "Andrew Porter", email = "andrew.porter@stfc.ac.uk"}] + {name = "Andrew Porter", email = "andrew.porter@stfc.ac.uk"}, + {name = "Sergi Siso", email = "sergi.siso@stfc.ac.uk"}] license = {text = "BSD-3-Clause"} description = "Python implementation of a Fortran parser" readme = "README.md" @@ -33,7 +33,6 @@ classifiers = [ keywords = ["fortran", "parser"] dynamic = ["version"] requires-python = ">=3.6" -dependencies = ["setuptools_scm"] [project.optional-dependencies] doc = ["sphinx", "sphinxcontrib.bibtex", "autoapi", "sphinx-autoapi", "sphinx_rtd_theme"] diff --git a/setup.py b/setup.py deleted file mode 100755 index 3bfb8319..00000000 --- a/setup.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -# Modified work Copyright (c) 2017-2023 Science and Technology -# Facilities Council. -# Original work Copyright (c) 1999-2008 Pearu Peterson. - -# All rights reserved. - -# Modifications made as part of the fparser project are distributed -# under the following license: - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: - -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. - -# 2. 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. - -# 3. 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. - -# -------------------------------------------------------------------- - -# The original software (in the f2py project) was distributed under -# the following license: - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: - -# a. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# b. 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. -# c. Neither the name of the F2PY project 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 REGENTS 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. - -"""Setup script. Used by easy_install and pip. This is now just a stub -which ensures that 'python setup.py' still works. All configuration is done -in setup.cfg.""" - -from setuptools import setup - -setup() diff --git a/src/fparser/__init__.py b/src/fparser/__init__.py index a54a7955..3b223eb1 100644 --- a/src/fparser/__init__.py +++ b/src/fparser/__init__.py @@ -65,28 +65,11 @@ # First version by: Pearu Peterson # First created: Oct 2006 -from importlib.metadata import PackageNotFoundError -from importlib import metadata - import logging import codecs +from importlib.metadata import version - -def _get_version(): - """ - :returns: the version of this package. - :rtype: str - """ - try: - return metadata.version(__name__) - except PackageNotFoundError: - # Package is not installed. - from setuptools_scm import get_version - - return get_version(root="../..", relative_to=__file__) - - -__version__ = _get_version() +__version__ = version("fparser") logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/src/fparser/scripts/fparser2.py b/src/fparser/scripts/fparser2.py index 47f469c1..cffba347 100755 --- a/src/fparser/scripts/fparser2.py +++ b/src/fparser/scripts/fparser2.py @@ -68,15 +68,12 @@ import logging import sys +from optparse import OptionParser +import fparser from fparser.scripts.script_options import set_fparser_options logging.basicConfig() -try: - from iocbio.optparse_gui import OptionParser -except ImportError: - from optparse import OptionParser - def runner(_, options, args): """ @@ -116,7 +113,7 @@ def runner(_, options, args): def main(): """Check arguments before parsing code""" - parser = OptionParser() + parser = OptionParser(version=fparser.__version__) set_fparser_options(parser) options, args = parser.parse_args() runner(parser, options, args) diff --git a/src/fparser/tests/test_fparser_module.py b/src/fparser/tests/test_fparser_module.py index b76206ee..f8ab0ef3 100644 --- a/src/fparser/tests/test_fparser_module.py +++ b/src/fparser/tests/test_fparser_module.py @@ -38,27 +38,6 @@ """ import os -import fparser - - -def test_fparser_get_version(monkeypatch): - """Test the _get_version() utility routine. It doesn't make sense to - actually check precisely which version it reports - just that it returns a - suitable string.""" - ver1 = fparser._get_version() - assert isinstance(ver1, str) - assert "." in ver1 - - def _broken_version(_name): - """Broken routine with which to patch the `version` method.""" - raise fparser.PackageNotFoundError() - - from importlib import metadata - - monkeypatch.setattr(metadata, "version", _broken_version) - ver2 = fparser._get_version() - assert isinstance(ver2, str) - assert "." in ver2 def test_fparser_logging_handler(tmpdir, caplog): diff --git a/src/fparser/tests/test_issue8.py b/src/fparser/tests/test_issue8.py index d2164ba3..c93f78a6 100644 --- a/src/fparser/tests/test_issue8.py +++ b/src/fparser/tests/test_issue8.py @@ -76,7 +76,7 @@ def test_reproduce_issue(): ! 2, 3,.. ! 3, 4,.. ! - & ncore(nclass) ! ncore = \sum_l + & ncore(nclass) ! ncore = \\sum_l ! Number of diffe end """ @@ -93,7 +93,7 @@ def test_reproduce_issue(): ! 2, 3,.. ! 3, 4,.. ! - ! ncore = \sum_l + ! ncore = \\sum_l ! Number of diffe END SUBROUTINE gwinput_v2x """