+
+ if "python_version" in _config:
+ versionPython_split = _config["python_version"].split('.')
+ versionPython = versionPython_split[0] + "." + versionPython_split[1]
+ else:
+ cmd='source %s && python3 -c "import sys ; sys.stdout.write(\\"{}.{}\\".format(sys.version_info.major,sys.version_info.minor))"' %(_config["prereq_path"])
+ versionPython=subprocess.check_output(['/bin/bash', '-l' ,'-c',cmd]).decode("utf-8")
+
+ venv_directory_path = None
+ if "venv_directory_path" in _config:
+ venv_directory_path = _config["venv_directory_path"]
+ venv_bin_directory_path = os.path.join(venv_directory_path, 'bin')
+ venv_pip_executable = os.path.join(venv_bin_directory_path, 'pip')
+ venv_python_executable = os.path.join(venv_bin_directory_path, 'python')
+ if os.path.isdir(venv_directory_path) and os.path.isfile(venv_pip_executable):
+ requirement_file = os.path.join(home_dir, 'requirements.txt')
+ with open(requirement_file, 'w') as fd:
+ subprocess.call([venv_python_executable, '-m', 'pip', 'freeze'], stdout=fd)
+ else:
+ venv_directory_path = None
+
+ with open(os.path.join(home_dir, 'env.d', 'configSalome.sh'),'w') as f:
+ for module in _config.get("modules", []):
+ command = 'export '+ module + '_ROOT_DIR=${HOME}/${APPLI}\n'
+ f.write(command)
+ pass
+ if "samples_path" in _config:
+ command = 'export DATA_DIR=' + _config["samples_path"] +'\n'
+ f.write(command)
+ pass
+ if "resources_path" in _config and os.path.isfile(_config["resources_path"]):
+ command = 'export USER_CATALOG_RESOURCES_FILE=' + os.path.abspath(_config["resources_path"]) +'\n'
+ f.write(command)
+ # Note: below, PYTHONPATH should not be extended to bin/salome! Python modules must be installed in lib/pythonX.Y, to be fixed (e.g. Kernel SALOME_Container.py)
+ command ="""export PATH=${HOME}/${APPLI}/bin/salome:$PATH
+export PYTHONPATH=${HOME}/${APPLI}/lib/python%s/site-packages/salome:$PYTHONPATH
+export PYTHONPATH=${HOME}/${APPLI}/lib/salome:$PYTHONPATH
+export PYTHONPATH=${HOME}/${APPLI}/bin/salome:$PYTHONPATH
+export LD_LIBRARY_PATH=${HOME}/${APPLI}/lib/salome:$LD_LIBRARY_PATH
+""" %versionPython