提交 27f62bf3 authored 作者: Frederic's avatar Frederic

When loading cutils_ext module, put the path at the start of sys.path to prevent conflict.

close gh-728
上级 1ada610b
......@@ -56,32 +56,33 @@ def compile_cutils():
cmodule.GCC_compiler.compile_str('cutils_ext', code, location=loc,
preargs=args)
try:
# If we load a previously-compiled version, config.compiledir should
# be in sys.path.
if config.compiledir not in sys.path:
try:
# Must be at the beginning to ensure no conflict with other project
# that would use the same module name.
sys.path.insert(0, config.compiledir)
from cutils_ext.cutils_ext import *
except ImportError:
import cmodule
from cutils_ext.cutils_ext import *
except ImportError:
import cmodule
get_lock()
# Ensure no-one else is currently modifying the content of the compilation
# directory. This is important to prevent multiple processes from trying to
# compile the cutils_ext module simultaneously.
try:
get_lock()
# Ensure no-one else is currently modifying the content of the compilation
# directory. This is important to prevent multiple processes from trying to
# compile the cutils_ext module simultaneously.
try:
# We must retry to import it as some other processs could
# have been compiling it between the first failed import
# and when we receive the lock
from cutils_ext.cutils_ext import *
except ImportError:
import cmodule
try:
# We must retry to import it as some other processs could
# have been compiling it between the first failed import
# and when we receive the lock
from cutils_ext.cutils_ext import *
except ImportError:
import cmodule
compile_cutils()
from cutils_ext.cutils_ext import *
compile_cutils()
from cutils_ext.cutils_ext import *
finally:
# Release lock on compilation directory.
release_lock()
finally:
# Release lock on compilation directory.
release_lock()
finally:
del sys.path[0]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论