From aec5291b31912744dde3a271c89469e979e97439 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 26 May 2026 11:34:18 +0100 Subject: [PATCH 1/2] 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/2] 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 """