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
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import platform
if sys.version_info[0] < 3:
raise Exception("This program requires at least python3.6")
is_windows = platform.system() == 'Windows'
parser = argparse.ArgumentParser(description='compile the .py to .so(Linux/Mac) or .pdy(Win)')
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,
args = parser.parse_args()
def get_export_symbols_fixed(self, ext):
names = ext.name.split('.')
if names[-1] != "__init__":
initfunc_name = "PyInit_" + names[-1]
else:
# take name of the package if it is an __init__-file
initfunc_name = "PyInit_" + names[-2]
if initfunc_name not in ext.export_symbols:
ext.export_symbols.append(initfunc_name)
return ext.export_symbols
def get_exclude_paths(input_path):
exclude_paths = []
if args.exclude is not None and os.path.isdir(input_path):
......@@ -140,6 +154,10 @@ def main():
print('---------- compile start ----------')
success = False
try:
if is_windows:
# replace wrong version with the fixed:
build_ext.get_export_symbols = get_export_symbols_fixed
compiler_directives = {"language_level": '3'}
ext_modules = cythonize(module_list=extensions,
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!