Skip to content

Commit 369947f

Browse files
author
ikrima
committed
Merge Fix: Adding back our custom logic for loading the plugin to guard against existing python installations
1 parent 5851564 commit 369947f

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

‎Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.cpp‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ PyObject *py_ue_set_slate_widget(ue_PyUObject * self, PyObject * args)
2626
if (!s_widget)
2727
return PyErr_Format(PyExc_Exception, "argument is not a SWidget");
2828

29-
if (widget_component)
30-
{
31-
widget_component->SetSlateWidget(s_widget->s_widget);
32-
}
33-
else
34-
{
35-
py_user_widget->SetSlateWidget(s_widget->s_widget);
36-
}
29+
if (widget_component) { widget_component->SetSlateWidget(s_widget->s_widget); }
30+
else { py_user_widget->SetSlateWidget(s_widget->s_widget); }
3731

3832
Py_RETURN_NONE;
3933
}

‎Source/UnrealEnginePython/Private/UnrealEnginePython.cpp‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,25 @@ void FUnrealEnginePythonModule::StartupModule()
159159
BrutalFinalize = false;
160160

161161
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
162-
FString IniValue;
163-
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("Home"), IniValue, GEngineIni)) {
162+
FString PythonHome;
163+
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("Home"), PythonHome, GEngineIni)) {
164164
#if PY_MAJOR_VERSION >= 3
165-
wchar_t *home = (wchar_t *)*IniValue;
165+
wchar_t *home = (wchar_t *)*PythonHome;
166166
#else
167-
char *home = TCHAR_TO_UTF8(*IniValue);
167+
char *home = TCHAR_TO_UTF8(*PythonHome);
168168
#endif
169-
FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONHOME"), *IniValue);
169+
FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONHOME"), *PythonHome);
170170
Py_SetPythonHome(home);
171171
}
172172

173-
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("RelativeHome"), IniValue, GEngineIni)) {
174-
IniValue = FPaths::Combine(*PROJECT_CONTENT_DIR, *IniValue);
175-
FPaths::NormalizeFilename(IniValue);
176-
IniValue = FPaths::ConvertRelativePathToFull(IniValue);
173+
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("RelativeHome"), PythonHome, GEngineIni)) {
174+
PythonHome = FPaths::Combine(*PROJECT_CONTENT_DIR, *PythonHome);
175+
FPaths::NormalizeFilename(PythonHome);
176+
PythonHome = FPaths::ConvertRelativePathToFull(PythonHome);
177177
#if PY_MAJOR_VERSION >= 3
178-
wchar_t *home = (wchar_t *)*IniValue;
178+
wchar_t *home = (wchar_t *)*PythonHome;
179179
#else
180-
char *home = TCHAR_TO_UTF8(*IniValue);
180+
char *home = TCHAR_TO_UTF8(*PythonHome);
181181
#endif
182182

183183
Py_SetPythonHome(home);
@@ -245,9 +245,9 @@ void FUnrealEnginePythonModule::StartupModule()
245245
// To ensure there are no path conflicts, if we have a valid python home at this point,
246246
// we override the current environment entirely with the environment we want to use,
247247
// removing any paths to other python environments we aren't using.
248-
if (IniValue.Len() > 0)
248+
if (PythonHome.Len() > 0)
249249
{
250-
FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONHOME"), *IniValue);
250+
FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONHOME"), *PythonHome);
251251

252252
const int32 MaxPathVarLen = 32768;
253253
FString OrigPathVar = FString::ChrN(MaxPathVarLen, TEXT('\0'));
@@ -268,9 +268,9 @@ void FUnrealEnginePythonModule::StartupModule()
268268

269269
// Setup our own paths for PYTHONPATH
270270
TArray<FString> OurPythonPaths = {
271-
IniValue,
272-
FPaths::Combine(IniValue, TEXT("Lib")),
273-
FPaths::Combine(IniValue, TEXT("Lib/site-packages")),
271+
PythonHome,
272+
FPaths::Combine(PythonHome, TEXT("Lib")),
273+
FPaths::Combine(PythonHome, TEXT("Lib/site-packages")),
274274
};
275275
FString PythonPathVars = FString::Join(OurPythonPaths, PathDelimiter);
276276
FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONPATH"), *PythonPathVars);

0 commit comments

Comments
 (0)