Skip to content

Commit

Permalink
Merge branch 'migrate-to-pyproject-toml'
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Dec 27, 2024
2 parents 7a88047 + f847402 commit 8a4208f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 78 deletions.
5 changes: 1 addition & 4 deletions .github/build/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ RUN groupadd -o -g $GID runner && \
if [[ $AUDITWHEEL_PLAT == manylinux2014_* ]]; then \
yum install -y glibc-static; \
fi && \
pip install --upgrade cmake cython --only-binary=cmake && \
for PYBIN in /opt/python/cp3*/bin; do \
"${PYBIN}/pip" install -U setuptools; \
done
pip install --upgrade cmake --only-binary=cmake

VOLUME /mnt
WORKDIR /mnt
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recursive-include src/cpymad *.pxd *.pyx *.c
recursive-include src/cpymad *.pxd *.pyx
recursive-include src/cpymad/COPYING *.rst
recursive-include test *.py *.madx
70 changes: 70 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[project]
name = "cpymad"
description = "Cython binding to MAD-X"
dynamic = ["version"]

authors = [
{name = "Thomas Gläßle", email = "t_glaessle@gmx.de"},
{name = "Yngve Inntjore Levinsen"},
{name = "Kajetan Fuchsberger"},
]
maintainers = [
{name = "Thomas Gläßle", email = "t_glaessle@gmx.de"},
{name = "Riccardo De Maria", email = "riccardodemaria@gmail.com"},
]

readme = {file = "README.rst", content-type = "text/x-rst"}
license = {file = "COPYING.rst"}

classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"License :: OSI Approved :: Apache Software License",
"License :: Other/Proprietary License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Physics",
]

urls.Github = "https://github.com/hibtc/cpymad"
urls.Issues = "https://github.com/hibtc/cpymad/issues"
urls.Documentation = "http://hibtc.github.io/cpymad/"
urls.Changelog = "https://github.com/hibtc/cpymad/blob/master/CHANGES.rst"

requires-python = ">=3.5"

dependencies = [
"numpy",
"minrpc>=0.1.0",
]
optional-dependencies.doc = [
"sphinx",
"sphinx_rtd_theme",
"sphinx_substitution_extensions",
"sphinx_automodapi",
"sphinx_autodoc_typehints",
"pandas",
]
optional-dependencies.dev = [
"cython",
"flake8",
"pytest",
]

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >= 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
]

[tool.setuptools]
dynamic.version.attr = "cpymad.__version__"
packages.find = {where = ["src"], include = ["cpymad*"]}
package-data = {"cpymad.COPYING" = ["*.rst"]}
include-package-data = false
51 changes: 0 additions & 51 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
[metadata]
name = cpymad
version = attr: cpymad.__version__
description = Cython binding to MAD-X
url = https://github.com/hibtc/cpymad
long_description = file: README.rst
author = Thomas Gläßle
author_email = t_glaessle@gmx.de
license = GPLv3+
license_files =
COPYING.rst
LICENSE/*
src/cpymad/COPYING/*
project_urls =
Source Code = https://github.com/hibtc/cpymad
Bug Tracker = https://github.com/hibtc/cpymad/issues
Documentation = http://hibtc.github.io/cpymad/
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Science/Research
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
License :: OSI Approved :: Apache Software License
License :: Other/Proprietary License
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3
Topic :: Scientific/Engineering :: Physics
long_description_content_type = text/x-rst

[options]
zip_safe = false
include_package_data = true
python_requires = >=3.5
install_requires =
numpy
minrpc>=0.1.0

[options.extras_require]
doc =
sphinx
sphinx_rtd_theme
sphinx_substitution_extensions
sphinx_automodapi
sphinx_autodoc_typehints
pandas
dev =
cython
flake8
pytest

[flake8]
# codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# default: ignore = E121,E123,E126,E133,E226,E241,E242,E704,W503,W504,W505
Expand Down
23 changes: 1 addition & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# at the commit that first added this paragraph (can be identified using `git
# blame`) and the simplifications that were possible in the following commits.

from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension
from distutils.util import get_platform
from distutils import sysconfig
from argparse import ArgumentParser
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -132,25 +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()
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=find_packages('src', include='cpymad*'),
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',
],
)

0 comments on commit 8a4208f

Please sign in to comment.