Skip to content

Commit

Permalink
Merge pull request #6521 from janezd/cython-3
Browse files Browse the repository at this point in the history
Change setup.py to work with Cython 3.0
  • Loading branch information
markotoplak committed Jul 24, 2023
2 parents 33b082c + c6b6d4e commit 50df82a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires = [
"setuptools>=41.0.0,<50.0",
"wheel",
"cython<3.0",
"cython>=3.0",
"oldest-supported-numpy",
"sphinx",
"recommonmark",
Expand Down
28 changes: 14 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
have_sphinx = False

try:
from Cython.Distutils.build_ext import new_build_ext as build_ext
from Cython.Build import cythonize
have_cython = True
except ImportError:
have_cython = False
Expand Down Expand Up @@ -434,14 +434,7 @@ def ext_modules():
if os.name == 'posix':
libraries.append("m")

return [
# Cython extensions. Will be automatically cythonized.
Extension(
"*",
["Orange/*/*.pyx"],
include_dirs=includes,
libraries=libraries,
),
modules = [
Extension(
"Orange.classification._simple_tree",
sources=[
Expand All @@ -464,6 +457,16 @@ def ext_modules():
),
]

if have_cython:
modules += cythonize(Extension(
"*",
["Orange/*/*.pyx"],
include_dirs=includes,
libraries=libraries,
))

return modules


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

extra_args = {}
setup(
name=NAME,
version=FULLVERSION,
Expand Down

0 comments on commit 50df82a

Please sign in to comment.