77
88py_file = "source.py"
99
10- if os .path .exists (py_file ):
11- os .remove (py_file )
12-
1310def write_disclaimer (py_file_path ):
1411 disclaimer = "\" \" \" \n "
1512 disclaimer += "Auto-generated file. To edit, run `python build_python.py`.\n "
@@ -29,8 +26,31 @@ def generate_variable(cpp_file_path, variable_name, py_file_path, end_str="\n\n"
2926 with open (py_file_path , "a+" ) as f_py :
3027 f_py .write (py_lines )
3128
32- write_disclaimer (py_file )
33- generate_variable (source_sampling_cpp , "source_sampling_cpp" , py_file )
34- generate_variable (plasma_source_cpp , "plasma_source_cpp" , py_file )
35- generate_variable (plasma_source_hpp , "plasma_source_hpp" , py_file )
36- generate_variable (make_file , "make_file" , py_file , "\n " )
29+ def build (source_dir = "." ):
30+ output_path = os .path .join (source_dir , py_file )
31+
32+ if os .path .exists (output_path ):
33+ os .remove (output_path )
34+
35+ write_disclaimer (output_path )
36+ generate_variable (
37+ os .path .join (source_dir , source_sampling_cpp ),
38+ "source_sampling_cpp" ,
39+ output_path
40+ )
41+ generate_variable (
42+ os .path .join (source_dir , plasma_source_cpp ),
43+ "plasma_source_cpp" ,
44+ output_path
45+ )
46+ generate_variable (
47+ os .path .join (source_dir , plasma_source_hpp ),
48+ "plasma_source_hpp" ,
49+ output_path
50+ )
51+ generate_variable (
52+ os .path .join (source_dir , make_file ),
53+ "make_file" ,
54+ output_path ,
55+ "\n "
56+ )
0 commit comments