Skip to content

Commit

Permalink
Cython: check for files
Browse files Browse the repository at this point in the history
Pushing in new branch to get it up to GH so I can pull it down to a
machine which has an old version of Cython
  • Loading branch information
amcn committed Feb 20, 2024
1 parent 28f23e3 commit 44f81d2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions mesonbuild/modules/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,24 @@ def extension_module_method(self, args: T.Tuple[str, T.List[BuildTargetSource]],
kwargs['link_args'] = new_link_args

cython_compiler = next((c for c in compilers.values() if c.get_id() == 'cython'), None)
if cython_compiler is not None and mesonlib.version_compare(cython_compiler.version, '< 3.0.0'):
mlog.warning(f'Limited API not supported by Cython versions < 3.0.0 (detected: {cython_compiler.version})', location=self.current_node)
if cython_compiler is not None:
# Determine if any of the supplied source files are Cython source.
def has_cython_files(cython_compiler, args):
cython_suffixes = cython_compiler.file_suffixes
for arg in args:
if isinstance(arg, mesonlib.File):
arg = arg.fname
suffix = os.path.splitext(arg)[1][1:].lower()
if suffix in cython_suffixes:
return True
return False

# Cython's support for the Limited API was added in version 3.0
def has_cython_limited_api(cython_compiler):
return mesonlib.version_compare(cython_compiler.version, '>= 3.0.0')

if has_cython_files(cython_compiler, args[1]) and not has_cython_limited_api(cython_compiler):
mlog.error(f'Limited API not supported by Cython versions < 3.0.0 (detected: {cython_compiler.version})', location=self.current_node)

kwargs['dependencies'] = new_deps

Expand Down

0 comments on commit 44f81d2

Please sign in to comment.