Skip to content

Commit

Permalink
path fixes for 4.16
Browse files Browse the repository at this point in the history
-FPath::Combine doesn't behave as previously in regards to raw char*.
Wrapping path chunks in FString() returns expected behavior.
  • Loading branch information
getnamo committed Jun 6, 2017
1 parent 385dd21 commit 73f0cee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/UnrealEnginePython/Private/UnrealEnginePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ static void UESetupPythonInterpeter(bool verbose) {

PyObject *py_path = PyDict_GetItemString(py_sys_dict, "path");

char *zip_path = TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(FPaths::Combine(*FPaths::GameContentDir(), UTF8_TO_TCHAR("ue_python.zip"))));
char *zip_path = TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::GameContentDir(), FString("ue_python.zip"))));
PyObject *py_zip_path = PyUnicode_FromString(zip_path);
PyList_Insert(py_path, 0, py_zip_path);

char *scripts_path = TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(FPaths::Combine(*FPaths::GameContentDir(), UTF8_TO_TCHAR("Scripts"))));
char *scripts_path = TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::GameContentDir(), FString("Scripts"))));
PyObject *py_scripts_path = PyUnicode_FromString(scripts_path);
PyList_Insert(py_path, 0, py_scripts_path);

/* UnrealEnginePython Plugin Content/Scripts path */
FString PluginRoot = IPluginManager::Get().FindPlugin("UnrealEnginePython")->GetBaseDir();
FString ScriptsPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(PluginRoot, "Content/Scripts"));
FString ScriptsPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(PluginRoot, FString("Content/Scripts")));
PyObject *py_plugin_scripts_path = PyUnicode_FromString(TCHAR_TO_UTF8(*ScriptsPath));
PyList_Insert(py_path, 0, py_plugin_scripts_path);

/* add the plugin paths - windows only */
FString PythonHome = FPaths::ConvertRelativePathToFull(FPaths::Combine(*FPaths::GamePluginsDir(), "UnrealEnginePython/Binaries/Win64"));
FString PythonHome = FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::GamePluginsDir(), FString("UnrealEnginePython/Binaries/Win64")));
char *python_path = TCHAR_TO_UTF8(*PythonHome);
char *site_path = TCHAR_TO_UTF8(*FPaths::Combine(*PythonHome, "Lib/site-packages"));
char *site_path = TCHAR_TO_UTF8(*FPaths::Combine(FString(PythonHome), FString("Lib/site-packages")));
PyList_Insert(py_path, 0, PyUnicode_FromString(python_path));
PyList_Insert(py_path, 0, PyUnicode_FromString(site_path));

Expand Down Expand Up @@ -356,7 +356,7 @@ void FUnrealEnginePythonModule::AddPythonDependentPlugin(const FString& PluginNa
{
//Add plugin Content/Script to sys.path
FString PluginRoot = IPluginManager::Get().FindPlugin(PluginName)->GetBaseDir();
FString ScriptsPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(PluginRoot, "Content/Scripts"));
FString ScriptsPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(PluginRoot, FString("Content/Scripts")));
FUnrealEnginePythonModule::Get().AddPathToSysPath(ScriptsPath);
UE_LOG(LogPython, Log, TEXT("Added %s Plugin Content/Scripts (%s) to sys.path"), *PluginName, *ScriptsPath);

Expand Down

0 comments on commit 73f0cee

Please sign in to comment.