diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dba0e19..76a740a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 with: diff --git a/pyproject.toml b/pyproject.toml index 269f339..3660e81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=64", "Cython", "oldest-supported-numpy", 'setuptools_scm[toml]>=8'] +requires = ["setuptools>=64", "Cython", "numpy>=1.25", 'setuptools_scm[toml]>=8'] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 2bb8b30..bd67cc0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,11 +24,10 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Programming Language :: Python :: 3 :: Only Topic :: Scientific/Engineering :: Astronomy Topic :: Scientific/Engineering :: Physics diff --git a/setup.py b/setup.py index 7cbd324..281c623 100644 --- a/setup.py +++ b/setup.py @@ -1,63 +1,43 @@ -from setuptools import setup +from setuptools import setup, Extension import os +from Cython.Build import cythonize +import numpy as np + + +kwargs = dict( + include_dirs=[np.get_include()], + define_macros=[ + # fixes a warning when compiling + ("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"), + # defines the oldest numpy we want to be compatible with + ("NPY_TARGET_VERSION", "NPY_1_21_API_VERSION"), + ] +) -# make sure users without cython can install our extensions -try: - from Cython.Distutils.extension import Extension - from Cython.Distutils import build_ext as _build_ext - USE_CYTHON = True -except ImportError: - from setuptools import Extension - from setuptools.command.build_ext import build_ext as _build_ext - USE_CYTHON = False - -print('using cython', USE_CYTHON) - - -# make sure numpy is installed before we try to build -# the extenion -class build_ext(_build_ext): - def finalize_options(self): - super().finalize_options() - import numpy - self.include_dirs.append(numpy.get_include()) - - -# if we have cython, use the cython file if not the c file -ext = '.pyx' if USE_CYTHON else '.c' extensions = [ - Extension('eventio.header', sources=['src/eventio/header' + ext]), - Extension('eventio.var_int', sources=['src/eventio/var_int' + ext]), + Extension( + 'eventio.header', + sources=['src/eventio/header.pyx'], + **kwargs, + ), + Extension( + 'eventio.var_int', + sources=['src/eventio/var_int.pyx'], + **kwargs, + ), Extension( 'eventio.simtel.parsing', - sources=['src/eventio/simtel/parsing' + ext] + sources=['src/eventio/simtel/parsing.pyx'], + **kwargs, ), ] -cmdclass = {'build_ext': build_ext} - -# give a nice error message if people cloned the -# repository and do not have cython installed -if ext == '.c': - sources = [] - for ext in extensions: - sources.extend(ext.sources) - if not all(os.path.isfile(s) for s in sources): - raise ImportError('You need `Cython` to build this project locally') - setup( use_scm_version={"write_to": os.path.join("src", "eventio", "_version.py")}, - - ext_modules=extensions, - cmdclass=cmdclass, - - package_data={ - 'eventio': ['*.c'], - 'eventio.simtel': ['*.c'], - }, - python_requires='>=3.8', + ext_modules=cythonize(extensions), + python_requires='>=3.9', install_requires=[ - 'numpy', + 'numpy >= 1.21', 'corsikaio ~= 0.3.3', 'zstandard > 0.11.1', # memory leak in zstandard 0.11.1 'setuptools_scm',