Skip to content

Commit a62b2be

Browse files
committed
fixup! fixup! exp: tentative fixup
1 parent 14f00b4 commit a62b2be

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

setup.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,26 @@ def run(self):
7070
print('clean: skipping file {!r}'.format(artifact))
7171

7272
class BuildExt(build_ext):
73-
def finalize_options(self) -> None:
74-
super().finalize_options()
75-
for ext in self.extensions:
76-
ext.py_limited_api = USE_PY_LIMITED_API
73+
def run(self):
74+
if not any([arg in CMDS_NOCYTHONIZE for arg in sys.argv]):
75+
# See https://github.com/Unidata/cftime/issues/91
76+
self.extensions = self.distribution.ext_modules = []
77+
return
78+
79+
self.extensions = self.distribution.ext_modules = cythonize(
80+
Extension(
81+
f'{NAME}._{NAME}',
82+
sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)],
83+
define_macros=DEFINE_MACROS,
84+
include_dirs=[numpy.get_include()],
85+
py_limited_api=USE_PY_LIMITED_API
86+
),
87+
compiler_directives=COMPILER_DIRECTIVES,
88+
language_level=3,
89+
)
90+
91+
self.finalize_options()
92+
super().run()
7793

7894

7995
if ((FLAG_COVERAGE in sys.argv or os.environ.get('CYTHON_COVERAGE', None))
@@ -89,24 +105,9 @@ def finalize_options(self) -> None:
89105
sys.argv.remove(FLAG_COVERAGE)
90106
print('enable: "linetrace" Cython compiler directive')
91107

92-
# See https://github.com/Unidata/cftime/issues/91
93-
if any([arg in CMDS_NOCYTHONIZE for arg in sys.argv]):
94-
ext_modules = []
95-
else:
96-
extension = Extension('{}._{}'.format(NAME, NAME),
97-
sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)],
98-
define_macros=DEFINE_MACROS,
99-
include_dirs=[numpy.get_include()],
100-
py_limited_api=USE_PY_LIMITED_API)
101-
102-
ext_modules = cythonize(
103-
extension,
104-
compiler_directives=COMPILER_DIRECTIVES,
105-
language_level=3,
106-
)
107108

108109
setup(
109110
cmdclass={'clean_cython': CleanCython, 'build_ext': BuildExt},
110-
ext_modules=ext_modules,
111+
ext_modules = [Extension('cftime.x', ['x.c'])], # To trick build into running build_ext
111112
options=SETUP_OPTIONS,
112113
)

0 commit comments

Comments
 (0)