@@ -180,6 +180,8 @@ else:
180180    check : true 
181181    ).stdout().strip()
182182
183+ cython_program =  find_program (cython.cmd_array()[0 ])
184+ 
183185scikit_learn_cython_args =  [
184186  ' -X language_level=3' ' -X boundscheck=' +  boundscheck, ' -X wraparound=False' 
185187  ' -X initializedcheck=False' ' -X nonecheck=False' ' -X cdivision=True' 
@@ -190,7 +192,25 @@ scikit_learn_cython_args = [
190192]
191193cython_args +=  scikit_learn_cython_args
192194
193- cython_program =  find_program (cython.cmd_array()[0 ])
195+ if  cython.version().version_compare(' >=3.1.0' 
196+   cython_shared_src =  custom_target (
197+     install : false ,
198+     output : ' _cyutility.c' 
199+     command : [
200+       cython_program, ' -3' ' --fast-fail' 
201+       ' --generate-shared=' +  meson .current_build_dir()/ ' _cyutility.c' 
202+     ],
203+   )
204+ 
205+   py.extension_module(' _cyutility' 
206+     cython_shared_src,
207+     subdir : ' sklearn' 
208+     cython_args : cython_args,
209+     install : true ,
210+   )
211+ 
212+   cython_args +=  [' --shared=sklearn._cyutility' 
213+ endif 
194214
195215cython_gen =  generator (cython_program,
196216  arguments  : cython_args +  [' @INPUT@' ' --output-file' ' @OUTPUT@' 
@@ -202,7 +222,6 @@ cython_gen_cpp = generator(cython_program,
202222203223)
204224
205- 
206225# Write file in Meson build dir to be able to figure out from Python code 
207226# whether scikit-learn was built with Meson. Adapted from pandas 
208227# _version_meson.py. 
0 commit comments