Skip to content

Commit e15b946

Browse files
author
Roberto De Ioris
committed
added AdditionalModulesPath ini directive
1 parent 4c8a9fe commit e15b946

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose) {
8787
PyObject *py_scripts_path = PyUnicode_FromString(scripts_path);
8888
PyList_Insert(py_path, 0, py_scripts_path);
8989

90+
char *additional_modules_path = TCHAR_TO_UTF8(*AdditionalModulesPath);
91+
PyObject *py_additional_modules_path = PyUnicode_FromString(additional_modules_path);
92+
PyList_Insert(py_path, 0, py_additional_modules_path);
93+
9094
if (verbose) {
9195
UE_LOG(LogPython, Log, TEXT("Python VM initialized: %s"), UTF8_TO_TCHAR(Py_GetVersion()));
9296
UE_LOG(LogPython, Log, TEXT("Python Scripts search path: %s"), UTF8_TO_TCHAR(scripts_path));
@@ -104,6 +108,8 @@ static void setup_stdout_stderr() {
104108
" self.logger(buf)\n"
105109
" def flush(self):\n"
106110
" return\n"
111+
" def isatty(self):\n"
112+
" return False\n"
107113
"sys.stdout = UnrealEngineOutput(unreal_engine.log)\n"
108114
"sys.stderr = UnrealEngineOutput(unreal_engine.log_error)\n";
109115
PyRun_SimpleString(code);
@@ -179,6 +185,14 @@ void FUnrealEnginePythonModule::StartupModule()
179185
ScriptsPath = FPaths::Combine(FPaths::GameContentDir(), IniValue);
180186
}
181187

188+
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("AdditionalModulesPath"), IniValue, GEngineIni)) {
189+
AdditionalModulesPath = IniValue;
190+
}
191+
192+
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("RelativeAdditionalModulesPath"), IniValue, GEngineIni)) {
193+
AdditionalModulesPath = FPaths::Combine(FPaths::GameContentDir(), IniValue);
194+
}
195+
182196
if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ZipPath"), IniValue, GEngineIni)) {
183197
ZipPath = IniValue;
184198
}

Source/UnrealEnginePython/Public/UnrealEnginePython.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface
3232

3333
FString ScriptsPath;
3434
FString ZipPath;
35+
FString AdditionalModulesPath;
3536

3637
private:
3738
void *ue_python_gil;

0 commit comments

Comments
 (0)