|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
string path = Application.dataPath.Replace("/Assets", ""); |
|
|
|
string packagesPath = Application.dataPath.Replace("/Assets","/Library/PythonInstall/Scripts"); |
|
|
|
packagesPath = packagesPath.Replace("/", "\\"); |
|
|
|
pathToData = pathToData.Replace("/", "\\"); |
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
path = path.Replace(" ", "\\ "); |
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
command = $"cd \"{path}\\DataInsightsEnv\\Scripts\\\" && activate && cd \"{pathToData}\\..\" && \"{path}\\DataInsightsEnv\\Scripts\\pyrception-utils.exe\" preview --data=\".\""; |
|
|
|
//command = $"cd \"{path}\\DataInsightsEnv\\Scripts\\\" && activate && cd \"{pathToData}\\..\" && \"{path}\\DataInsightsEnv\\Scripts\\pyrception-utils.exe\" preview --data=\".\"";
|
|
|
|
command = $"cd \"{pathToData}\\..\" && \"{packagesPath}\\pyrception-utils.exe\" preview --data=\".\""; |
|
|
|
command = $"cd \"{path}/DataInsightsEnv/bin\";source activate;cd \"{pathToData}/..\";\"{path}/DataInsightsEnv/bin/pyrception-utils\" preview --data=\".\""; |
|
|
|
//command = $"cd \"{path}/DataInsightsEnv/bin\";source activate;cd \"{pathToData}/..\";\"{path}/DataInsightsEnv/bin/pyrception-utils\" preview --data=\".\"";
|
|
|
|
command = $"cd \"{pathToData}\\..\" && \"{packagesPath}\\pyrception-utils\" preview --data=\".\""; |
|
|
|
#endif
|
|
|
|
int ExitCode = 0; |
|
|
|
ExecuteCMD(command, ref ExitCode, waitForExit: false, displayWindow: true); |
|
|
|
|
|
|
|
|
|
|
//==============================CHECK PIP3 IS INSTALLED======================================
|
|
|
|
int ExitCode = 0; |
|
|
|
ExecuteCMD("pip3", ref ExitCode); |
|
|
|
/*ExecuteCMD("pip3", ref ExitCode); |
|
|
|
UnityEngine.Debug.LogError("Python >= 3 and pip3 must be installed."); |
|
|
|
UnityEngine.Debug.LogError("Python >= 3 and pip3 must be installed and available on PATH."); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
string packagesPath = Application.dataPath.Replace("/Assets","/Library/PythonInstall/Scripts"); |
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
string packagesPath = Application.dataPath.Replace("/Assets","/Library/PythonInstall/bin"); |
|
|
|
#endif
|
|
|
|
packagesPath = packagesPath.Replace("/", "\\"); |
|
|
|
packagesPath = packagesPath.Replace(" ", "\\ "); |
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Installing virtualenv...", 0 / steps); |
|
|
|
//EditorUtility.DisplayProgressBar("Setting up Pyrception", "Installing virtualenv...", 0 / steps);
|
|
|
|
ExecuteCMD($"pip3 install virtualenv", ref ExitCode); |
|
|
|
//ExecuteCMD($"\"{packagesPath}\\pip3.bat\" install virtualenv", ref ExitCode);
|
|
|
|
ExecuteCMD($"pip3 install --target=\"{path}/virtualenvDI\" virtualenv", ref ExitCode); //(maybe add --no-user)
|
|
|
|
//ExecuteCMD($"pip3 install --target=\"{path}/virtualenvDI\" virtualenv", ref ExitCode); //(maybe add --no-user)
|
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
//==============================CREATE VIRTUALENV NAMED DataInsightsEnv======================================
|
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Setting up virtualenv instance...", 1f / steps); |
|
|
|
//EditorUtility.DisplayProgressBar("Setting up Pyrception", "Setting up virtualenv instance...", 1f / steps);
|
|
|
|
ExecuteCMD($"virtualenv -p python3 \"{path}\\DataInsightsEnv\"", ref ExitCode); |
|
|
|
//ExecuteCMD($"\"{packagesPath}\\virtualenv.exe\" -p python3 \"{path}\\DataInsightsEnv\"", ref ExitCode);
|
|
|
|
ExecuteCMD("export PYTHONPATH=\"${PYTHONPATH}:"+$"{path}/virtualenvDI\";"+$"\"{virtualenvPath}/virtualenv\" -p python3 \"{path}/DataInsightsEnv\"", ref ExitCode); |
|
|
|
//ExecuteCMD("export PYTHONPATH=\"${PYTHONPATH}:"+$"{path}/virtualenvDI\";"+$"\"{virtualenvPath}/virtualenv\" -p python3 \"{path}/DataInsightsEnv\"", ref ExitCode);
|
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
//==============================COPY ALL PYRCEPTION FILES FOR INSTALLATION======================================
|
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Getting pyrception files...", 2f / steps); |
|
|
|
EditorUtility.DisplayProgressBar("Setting up Pyrception", "Getting pyrception files...", 1.5f / steps); |
|
|
|
ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{path}\\DataInsightsEnv\\pyrception-util\"", ref ExitCode); |
|
|
|
//ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{path}\\DataInsightsEnv\\pyrception-util\"", ref ExitCode);
|
|
|
|
ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{packagesPath}\\..\\pyrception-util\"", ref ExitCode); |
|
|
|
ExecuteCMD($"\\cp -r \"{pyrceptionPath}\" \"{path}/DataInsightsEnv/pyrception-util\"", ref ExitCode); |
|
|
|
//ExecuteCMD($"\\cp -r \"{pyrceptionPath}\" \"{path}/DataInsightsEnv/pyrception-util\"", ref ExitCode);
|
|
|
|
ExecuteCMD($"\\cp -r \"{pyrceptionPath}\" \"{packagesPath}\\..\\pyrception-util\"", ref ExitCode); |
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
|
|
|
|
//==============================INSTALL PYRCEPTION IN THE VIRTUALENV======================================
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd \"{path}\\DataInsightsEnv\\pyrception-util\" && pip3 --no-cache-dir install -e . && deactivate", ref ExitCode); |
|
|
|
//ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd \"{path}\\DataInsightsEnv\\pyrception-util\" && \"{packagesPath}\"\\pip3 --no-cache-dir install -e . && deactivate", ref ExitCode);
|
|
|
|
ExecuteCMD($"cd \"{packagesPath}\\..\\pyrception-util\" && \"{packagesPath}\"\\pip3.bat install --no-warn-script-location --no-cache-dir -e .", ref ExitCode); |
|
|
|
|
|
|
|
ExecuteCMD($"source \"{path}/DataInsightsEnv/bin/activate\"; cd \"{path}/DataInsightsEnv/pyrception-util\"; pip3 --no-cache-dir install -e .; deactivate", ref ExitCode); |
|
|
|
//ExecuteCMD($"source \"{path}/DataInsightsEnv/bin/activate\"; cd \"{path}/DataInsightsEnv/pyrception-util\"; pip3 --no-cache-dir install -e .; deactivate", ref ExitCode);
|
|
|
|
ExecuteCMD($"cd \"{packagesPath}\\..\\pyrception-util\"; \"{packagesPath}\"\\pip3 --no-warn-script-location --no-cache-dir install -e ., ref ExitCode);
|
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
info.CreateNoWindow = !displayWindow; |
|
|
|
info.UseShellExecute = !waitForExit; |
|
|
|
info.RedirectStandardOutput = redirectOutput && waitForExit; |
|
|
|
info.RedirectStandardError = true && waitForExit; |
|
|
|
info.RedirectStandardError = waitForExit; |
|
|
|
|
|
|
|
Process cmd = Process.Start(info); |
|
|
|
|
|
|
|
|
|
|
ExitCode = cmd.ExitCode; |
|
|
|
if (ExitCode != 0) |
|
|
|
{ |
|
|
|
UnityEngine.Debug.LogError($"Error - {ExitCode} - Failed to execute: {command} - {cmd.StandardError.ReadToEnd()}"); |
|
|
|
UnityEngine.Debug.LogError($"Error - {ExitCode} - Failed to execute: {command} - {/*cmd.StandardError.ReadToEnd()*/output}"); |
|
|
|
} |
|
|
|
|
|
|
|
cmd.Close(); |
|
|
|