|
|
|
|
|
|
[MenuItem("Window/Pyrception/Run")] |
|
|
|
static void RunPyrception() |
|
|
|
{ |
|
|
|
/*if(currentProcess != null) |
|
|
|
{ |
|
|
|
currentProcess.Kill(); |
|
|
|
currentProcess = null; |
|
|
|
UnityEngine.Debug.Log("Current Process was set to null"); |
|
|
|
}*/ |
|
|
|
|
|
|
|
string path = Path.GetFullPath(Application.dataPath.Replace("/Assets", "")); |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
|
|
|
path = path.Replace("/", "\\"); |
|
|
|
packagesPath = packagesPath.Replace("/", "\\"); |
|
|
|
pathToData = pathToData.Replace("/", "\\"); |
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
//path = path.Replace(" ", "\\ ");
|
|
|
|
//packagesPath = packagesPath.Replace(" ", "\\ ");
|
|
|
|
//pathToData = pathToData.Replace(" ", "\\ ");
|
|
|
|
//command = $"cd \"{path}\\DataInsightsEnv\\Scripts\\\" && activate && cd \"{pathToData}\\..\" && \"{path}\\DataInsightsEnv\\Scripts\\pyrception-utils.exe\" preview --data=\".\"";
|
|
|
|
//command = $"cd \"{path}/DataInsightsEnv/bin\";source activate;cd \"{pathToData}/..\";\"{path}/DataInsightsEnv/bin/pyrception-utils\" preview --data=\".\"";
|
|
|
|
ExecuteCMD(command, ref ExitCode, waitForExit: true, displayWindow: true); |
|
|
|
ExecuteCMD(command, ref ExitCode, waitForExit: false, displayWindow: true); |
|
|
|
if (ExitCode != 0) |
|
|
|
return; |
|
|
|
else |
|
|
|
|
|
|
static void SetupPyrception() |
|
|
|
{ |
|
|
|
int steps = 3; |
|
|
|
|
|
|
|
//==============================CHECK PIP3 IS INSTALLED======================================
|
|
|
|
/*ExecuteCMD("pip3", ref ExitCode); |
|
|
|
if(ExitCode != 0) |
|
|
|
{ |
|
|
|
UnityEngine.Debug.LogError("Python >= 3 and pip3 must be installed and available on PATH."); |
|
|
|
return; |
|
|
|
}*/ |
|
|
|
|
|
|
|
//==============================SETUP PATHS======================================
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
pyrceptionPath = pyrceptionPath.Replace("/", "\\"); |
|
|
|
packagesPath = packagesPath.Replace("/", "\\"); |
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
//pyrceptionPath = pyrceptionPath.Replace(" ", "\\ ");
|
|
|
|
//packagesPath = packagesPath.Replace(" ", "\\ ");
|
|
|
|
|
|
|
|
//==============================INSTALL VIRTUALENV======================================
|
|
|
|
//EditorUtility.DisplayProgressBar("Setting up Pyrception", "Installing virtualenv...", 0 / steps);
|
|
|
|
|
|
|
|
ExitCode = 0; |
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
//ExecuteCMD($"\"{packagesPath}\\pip3.bat\" install virtualenv", ref ExitCode);
|
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
//ExecuteCMD($"pip3 install --target=\"{path}/virtualenvDI\" virtualenv", ref ExitCode); //(maybe add --no-user)
|
|
|
|
#endif
|
|
|
|
/*if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
return; |
|
|
|
}*/ |
|
|
|
|
|
|
|
//==============================CREATE VIRTUALENV NAMED DataInsightsEnv======================================
|
|
|
|
//EditorUtility.DisplayProgressBar("Setting up Pyrception", "Setting up virtualenv instance...", 1f / steps);
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
//ExecuteCMD($"\"{packagesPath}\\virtualenv.exe\" -p python3 \"{path}\\DataInsightsEnv\"", ref ExitCode);
|
|
|
|
#elif (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
|
|
|
|
//string virtualenvPath = path+"/virtualenvDI/bin/";
|
|
|
|
//ExecuteCMD("export PYTHONPATH=\"${PYTHONPATH}:"+$"{path}/virtualenvDI\";"+$"\"{virtualenvPath}/virtualenv\" -p python3 \"{path}/DataInsightsEnv\"", ref ExitCode);
|
|
|
|
#endif
|
|
|
|
/*if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
return; |
|
|
|
}*/ |
|
|
|
|
|
|
|
//ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{path}\\DataInsightsEnv\\pyrception-util\"", ref ExitCode);
|
|
|
|
//ExecuteCMD($"XCOPY /E/I/Y \"{pyrceptionPath}\" \"{packagesPath}\\..\\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}\' \'{packagesPath}/../pyrception-util\'", ref ExitCode); |
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
|
|
|
|
|
|
|
/*UnityEngine.Debug.Log(pyrceptionPath); |
|
|
|
UnityEngine.Debug.Log(packagesPath); |
|
|
|
DirectoryCopy(pyrceptionPath, packagesPath);*/ |
|
|
|
|
|
|
|
//==============================INSTALL PYRCEPTION IN PYTHON FOR UNITY======================================
|
|
|
|
|
|
|
|
//==============================INSTALL PYRCEPTION IN THE VIRTUALENV======================================
|
|
|
|
//ExecuteCMD($"\"{path}\\DataInsightsEnv\\Scripts\\activate\" && cd \"{path}\\DataInsightsEnv\\pyrception-util\" && \"{packagesPath}\"\\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($"\\cp -r \'{pyrceptionPath}\pyrception-utils.py\' \'{packagesPath}\pyrception-utils.py\', ref ExitCode);
|
|
|
|
#endif
|
|
|
|
if (ExitCode != 0) { |
|
|
|
EditorUtility.ClearProgressBar(); |
|
|
|
|
|
|
string shell = ""; |
|
|
|
string argument = ""; |
|
|
|
string output = ""; |
|
|
|
|
|
|
|
UnityEngine.Debug.Log(command); |
|
|
|
|
|
|
|
#if UNITY_EDITOR_WIN
|
|
|
|
shell = "cmd.exe"; |
|
|
|