提交 13839a98 authored 作者: nouiz's avatar nouiz

Merge pull request #1047 from jlowin/lazylinker_ext-import-fix

lazylinker_ext import fix -- allow CVM on PiCloud servers
...@@ -67,7 +67,8 @@ try: ...@@ -67,7 +67,8 @@ try:
location = os.path.join(config.compiledir, 'cutils_ext') location = os.path.join(config.compiledir, 'cutils_ext')
if not os.path.exists(location): if not os.path.exists(location):
os.mkdir(location) os.mkdir(location)
file(os.path.join(location, "__init__.py"), 'w').close() if not os.path.exists(os.path.join(location, '__init__.py')):
file(os.path.join(location, '__init__.py'), 'w').close()
try: try:
from cutils_ext.cutils_ext import * from cutils_ext.cutils_ext import *
...@@ -80,7 +81,7 @@ try: ...@@ -80,7 +81,7 @@ try:
# compile the cutils_ext module simultaneously. # compile the cutils_ext module simultaneously.
try: try:
try: try:
# We must retry to import it as some other processs could # We must retry to import it as some other process could
# have been compiling it between the first failed import # have been compiling it between the first failed import
# and when we receive the lock # and when we receive the lock
from cutils_ext.cutils_ext import * from cutils_ext.cutils_ext import *
......
...@@ -22,6 +22,19 @@ def try_reload(): ...@@ -22,6 +22,19 @@ def try_reload():
del sys.path[0] del sys.path[0]
try: try:
# See gh issue #728 for why these lines are here. Summary: compiledir must
# be at the beginning of the path to avoid conflicts with any other
# lazylinker_ext modules that might exist (this step handled in try_import
# and try_reload). An __init__.py file must be created for the same reason.
# Note that these lines may seem redundant (they are repeated in
# compile_str()) but if another lazylinker_ext does exist then it will be
# imported and compile_str won't get called at all.
location = os.path.join(config.compiledir, 'lazylinker_ext')
if not os.path.exists(location):
os.mkdir(location)
if not os.path.exists(os.path.join(location, '__init__.py')):
file(os.path.join(location, '__init__.py'), 'w').close()
_need_reload = False _need_reload = False
if force_compile: if force_compile:
raise ImportError() raise ImportError()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论