diff --git a/pyproject.toml b/pyproject.toml index 05298983..764163dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,7 @@ readme = "README.md" authors = [ { name="Jeff Whitaker", email="whitaker.jeffrey@gmail.com"} ] -license = "MIT" -license-files = ["LICENSE"] +license = {text = "MIT"} classifiers = [ 'Development Status :: 5 - Production/Stable', 'Operating System :: MacOS :: MacOS X', @@ -32,7 +31,7 @@ dev = [ "check-manifest", "coverage>=7.10.0", "coveralls", - "cython>=0.29.20", + "cython>=3", "pytest", "sphinx", "twine", @@ -41,7 +40,7 @@ dev = [ [build-system] requires = [ "setuptools>=77.0.1", - "cython>=0.29.20", + "cython>=3", "numpy>=2.0.0,<3", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index eed7048f..0de71040 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ import sys import numpy -from Cython.Build import cythonize from setuptools import Command, Extension, setup @@ -28,6 +27,7 @@ NAME = 'cftime' CFTIME_DIR = os.path.join(SRCDIR, NAME) CYTHON_FNAME = os.path.join(CFTIME_DIR, '_{}.pyx'.format(NAME)) +CYTHON_CNAME = os.path.join(CFTIME_DIR, '_{}.c'.format(NAME)) class CleanCython(Command): @@ -53,8 +53,7 @@ def run(self): print('clean: skipping file {!r}'.format(artifact)) -if ((FLAG_COVERAGE in sys.argv or os.environ.get('CYTHON_COVERAGE', None)) - and cythonize): +if FLAG_COVERAGE in sys.argv or os.environ.get('CYTHON_COVERAGE', None): COMPILER_DIRECTIVES = { **COMPILER_DIRECTIVES, **COVERAGE_COMPILER_DIRECTIVES } @@ -68,16 +67,15 @@ def run(self): if any([arg in CMDS_NOCYTHONIZE for arg in sys.argv]): ext_modules = [] else: - extension = Extension('{}._{}'.format(NAME, NAME), - sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)], - define_macros=DEFINE_MACROS, - include_dirs=[numpy.get_include(),]) - - ext_modules = cythonize( - extension, - compiler_directives=COMPILER_DIRECTIVES, - language_level=3, - ) + ext_modules = [Extension('{}._{}'.format(NAME, NAME), + sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)], + define_macros=DEFINE_MACROS, + include_dirs=[numpy.get_include(),])] + for e in ext_modules: + e.cython_directives = {**{'language_level': "3"} , **COMPILER_DIRECTIVES} + # remove _cftime.c file if it exists, so cython will recompile _cftime.pyx. + if os.path.exists(CYTHON_CNAME): + os.remove(CYTHON_CNAME) setup( cmdclass={'clean_cython': CleanCython},