Skip to content

Commit 50df82a

Browse files
authored
Merge pull request #6521 from janezd/cython-3
Change setup.py to work with Cython 3.0
2 parents 33b082c + c6b6d4e commit 50df82a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
requires = [
33
"setuptools>=41.0.0,<50.0",
44
"wheel",
5-
"cython<3.0",
5+
"cython>=3.0",
66
"oldest-supported-numpy",
77
"sphinx",
88
"recommonmark",

setup.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
have_sphinx = False
3030

3131
try:
32-
from Cython.Distutils.build_ext import new_build_ext as build_ext
32+
from Cython.Build import cythonize
3333
have_cython = True
3434
except ImportError:
3535
have_cython = False
@@ -434,14 +434,7 @@ def ext_modules():
434434
if os.name == 'posix':
435435
libraries.append("m")
436436

437-
return [
438-
# Cython extensions. Will be automatically cythonized.
439-
Extension(
440-
"*",
441-
["Orange/*/*.pyx"],
442-
include_dirs=includes,
443-
libraries=libraries,
444-
),
437+
modules = [
445438
Extension(
446439
"Orange.classification._simple_tree",
447440
sources=[
@@ -464,6 +457,16 @@ def ext_modules():
464457
),
465458
]
466459

460+
if have_cython:
461+
modules += cythonize(Extension(
462+
"*",
463+
["Orange/*/*.pyx"],
464+
include_dirs=includes,
465+
libraries=libraries,
466+
))
467+
468+
return modules
469+
467470

468471
def setup_package():
469472
write_version_py()
@@ -478,17 +481,14 @@ def setup_package():
478481
# numpy.distutils insist all data files are installed in site-packages
479482
'install_data': install_data.install_data
480483
}
481-
if have_numpy and have_cython:
482-
extra_args = {}
483-
cmdclass["build_ext"] = build_ext
484-
else:
484+
if not (have_numpy and have_cython):
485485
# substitute a build_ext command with one that raises an error when
486486
# building. In order to fully support `pip install` we need to
487487
# survive a `./setup egg_info` without numpy so pip can properly
488488
# query our install dependencies
489-
extra_args = {}
490489
cmdclass["build_ext"] = build_ext_error
491490

491+
extra_args = {}
492492
setup(
493493
name=NAME,
494494
version=FULLVERSION,

0 commit comments

Comments
 (0)