From aec5291b31912744dde3a271c89469e979e97439 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 26 May 2026 11:34:18 +0100 Subject: [PATCH 1/8] Delete setuptools_scm_git_archive dependency and add version command option --- pyproject.toml | 5 +-- setup.py | 74 --------------------------------- src/fparser/scripts/fparser2.py | 9 ++-- 3 files changed, 5 insertions(+), 83 deletions(-) delete mode 100755 setup.py diff --git a/pyproject.toml b/pyproject.toml index ad1dff099..145134fbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,6 @@ requires = [ "setuptools >= 61", "setuptools_scm[toml] >= 6.2", - "setuptools_scm_git_archive", "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 3bfb8319c..000000000 --- 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/scripts/fparser2.py b/src/fparser/scripts/fparser2.py index 47f469c1e..cffba3479 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) From 4e4ea9dcbb078aa6aef9e271de72930e7e3737a1 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 26 May 2026 13:09:05 +0100 Subject: [PATCH 2/8] Remove runtime use of setuptools_scm and syntaxwarning --- doc/source/conf.py | 9 ++++++--- src/fparser/__init__.py | 21 ++------------------- src/fparser/tests/test_fparser_module.py | 21 --------------------- src/fparser/tests/test_issue8.py | 4 ++-- 4 files changed, 10 insertions(+), 45 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 04b361112..29d770f60 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -10,10 +10,13 @@ project = 'fparser' copyright = '2017-2024, Science and Technology Facilities Council' -author = 'Andrew Porter, Rupert Ford, Balthasar Reuter, Joerg Henrichs and Pearu Peterson' +author = ( + 'Andrew Porter, Rupert Ford, Balthasar Reuter, Joerg Henrichs, ' + 'Sergi Siso and Pearu Peterson' +) -version = fparser._get_version() -release = fparser._get_version() +version = fparser.__version__ +release = fparser.__version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/src/fparser/__init__.py b/src/fparser/__init__.py index a54a79553..73c556c9a 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 +import fparser._version as v - -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__ = v.version logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/src/fparser/tests/test_fparser_module.py b/src/fparser/tests/test_fparser_module.py index b76206ee6..f8ab0ef3d 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 d2164ba31..c93f78a60 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 """ From 140bb6ceed881888947a8b2790d6ccf878a4c2eb Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 2 Jun 2026 05:56:27 +0100 Subject: [PATCH 3/8] Update pyproject dependencies --- .gitignore | 1 + pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 54ab513d9..efe9a421b 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/pyproject.toml b/pyproject.toml index 145134fbe..504d9f59c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ - "setuptools >= 61", - "setuptools_scm[toml] >= 6.2", + "setuptools >= 80", + "setuptools_scm[toml] >= 8", "wheel >= 0.29.0", ] build-backend = "setuptools.build_meta" From f11bbffb16932530012a34c84ab68a948b6590b2 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 2 Jun 2026 08:56:00 +0100 Subject: [PATCH 4/8] Upde importlib.metadata to retrieve version --- src/fparser/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fparser/__init__.py b/src/fparser/__init__.py index 73c556c9a..3b223eb16 100644 --- a/src/fparser/__init__.py +++ b/src/fparser/__init__.py @@ -67,9 +67,9 @@ import logging import codecs -import fparser._version as v +from importlib.metadata import version -__version__ = v.version +__version__ = version("fparser") logging.getLogger(__name__).addHandler(logging.NullHandler()) From f0a648ea25eb31124227edd48e465636f2e532ff Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 2 Jun 2026 13:09:17 +0100 Subject: [PATCH 5/8] Update Sphinx files --- doc/doxygen.config | 2 +- doc/source/conf.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/doxygen.config b/doc/doxygen.config index 895787e10..6ece9a6c2 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 29d770f60..21d0fb357 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -9,15 +9,12 @@ import fparser project = 'fparser' -copyright = '2017-2024, Science and Technology Facilities Council' +copyright = '2017-2026, Science and Technology Facilities Council' author = ( 'Andrew Porter, Rupert Ford, Balthasar Reuter, Joerg Henrichs, ' 'Sergi Siso and Pearu Peterson' ) -version = fparser.__version__ -release = fparser.__version__ - # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration From 8b864a98ade66bcce5e6d1cfc4938c0e38cc0956 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 2 Jun 2026 13:12:40 +0100 Subject: [PATCH 6/8] Update copyright dates --- doc/source/developers_guide.rst | 2 +- doc/source/fparser.rst | 2 +- doc/source/fparser2.rst | 2 +- doc/source/index.rst | 2 +- doc/source/introduction.rst | 2 +- doc/source/license.rst | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/source/developers_guide.rst b/doc/source/developers_guide.rst index 1244b6ff7..63d7f5583 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 64ebefbd2..ca83bcb69 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 a7571db74..081438d22 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 231e57bc6..ddd2e30f6 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 3986f1941..306818c23 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 db825cd50..6b16db197 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 From 196f0719df6141c261463b035106ccfc6bb60431 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 4 Jun 2026 18:12:45 +0100 Subject: [PATCH 7/8] #506 rm import of fparser from conf.py --- doc/source/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 21d0fb357..53dc7d569 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -6,7 +6,6 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information import subprocess -import fparser project = 'fparser' copyright = '2017-2026, Science and Technology Facilities Council' From 89d67100de807deb202a8abeb8bdf3c2d39983a2 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 4 Jun 2026 18:15:50 +0100 Subject: [PATCH 8/8] #506 update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3b6f98e..f2f6f742b 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.