-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_cython.py
47 lines (38 loc) · 1.38 KB
/
build_cython.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Filename: compile_cython.py
Author(s): Peter Quigley
Contact: [email protected]
Created: Fri Oct 21 09:23:04 2022
Updated: Fri Oct 21 09:23:04 2022
Usage: python compile_cython.py
Run this file to compile the cython modules in the working directory.
"""
import os,sys
import platform
##############################
## Compile Cython Modules
##############################
print("Compiling cython files...\n")
for file in os.listdir("."):
# Detect cython files and compile
if file.endswith(".pyx"):
print(f"Compiling {file}")
if os.path.exists(f"setup_{file[:-4]}.py"):
os.system(f"python setup_{file[:-4]}.py build_ext --inplace")
else:
print(f"No setup file exists for {file}!\n")
continue
# Detect platform and clean up compilation
if platform.system() == "Windows":
os.system(f"rd /s /q build/")
os.system(f"del {file[:-4]}.html")
os.system(f"del {file[:-4]}.c")
os.system(f"del {file[:-4]}.pyd")
os.system(f"RENAME {file[:-4]}.*.pyd {file[:-4]}.pyd")
elif platform.system() == "Linux":
os.system(f"rm -r build/")
os.system(f"rm {file[:-4]}.html")
os.system(f"rm {file[:-4]}.c")
os.system(f"rm {file[:-4]}.so")
os.system(f"mv {file[:-4]}.*.so {file[:-4]}.so")
print("\n")