From a5e3d15d0d698df00d1dd2489f7a3b976c6fd6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Fri, 27 Dec 2024 09:36:29 +0100 Subject: [PATCH] Break python3.6 compatibility by removing redundant parameters from setup.py Parsing these parameters from pyproject.toml requires setuptools>=61.0 which is only available for python>=3.7. --- .github/build/linux/cpymad.sh | 4 +++- pyproject.toml | 2 +- setup.py | 25 ------------------------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/.github/build/linux/cpymad.sh b/.github/build/linux/cpymad.sh index 610e014b..b826e0e8 100755 --- a/.github/build/linux/cpymad.sh +++ b/.github/build/linux/cpymad.sh @@ -24,7 +24,9 @@ python setup.py sdist for PYBIN in /opt/python/cp3*/bin; do rm -f src/cpymad/libmadx.c - "${PYBIN}/pip" wheel dist/*.tar.gz --no-deps -w rawdist/ + if "${PYBIN}/python" -c "import sys;exit(sys.version_info<(3,7))"; then + "${PYBIN}/pip" wheel dist/*.tar.gz --no-deps -w rawdist/ + fi done # Bundle external shared libraries into the wheels diff --git a/pyproject.toml b/pyproject.toml index 340ef5bc..e7da9ba2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ [build-system] build-backend = "setuptools.build_meta" requires = [ - "setuptools[core]", + "setuptools[core] >= 61.0", "cython>=3.1.0a1 ; python_version >= '3.13'", # Cython3.1 needed for free-threaded python "cython<3 ; python_version < '3.8'", # Cython3.1 dropped support for python<3.8 "cython ; python_version >= '3.8' and python_version < '3.13'", # no particular requirements diff --git a/setup.py b/setup.py index 4802050e..c894beea 100644 --- a/setup.py +++ b/setup.py @@ -90,14 +90,6 @@ def fix_distutils_sysconfig_mingw(): sysconfig._config_vars['CC'] = 'gcc' -def exec_file(path): - """Execute a python file and return the `globals` dictionary.""" - namespace = {} - with open(path, 'rb') as f: - exec(f.read(), namespace, namespace) - return namespace - - def get_extension_args(madxdir, shared, static, **libs): """Get arguments for C-extension (include pathes, libraries, etc).""" # libquadmath isn't available on aarch64, see #101: @@ -132,29 +124,12 @@ def get_extension_args(madxdir, shared, static, **libs): if __name__ == '__main__': - sys.path.append(os.path.dirname(__file__)) fix_distutils_sysconfig_mingw() options, sys.argv[1:] = command_line_options().parse_known_args() - # NOTE: The "metadata" parameters for setup() may appear to be redundant - # but are curently required on setuptools<61.0 and hence for python3.6 - # for which setuptools>=60 is not available. See branch `drop-py36` for - # removal. - metadata = exec_file('src/cpymad/__init__.py') setup( - name='cpymad', - version=metadata['__version__'], - description=metadata['__summary__'], ext_modules=cythonize([ Extension('cpymad.libmadx', sources=["src/cpymad/libmadx.pyx"], **get_extension_args(**options.__dict__)), ]), - packages=['cpymad', 'cpymad.COPYING'], - package_dir={'': 'src'}, - zip_safe=False, # zip is bad for redistributing shared libs - include_package_data=True, # include files matched by MANIFEST.in - install_requires=[ - 'numpy', - 'minrpc>=0.0.8', - ], )