From 483dc6e8d90d46713dfdcfebe8e26ca3e0759372 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Mon, 19 May 2025 18:39:01 -0400 Subject: [PATCH] Add cythonize annotations to improve DX This doesn't change the build output, and allows developers to read HTML "annotations" (reports, generated by cythonize) which show how cython code is being compiled. --- setup.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 804b649..2054fb1 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -from setuptools import setup, Extension +from Cython.Build import cythonize +from setuptools import Extension, setup extra_compile_args = [ "-std=c++11", @@ -11,15 +12,21 @@ "-fomit-frame-pointer", ] +extensions = [ + Extension( + "pyjson5.pyjson5", + sources=["pyjson5.pyx"], + include_dirs=["src"], + extra_compile_args=extra_compile_args, + extra_link_args=extra_compile_args, + language="c++", + ), +] + setup( - ext_modules=[ - Extension( - "pyjson5.pyjson5", - sources=["pyjson5.pyx"], - include_dirs=["src"], - extra_compile_args=extra_compile_args, - extra_link_args=extra_compile_args, - language="c++", - ) - ], + ext_modules=cythonize( + extensions, + compiler_directives={"language_level": 3}, + annotate=True, + ), )