fixed import of local packages
This commit is contained in:
+18
-28
@@ -15,34 +15,24 @@ __all__ = ['A', 'B', 'BEAUTIFY', 'BODY', 'BR', 'CAT', 'CENTER', 'CLEANUP', 'CODE
|
|||||||
#: add pydal to sys.modules
|
#: add pydal to sys.modules
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
try:
|
|
||||||
pydalpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "packages", "dal")
|
MESSAGE = ("web2py depends on %s, which apparently you have not installed.\n" +
|
||||||
if pydalpath not in sys.path:
|
"Probably you cloned the repository using git without '--recursive'" +
|
||||||
sys.path.append(pydalpath)
|
"\nTo fix this, please run (from inside your web2py folder):\n\n" +
|
||||||
import pydal
|
" git submodule update --init --recursive\n\n" +
|
||||||
sys.modules['pydal'] = pydal
|
"You can also download a complete copy from http://www.web2py.com.")
|
||||||
except ImportError:
|
|
||||||
raise RuntimeError(
|
def import_packages():
|
||||||
"web2py depends on pydal, which apparently you have not installed.\n" +
|
for package, location in [('pydal', 'dal'), ('yatl', 'yatl')]:
|
||||||
"Probably you cloned the repository using git without '--recursive'" +
|
try:
|
||||||
"\nTo fix this, please run (from inside your web2py folder):\n\n" +
|
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "packages", location)
|
||||||
" git submodule update --init --recursive\n\n" +
|
if path not in sys.path:
|
||||||
"You can also download a complete copy from http://www.web2py.com."
|
sys.path.insert(0, path)
|
||||||
)
|
sys.modules[package] = __import__(package)
|
||||||
try:
|
except ImportError:
|
||||||
yatlpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "packages", "yatl")
|
raise RuntimeError(MESSAGE % package)
|
||||||
if yatlpath not in sys.path:
|
|
||||||
sys.path.append(yatlpath)
|
import_packages()
|
||||||
import yatl
|
|
||||||
sys.modules['yatl'] = yatl
|
|
||||||
except ImportError:
|
|
||||||
raise RuntimeError(
|
|
||||||
"web2py depends on yatl, which apparently you have not installed.\n" +
|
|
||||||
"Probably you cloned the repository using git without '--recursive'" +
|
|
||||||
"\nTo fix this, please run (from inside your web2py folder):\n\n" +
|
|
||||||
" git submodule update --init --recursive\n\n" +
|
|
||||||
"You can also download a complete copy from http://www.web2py.com."
|
|
||||||
)
|
|
||||||
|
|
||||||
from .globals import current
|
from .globals import current
|
||||||
from .html import *
|
from .html import *
|
||||||
|
|||||||
Reference in New Issue
Block a user