a75f6d66 by 周伟奇

fix windows error

1 parent 97b2d3ed
Showing 1 changed file with 18 additions and 0 deletions
...@@ -7,11 +7,13 @@ from distutils.core import setup ...@@ -7,11 +7,13 @@ from distutils.core import setup
7 from distutils.extension import Extension 7 from distutils.extension import Extension
8 from Cython.Build import cythonize 8 from Cython.Build import cythonize
9 from Cython.Distutils import build_ext 9 from Cython.Distutils import build_ext
10 import platform
10 11
11 12
12 if sys.version_info[0] < 3: 13 if sys.version_info[0] < 3:
13 raise Exception("This program requires at least python3.6") 14 raise Exception("This program requires at least python3.6")
14 15
16 is_windows = platform.system() == 'Windows'
15 17
16 parser = argparse.ArgumentParser(description='compile the .py to .so(Linux/Mac) or .pdy(Win)') 18 parser = argparse.ArgumentParser(description='compile the .py to .so(Linux/Mac) or .pdy(Win)')
17 parser.add_argument('-i', '--input', help='the directory(file) path of your project', required=True) 19 parser.add_argument('-i', '--input', help='the directory(file) path of your project', required=True)
...@@ -20,6 +22,18 @@ parser.add_argument('-e', '--exclude', help='exclude file. eg: ignore/ignore.py, ...@@ -20,6 +22,18 @@ parser.add_argument('-e', '--exclude', help='exclude file. eg: ignore/ignore.py,
20 args = parser.parse_args() 22 args = parser.parse_args()
21 23
22 24
25 def get_export_symbols_fixed(self, ext):
26 names = ext.name.split('.')
27 if names[-1] != "__init__":
28 initfunc_name = "PyInit_" + names[-1]
29 else:
30 # take name of the package if it is an __init__-file
31 initfunc_name = "PyInit_" + names[-2]
32 if initfunc_name not in ext.export_symbols:
33 ext.export_symbols.append(initfunc_name)
34 return ext.export_symbols
35
36
23 def get_exclude_paths(input_path): 37 def get_exclude_paths(input_path):
24 exclude_paths = [] 38 exclude_paths = []
25 if args.exclude is not None and os.path.isdir(input_path): 39 if args.exclude is not None and os.path.isdir(input_path):
...@@ -140,6 +154,10 @@ def main(): ...@@ -140,6 +154,10 @@ def main():
140 print('---------- compile start ----------') 154 print('---------- compile start ----------')
141 success = False 155 success = False
142 try: 156 try:
157 if is_windows:
158 # replace wrong version with the fixed:
159 build_ext.get_export_symbols = get_export_symbols_fixed
160
143 compiler_directives = {"language_level": '3'} 161 compiler_directives = {"language_level": '3'}
144 ext_modules = cythonize(module_list=extensions, 162 ext_modules = cythonize(module_list=extensions,
145 compiler_directives=compiler_directives) 163 compiler_directives=compiler_directives)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!