Render tempita templates before calling cythonize. This is skipped for * clean * sdist
(extensions, *args, **kwargs)
| 392 | # TODO(cython#4518): Need to check to see if e.g. `linetrace` has changed and |
| 393 | # possibly re-compile. |
| 394 | def maybe_cythonize(extensions, *args, **kwargs): |
| 395 | """ |
| 396 | Render tempita templates before calling cythonize. This is skipped for |
| 397 | |
| 398 | * clean |
| 399 | * sdist |
| 400 | """ |
| 401 | if "clean" in sys.argv or "sdist" in sys.argv: |
| 402 | # See https://github.com/cython/cython/issues/1495 |
| 403 | return extensions |
| 404 | |
| 405 | elif not _CYTHON_INSTALLED: |
| 406 | # GH#28836 raise a helpful error message |
| 407 | if _CYTHON_VERSION: |
| 408 | raise RuntimeError( |
| 409 | f"Cannot cythonize with old Cython version ({_CYTHON_VERSION} " |
| 410 | f"installed, needs {min_cython_ver})" |
| 411 | ) |
| 412 | raise RuntimeError("Cannot cythonize without Cython installed.") |
| 413 | |
| 414 | # reuse any parallel arguments provided for compilation to cythonize |
| 415 | parser = argparse.ArgumentParser() |
| 416 | parser.add_argument("--parallel", "-j", type=int, default=1) |
| 417 | parsed, _ = parser.parse_known_args() |
| 418 | |
| 419 | kwargs["nthreads"] = parsed.parallel |
| 420 | build_ext.render_templates(_pxifiles) |
| 421 | if debugging_symbols_requested: |
| 422 | kwargs["gdb_debug"] = True |
| 423 | |
| 424 | return cythonize(extensions, *args, **kwargs) |
| 425 | |
| 426 | |
| 427 | def srcpath(name=None, suffix=".pyx", subdir="src"): |
no test coverage detected