Skip to content

Commit a56692e

Browse files
author
ikrima
committed
Make GetWindowsPythonLibFile() more robust and output error if lib not found
1 parent 278fa48 commit a56692e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Source/UnrealEnginePython/UnrealEnginePython.Build.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,25 @@ private string GetWindowsPythonLibFile(string basePath)
398398
// just for usability, report if the pythonHome is not in the system path
399399
string[] allPaths = System.Environment.GetEnvironmentVariable("PATH").Split(';');
400400
// this will transform the slashes in backslashes...
401-
string checkedPath = Path.GetFullPath(basePath);
402-
if (checkedPath.EndsWith("\\"))
403-
{
404-
checkedPath = checkedPath.Remove(checkedPath.Length - 1);
405-
}
401+
string checkedPath = !string.IsNullOrWhiteSpace(basePath)
402+
? new System.Uri(Path.GetFullPath(basePath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)).LocalPath
403+
: basePath;
404+
406405
bool found = false;
407406
foreach (string item in allPaths)
408407
{
409-
if (item == checkedPath || item == checkedPath + "\\")
408+
string checkedItem = !string.IsNullOrWhiteSpace(item)
409+
? new System.Uri(item.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)).LocalPath
410+
: item;
411+
if (checkedItem == checkedPath)
410412
{
411413
found = true;
412414
break;
413415
}
414416
}
415417
if (!found)
416418
{
417-
System.Console.WriteLine("[WARNING] Your Python installation is not in the system PATH environment variable.");
419+
System.Console.WriteLine("[WARNING] Your Python installation ({0}) is not in the system PATH environment variable.", checkedPath);
418420
System.Console.WriteLine("[WARNING] Ensure your python paths are set in GlobalConfig (DefaultEngine.ini) so the path can be corrected at runtime.");
419421
}
420422
// first try with python3

0 commit comments

Comments
 (0)