44# FOR EXAMPLE IN CASE OF OLDER PYTHON VERSIONS
55
66# Import necessary modules
7- from sys import argv , exit
8- from os import path , walk , getenv
9- from shutil import move
10- from re import search
7+ from sys import argv
118from setuptools import setup
129from Cython .Build import cythonize
1310
1411# Append "build_ext" and "--inplace" to sys.argv to ensure the extension is built in place
1512argv .append ("build_ext" )
1613argv .append ("--inplace" )
1714argv .append ("--compiler=mingw32" )
18- print ("arguments: " , argv )
1915
20- try :
21- ext_modules = cythonize (".\\ src\\ *.pyx" , build_dir = ".\\ build" )
22- print ("Cythonizing files... " , ext_modules )
23- setup (ext_modules = ext_modules )
24- print ("Setup build successful" )
25- except Exception as e :
26- print (f"An error occurred during the Cython build: { e } " )
27- raise
16+ ext_modules = cythonize (".\\ src\\ *.pyx" , build_dir = ".\\ build" )
17+ print ("Cythonizing files... " , ext_modules )
2818
29-
30- def find_name (name_regex : str ) -> str | None :
31- for root , _ , files in walk (
32- "./"
33- ): # Traverse all directories and files starting from the current directory
34- for file in files : # For each file in the directory
35- if search (
36- name_regex , file
37- ): # Check if the file name matches the given regex
38- return path .join (
39- root , file
40- ) # Return the full file path if a match is found
41- return None # Return None if no file matches the regex pattern
42-
43-
44- # Find the compiled Cython file matching the pattern "helpers.c*"
45- file_name = find_name (r".*\.pyd" )
46- if file_name is None :
47- # If no file matching "helpers.c*" is found, print a message and exit the script
48- print ("No file found with extension .pyd" )
49- exit (1 )
50-
51- print (f"Found file: { file_name } " )
52-
53- # Move the matched file to the "src/prec" directory
54- move (path .join (file_name ), path .join (getenv ("CYTHON_OUT" ), path .basename (file_name )))
55- print ("File moved successfully" )
19+ setup (ext_modules = ext_modules )
20+ print ("Setup build successful" )
0 commit comments