Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make setup.py work with Cython 3 and Cython 0.29 #729

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import sys, os, os.path, platform, warnings

from distutils import log
from Cython.Build import cythonize
from setuptools import setup, Command, Distribution as _Distribution, Extension as _Extension
from setuptools.command.build_ext import build_ext as _build_ext
from distutils.errors import DistutilsError, CompileError, LinkError, DistutilsPlatformError
Expand Down Expand Up @@ -197,8 +198,6 @@ def get_source_files(self):
self.check_extensions_list(self.extensions)
filenames = []
for ext in self.extensions:
if with_cython:
self.cython_sources(ext.sources, ext)
for filename in ext.sources:
filenames.append(filename)
base = os.path.splitext(filename)[0]
Expand All @@ -225,8 +224,6 @@ def build_extensions(self):
with_ext = self.distribution.ext_status(ext)
if with_ext is not None and not with_ext:
continue
if with_cython:
ext.sources = self.cython_sources(ext.sources, ext)
try:
self.build_extension(ext)
except (CompileError, LinkError):
Expand Down Expand Up @@ -267,7 +264,8 @@ def run(self):


if __name__ == '__main__':

# Cythonize directly to stay compatible with Cython3 (also compatible with Cython 0.29)
cythonize('yaml/_yaml.pyx')
setup(
name=NAME,
version=VERSION,
Expand All @@ -285,7 +283,7 @@ def run(self):
package_dir={'': {2: 'lib', 3: 'lib3'}[sys.version_info[0]]},
packages=['yaml', '_yaml'],
ext_modules=[
Extension('yaml._yaml', ['yaml/_yaml.pyx'],
Extension('yaml._yaml', ['yaml/_yaml.c'],
'libyaml', "LibYAML bindings", LIBYAML_CHECK,
libraries=['yaml']),
],
Expand Down