Skip to content

Commit 350998c

Browse files
author
David
committed
Major update for 4.25 so can load system python shared library extension modules on debian/ubuntu eg ctypes/unittest.
This may make it impossible to load Epics python and UnrealEnginePython together.
1 parent f52a2c1 commit 350998c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,27 @@ void unreal_engine_init_py_module();
2828
void init_unreal_engine_builtin();
2929

3030
#if PLATFORM_LINUX
31+
// so something seems to have changed between 4.18 and 4.25 which means we can no longer
32+
// import python extension modules that have/are dynamic libraries (ie site?dist-packages modules)
33+
// eg import ctypes fails with missing dynamic link symbol found in the primary python shared library
34+
// it seems that the python extension modules are not able to access the primary
35+
// python shared library /usr/lib/x86_64-linux-gnu/libpythonx.x.so symbols
36+
// OK so this gets even more confusing as apparently on other linux distributions the python extension libraries
37+
// ARE linked with the primary python shared library - this is a debian/ubuntu issue
38+
// it appears what happened is that the default symbol visibility for global symbols was changed from default to hidden
39+
// - likely to reduce chance of symbol clashes - it could be particularly true now with Unreals python implementation
40+
// although that seems to use static linking - but this fixup may mean we cannot have both python implementations
41+
// active
42+
// note that ue4_module_options is a symbol whose existence and value is checked in either LinuxPlatformProcess.cpp (4.18)
43+
// or UnixPlatformProcess.cpp (4.25) to determine if to load dynamic libraries using RTLD_GLOBAL
44+
// - otherwise RTLD_LOCAL is used
45+
// it apparently has to be a global symbol itself for this to work
46+
#if ENGINE_MINOR_VERSION >= 25
47+
const char *ue4_module_options __attribute__((visibility("default"))) = "linux_global_symbols";
48+
#else
3149
const char *ue4_module_options = "linux_global_symbols";
3250
#endif
51+
#endif
3352

3453
#include "Runtime/Core/Public/Misc/CommandLine.h"
3554
#include "Runtime/Core/Public/Misc/ConfigCacheIni.h"

0 commit comments

Comments
 (0)