Improved 'cleanall' option to remove Cython files.

这个提交包含在:
Craig Warren
2015-11-04 10:16:00 +00:00
父节点 c57c292926
当前提交 9278f6487c

查看文件

@@ -64,22 +64,28 @@ for root, dirs, files in os.walk(os.path.join(os.getcwd(), 'user_libs')):
if 'cleanall' in sys.argv:
USE_CYTHON = False
print('Deleting Cython files...')
for file in cythonfiles:
tmp = os.path.splitext(file)
cfile = tmp[0] + '.c'
if sys.platform == 'win32':
libfile = tmp[0] + '.pyd'
else:
libfile = tmp[0] + '.so'
try:
os.remove(cfile)
except OSError:
print('Could not remove: {}'.format(cfile))
try:
os.remove(libfile)
except OSError:
print('Could not remove: {}'.format(libfile))
shutil.rmtree('build', ignore_errors=True)
for entry in os.scandir(os.path.join(os.getcwd(), packagename)):
for file in cythonfiles:
tmp = os.path.splitext(file)
if entry.name.startswith(tmp[0]):
# Remove Cython C files
try:
os.remove(tmp[0] + '.c')
except OSError:
print('Could not remove: {}'.format(tmp[0] + '.c'))
# Remove compiled Cython modules
libfilename = entry.name.split('.')[0]
if sys.platform == 'win32':
libfile = libfilename + '.pyd'
else:
libfile = libfilename + '.so'
try:
os.remove(libfile)
except OSError:
print('Could not remove: {}'.format(libfile))
# Remove build directory
shutil.rmtree(os.path.join(os.getcwd(), 'build'), ignore_errors=True)
# Now do a normal clean
sys.argv[1] = 'clean' # this is what distutils understands