Skip to content

Commit e2bfda4

Browse files
committed
修复单文件编译时和__init__.py文件冲突的bug
1 parent b71fad4 commit e2bfda4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

AutoCython.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ def remove(path, name):
206206
with open(os.path.join(dirname, setup_file), 'w', encoding='utf-8') as f:
207207
f.write(self._setup_file_str.format(filename))
208208

209+
if not complicating and os.path.isfile(os.path.join(dirname, "__init__.py")):
210+
os.rename(os.path.join(dirname, "__init__.py"), os.path.join(dirname, "___init__.py"))
211+
209212
# Popen('python AutoCython_DataServerClient_Alice.py build_ext --inplace', stdout=PIPE, stderr=PIPE, cwd='build_test/test1\\')
210213
cython_popen = Popen(self._Popen_cmd.format(setup_file), stdout=PIPE, stderr=PIPE, cwd=dirname)
211214

@@ -215,6 +218,8 @@ def remove(path, name):
215218

216219
if wait:
217220
cython_popen.wait()
221+
if not complicating and os.path.isfile(os.path.join(dirname, "___init__.py")):
222+
os.rename(os.path.join(dirname, "___init__.py"), os.path.join(dirname, "__init__.py"))
218223

219224
if not complicating and cython_popen.wait() != 0:
220225
# 错误是输出
@@ -343,7 +348,7 @@ def __init__(self):
343348
self.file_path = ''
344349
self.a_file_flag = False
345350

346-
self.version = 'AutoCython V1.2.5'
351+
self.version = 'AutoCython V1.2.6'
347352
# 像这样写格式好看一点
348353
self.help_info =(
349354
"Usage: AutoCython [options] ...\n"+
@@ -414,4 +419,4 @@ def geto(self) -> (str, list, str, list):
414419
""" CMD """
415420
ac = AutoCython(*AC_getopt_argv().geto())
416421

417-
ac.compile()
422+
ac.compile()

0 commit comments

Comments
 (0)