102 me_abs = os.path.dirname(os.path.realpath(__file__))
103 cfp_json_file = me_abs + __cfp_json_path__
104 with open(cfp_json_file,
'r')
as json_file:
105 data = json.load(json_file)
107 root_abs = os.path.realpath(me_abs+
"/../")
108 data[
'abs_path'] = root_abs
112 cfenv_dir = os.path.abspath(root_abs + __cfenv_path_from_root__)
113 if not os.path.isdir(cfenv_dir)
or not os.path.isfile(
"{}/bin/activate".format(cfenv_dir)):
115 os.system(
"rm -rf {}".format(cfenv_dir))
117 print(
"[INFO] the python virutalenv for this project on this machine is missing, installing it...")
118 os.system(
'cd {}; virtualenv -p {} {}'
119 .format(os.path.abspath(cfenv_dir +
'/../'), sys_py_bin, __cfenv_small_name__))
120 os.system(
'/bin/bash -c "source {}/bin/activate; pip install {}"'.format(cfenv_dir, __cfenv_req_packages__))
122 data[
'cfenvPath'] = cfenv_dir
123 data[
'sysPython3Bin'] = sys_py_bin
125 for e
in __mandatory_keys__:
126 if e
not in data.keys():
129 env_file = me_abs + __env_file_name__
132 if os.path.exists(env_file):
133 json_time = os.path.getmtime(cfp_json_file)
134 env_time = os.path.getmtime(env_file)
136 if env_time >= json_time:
140 with open(me_abs +
"/machine_env.template",
"r")
as input, open(env_file,
"w+")
as outfile:
142 for i
in range(0, len(__match_regex__)):
143 out = re.sub(re.escape(__match_regex__[i]), data[__replace_regex__[i]], out)
145 if 'additional_lines' in data.keys():
147 for e
in data[
'additional_lines']:
148 new_line =
str(e) +
'\n'
154 os.system(
"chmod +x {}".format(env_file))
def print_incomplete(msg="")