Skip to content

Commit fdc521b

Browse files
author
rdeioris
committed
fixed build on Linux systems, closes 20tab#170
1 parent 9ea995b commit fdc521b

4 files changed

Lines changed: 89 additions & 7 deletions

File tree

‎Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ PyObject *py_ue_new_fmenu_builder(FMenuBuilder *menu_builder) {
198198
ue_PyFMenuBuilder *ret = (ue_PyFMenuBuilder *)PyObject_New(ue_PyFMenuBuilder, &ue_PyFMenuBuilderType);
199199
ret->menu_builder = menu_builder;
200200
return (PyObject *)ret;
201-
}
201+
}

‎Source/UnrealEnginePython/Private/Slate/UEPySWindow.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ static PyObject *py_ue_swindow_set_sizing_rule(ue_PySWindow *self, PyObject * ar
6363

6464
GET_s_window;
6565

66+
#if ENGINE_MINOR_VERSION > 15
67+
s_window->SetSizingRule((ESizingRule)rule);
68+
#else
6669
s_window->SetSizingRule((ESizingRule::Type)rule);
70+
#endif
6771

6872
Py_INCREF(self);
6973
return (PyObject *)self;

‎Source/UnrealEnginePython/Public/UnrealEnginePython.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#pragma once
44

5+
#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
6+
57
#include "ModuleManager.h"
68

79
#include "Runtime/SlateCore/Public/Styling/SlateStyle.h"

‎Source/UnrealEnginePython/UnrealEnginePython.Build.cs‎

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class UnrealEnginePython : ModuleRules
1313
//private string pythonHome = "C:/Program Files/Python36";
1414
// this is an example for Homebrew on Mac
1515
//private string pythonHome = "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/";
16+
// on Linux an include;libs syntax is expected:
17+
//private string pythonHome = "/usr/local/include/python3.6;/usr/local/lib/libpython3.6.so"
1618

1719

1820
private string[] windowsKnownPaths =
@@ -30,6 +32,44 @@ public class UnrealEnginePython : ModuleRules
3032
"/Library/Frameworks/Python.framework/Versions/2.7",
3133
};
3234

35+
private string[] linuxKnownIncludesPaths =
36+
{
37+
"/usr/local/include/python3.6",
38+
"/usr/local/include/python3.6m",
39+
"/usr/local/include/python3.5",
40+
"/usr/local/include/python3.5m",
41+
"/usr/local/include/python2.7",
42+
"/usr/include/python3.6",
43+
"/usr/include/python3.6m",
44+
"/usr/include/python3.5",
45+
"/usr/include/python3.5m",
46+
"/usr/include/python2.7",
47+
};
48+
49+
private string[] linuxKnownLibsPaths =
50+
{
51+
"/usr/local/lib/libpython3.6.so",
52+
"/usr/local/lib/libpython3.6m.so",
53+
"/usr/local/lib/x86_64-linux-gnu/libpython3.6.so",
54+
"/usr/local/lib/x86_64-linux-gnu/libpython3.6m.so",
55+
"/usr/local/lib/libpython3.5.so",
56+
"/usr/local/lib/libpython3.5m.so",
57+
"/usr/local/lib/x86_64-linux-gnu/libpython3.5.so",
58+
"/usr/local/lib/x86_64-linux-gnu/libpython3.5m.so",
59+
"/usr/local/lib/libpython2.7.so",
60+
"/usr/local/lib/x86_64-linux-gnu/libpython2.7.so",
61+
"/usr/lib/libpython3.6.so",
62+
"/usr/lib/libpython3.6m.so",
63+
"/usr/lib/x86_64-linux-gnu/libpython3.6.so",
64+
"/usr/lib/x86_64-linux-gnu/libpython3.6m.so",
65+
"/usr/lib/libpython3.5.so",
66+
"/usr/lib/libpython3.5m.so",
67+
"/usr/lib/x86_64-linux-gnu/libpython3.5.so",
68+
"/usr/lib/x86_64-linux-gnu/libpython3.5m.so",
69+
"/usr/lib/libpython2.7.so",
70+
"/usr/lib/x86_64-linux-gnu/libpython2.7.so",
71+
};
72+
3373
public UnrealEnginePython(TargetInfo Target)
3474
{
3575

@@ -140,15 +180,26 @@ public UnrealEnginePython(TargetInfo Target)
140180
}
141181
else if (Target.Platform == UnrealTargetPlatform.Linux)
142182
{
143-
if (pythonHome == "python35")
183+
if (pythonHome == "")
144184
{
145-
PublicIncludePaths.Add("/usr/include/python3.5m");
146-
PublicAdditionalLibraries.Add("/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5.so");
185+
string includesPath = DiscoverLinuxPythonIncludesPath();
186+
if (includesPath == null)
187+
{
188+
throw new System.Exception("Unable to find Python includes, please add a search path to linuxKnownIncludesPaths");
189+
}
190+
string libsPath = DiscoverLinuxPythonLibsPath();
191+
if (libsPath == null)
192+
{
193+
throw new System.Exception("Unable to find Python libs, please add a search path to linuxKnownLibsPaths");
194+
}
195+
PublicIncludePaths.Add(includesPath);
196+
PublicAdditionalLibraries.Add(libsPath);
147197
}
148-
else if (pythonHome == "python27")
198+
else
149199
{
150-
PublicIncludePaths.Add("/usr/include/python2.7");
151-
PublicAdditionalLibraries.Add("/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so");
200+
string []items = pythonHome.Split(';');
201+
PublicIncludePaths.Add(items[0]);
202+
PublicAdditionalLibraries.Add(items[1]);
152203
}
153204
Definitions.Add(string.Format("UNREAL_ENGINE_PYTHON_ON_LINUX"));
154205
}
@@ -180,6 +231,31 @@ private string DiscoverPythonPath(string[] knownPaths)
180231
return "";
181232
}
182233

234+
private string DiscoverLinuxPythonIncludesPath()
235+
{
236+
foreach (string path in linuxKnownIncludesPaths)
237+
{
238+
string headerFile = Path.Combine(path, "Python.h");
239+
if (File.Exists(headerFile))
240+
{
241+
return path;
242+
}
243+
}
244+
return null;
245+
}
246+
247+
private string DiscoverLinuxPythonLibsPath()
248+
{
249+
foreach (string path in linuxKnownLibsPaths)
250+
{
251+
if (File.Exists(path))
252+
{
253+
return path;
254+
}
255+
}
256+
return null;
257+
}
258+
183259
private string GetMacPythonLibFile(string basePath)
184260
{
185261
// first try with python3

0 commit comments

Comments
 (0)