blob: 49d3244dcf258a2ad8963aaece4f519acc740109 [file] [log] [blame]
# utility to be shared among all top-level scripts
import os.path
import sys
import platform
pyver = "{0[0]}.{0[1]}".format(sys.version_info)
TOP_DIR = os.path.abspath(os.path.join(
os.path.dirname(__file__), ".."))
BUILD_DIR = os.path.abspath(os.path.join(TOP_DIR, "build"))
code_dir = os.path.abspath(os.path.join(BUILD_DIR, "code"))
if not os.path.exists(code_dir):
code_dir = os.path.join(TOP_DIR, "code")
CODE_DIR = code_dir
lib_dir = os.path.abspath(os.path.join(BUILD_DIR, "lib"))
if not os.path.exists(lib_dir):
lib_dir = os.path.join(TOP_DIR, "lib")
LIB_DIR = lib_dir
DATA_DIR = os.path.abspath(os.path.join(TOP_DIR, "data"))
SCHEMA_DIR = os.path.join(DATA_DIR, "schema")
bin_dir = os.path.join(BUILD_DIR, "bin")
if not os.path.exists(bin_dir):
bin_dir = os.path.join(TOP_DIR, "bin")
BIN_DIR = bin_dir
EXT_DIR = os.path.abspath(os.path.join(CODE_DIR, "common", "external"))
# CODE_PKG_LOC this can be different from CODE_DIR when egg files are used
egg = os.path.join(CODE_DIR, "code-python%s.egg" % pyver)
if os.path.exists(egg):
CODE_PKG_LOC = egg
elif os.path.exists(os.path.join(CODE_DIR, "feic")):
CODE_PKG_LOC = CODE_DIR
else:
raise RuntimeError("Could not find code for the execution: "
"wrong installation?")
def setup_path():
paths = [CODE_PKG_LOC,
os.path.join(CODE_PKG_LOC, "viewers"),
os.path.join(EXT_DIR, "antlr/antlr-python-runtime-3.4"),
os.path.join(EXT_DIR, "pysmt.whl"),
LIB_DIR]
bits = int(platform.architecture()[0][0:-3])
if platform.system() == "Windows" and 64 == bits:
paths.append(os.path.join(EXT_DIR, "win64"))
# for xSAP Boeing package
if os.path.exists(os.path.join(EXT_DIR, "mathsat")):
paths.append(os.path.join(EXT_DIR, "mathsat"))
for _path in paths:
sys.path.append(_path)