Skip to content

Commit 01c46e8

Browse files
committed
compile fixes for 4.20 fork
1 parent 3b04a35 commit 01c46e8

File tree

8 files changed

+62
-92
lines changed

8 files changed

+62
-92
lines changed

Source/UnrealEnginePython/Private/PipConsoleManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Fill out your copyright notice in the Description page of Project Settings.
22

3+
#include "PipConsoleManager.h"
34
#include "UnrealEnginePythonPrivatePCH.h"
45
#include "IPluginManager.h"
5-
#include "PipConsoleManager.h"
6+
67

78
UPipConsoleManager::UPipConsoleManager(const FObjectInitializer& ObjectInitializer)
89
: Super(ObjectInitializer)

Source/UnrealEnginePython/Private/PythonComponent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
153153

154154
Py_XDECREF(ep_ret);
155155
}
156-
Py_DECREF(bp_ret);
157156

158157
Super::EndPlay(EndPlayReason);
159158
}

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -770,16 +770,10 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj
770770

771771
FGraphEventRef task = FFunctionGraphTask::CreateAndDispatchWhenReady([&, py_callable_s, py_params_s]() {
772772
//UE_LOG(LogPython, Log, TEXT("In task graph, are in game thread? %d"), IsInGameThread());
773-
774-
<<<<<<< HEAD
775-
=======
776-
777-
FGraphEventRef task = FFunctionGraphTask::CreateAndDispatchWhenReady([&]() {
778-
>>>>>>> pr/9
779773
FScopePythonGIL gil;
780774
PyObject *ret = nullptr;
781775
PyObject *py_tuple_params = nullptr;
782-
776+
783777
//do we have parameters?
784778
if (py_params_s)
785779
{
@@ -793,16 +787,14 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj
793787
}
794788

795789
//did we get a valid return from our call?
796-
if (ret)
790+
if (ret)
797791
{
798792
Py_DECREF(ret);
799793
}
800-
else
794+
else
801795
{
802796
unreal_engine_py_log_error();
803797
}
804-
<<<<<<< HEAD
805-
806798
if (py_params_s)
807799
{
808800
Py_DECREF(py_params_s);
@@ -813,21 +805,9 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj
813805
}
814806
Py_DECREF(py_callable_s);
815807
}, TStatId(), nullptr, ENamedThreads::GameThread);
816-
808+
817809
Py_INCREF(Py_None);
818810
return Py_None;
819-
=======
820-
Py_DECREF(py_callable);
821-
}, TStatId(), nullptr, (ENamedThreads::Type)named_thread);
822-
823-
824-
Py_BEGIN_ALLOW_THREADS;
825-
FTaskGraphInterface::Get().WaitUntilTaskCompletes(task);
826-
Py_END_ALLOW_THREADS;
827-
// TODO Implement signal triggering in addition to WaitUntilTaskCompletes
828-
// FTaskGraphInterface::Get().TriggerEventWhenTaskCompletes
829-
830-
Py_RETURN_NONE;
831811
}
832812

833813

@@ -862,7 +842,6 @@ PyObject *py_unreal_engine_main_thread_call(PyObject * self, PyObject * args)
862842
Py_END_ALLOW_THREADS;
863843

864844
Py_RETURN_NONE;
865-
>>>>>>> pr/9
866845
}
867846
#endif
868847

Source/UnrealEnginePython/Private/UEPyLambda.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "UEPyLambda.h"
12
#include "UnrealEnginePythonPrivatePCH.h"
23

34
PyObject * py_ue_run_on_game_thread(PyObject* PyFunction, PyObject* Args)

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,6 @@ void FUnrealEnginePythonModule::StartupModule()
435435
}
436436
else
437437
{
438-
<<<<<<< HEAD
439-
// TODO gracefully manage the error
440-
UE_LOG(LogPython, Warning, TEXT("ue_site not found (if you don't use the startup file ignore this warning)"));
441-
//unreal_engine_py_log_error();
442-
}
443-
=======
444438
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 6
445439
if (PyErr_ExceptionMatches(PyExc_ModuleNotFoundError))
446440
{
@@ -455,7 +449,6 @@ void FUnrealEnginePythonModule::StartupModule()
455449
unreal_engine_py_log_error();
456450
#endif
457451
}
458-
>>>>>>> pr/9
459452

460453
// release the GIL
461454
PyThreadState *UEPyGlobalState = PyEval_SaveThread();
@@ -635,7 +628,7 @@ PyObject *ue_py_register_module(const char *name)
635628

636629
void FUnrealEnginePythonModule::AddPathToSysPath(const FString& Path)
637630
{
638-
PythonGILAcquire();
631+
FScopePythonGIL gil;
639632

640633
PyObject *py_sys = PyImport_ImportModule("sys");
641634
PyObject *py_sys_dict = PyModule_GetDict(py_sys);
@@ -644,8 +637,6 @@ void FUnrealEnginePythonModule::AddPathToSysPath(const FString& Path)
644637
char *charPath = TCHAR_TO_UTF8(*Path);
645638
PyObject *py_scripts_path = PyUnicode_FromString(charPath);
646639
PyList_Insert(py_path, 0, py_scripts_path);
647-
648-
PythonGILRelease();
649640
}
650641

651642
void FUnrealEnginePythonModule::AddPythonDependentPlugin(const FString& PluginName)
@@ -660,16 +651,14 @@ void FUnrealEnginePythonModule::AddPythonDependentPlugin(const FString& PluginNa
660651
FString PyModulePath = FString::Printf(TEXT("%s/upymodule.json"), *ScriptsPath);
661652
FString RunImport = FString::Printf(TEXT("import upymodule_importer\nupymodule_importer.parseJson('%s')"), *PyModulePath);
662653

663-
PythonGILAcquire();
654+
FScopePythonGIL gil;
664655

665656
if (PyRun_SimpleString(TCHAR_TO_UTF8(*RunImport)) == 0) {
666657
UE_LOG(LogPython, Log, TEXT("%s Plugin upymodule.json parsed"), *PluginName);
667658
}
668659
else {
669660
unreal_engine_py_log_error();
670661
}
671-
672-
PythonGILRelease();
673662
}
674663

675664
#undef LOCTEXT_NAMESPACE

Source/UnrealEnginePython/Public/PipConsoleManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#pragma once
44

5+
#include "Runtime/Engine/Classes/GameFramework/CheatManager.h"
56
#include "PipConsoleManager.generated.h"
67

78
/**

Source/UnrealEnginePython/UnrealEnginePython.Build.cs

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ protected string ThirdPartyPythonHome
2323

2424

2525
// otherwise specify the path of your python installation
26-
//private string pythonHome = "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/";
26+
//private string PythonHome = "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/";
2727
// on Linux an include;libs syntax is expected:
28-
//private string pythonHome = "/usr/local/include/python3.6;/usr/local/lib/libpython3.6.so"
28+
//private string PythonHome = "/usr/local/include/python3.6;/usr/local/lib/libpython3.6.so"
2929

3030
//Swap python versions here
3131
private string PythonType = "Python36";
@@ -229,62 +229,62 @@ public UnrealEnginePython(TargetInfo Target)
229229
});
230230
}
231231

232-
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
233-
{
234-
if (UseThirdPartyPython)
235-
{
236-
PythonHome = ThirdPartyPythonHome;
232+
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
233+
{
234+
if (UseThirdPartyPython)
235+
{
236+
PythonHome = ThirdPartyPythonHome;
237237

238-
System.Console.WriteLine("Using Embedded Python at: " + PythonHome);
239-
PublicIncludePaths.Add(PythonHome);
240-
string libPath = Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType.ToLower()));
238+
System.Console.WriteLine("Using Embedded Python at: " + PythonHome);
239+
PublicIncludePaths.Add(PythonHome);
240+
string libPath = Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType.ToLower()));
241241

242-
System.Console.WriteLine("full lib path: " + libPath);
243-
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
244-
PublicAdditionalLibraries.Add(libPath);
242+
System.Console.WriteLine("full lib path: " + libPath);
243+
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
244+
PublicAdditionalLibraries.Add(libPath);
245245

246246
string dllPath = Path.Combine(BinariesPath, "Win64", string.Format("{0}.dll", PythonType.ToLower()));
247-
RuntimeDependencies.Add(new RuntimeDependency(dllPath));
247+
RuntimeDependencies.Add(dllPath);
248248
}
249-
else if (PythonHome == "")
250-
{
251-
pythonHome = DiscoverPythonPath(windowsKnownPaths, "Win64");
252-
if (pythonHome == "")
253-
{
254-
throw new System.Exception("Unable to find Python installation");
255-
}
256-
257-
System.Console.WriteLine("Using Python at: " + PythonHome);
258-
PublicIncludePaths.Add(PythonHome);
259-
string libPath = GetWindowsPythonLibFile(PythonHome);
260-
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
261-
PublicAdditionalLibraries.Add(libPath);
262-
}
263-
}
264-
265-
//other platforms
266-
else
249+
else if (PythonHome == "")
250+
{
251+
PythonHome = DiscoverPythonPath(windowsKnownPaths, "Win64");
252+
if (PythonHome == "")
253+
{
254+
throw new System.Exception("Unable to find Python installation");
255+
}
256+
257+
System.Console.WriteLine("Using Python at: " + PythonHome);
258+
PublicIncludePaths.Add(PythonHome);
259+
string libPath = GetWindowsPythonLibFile(PythonHome);
260+
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
261+
PublicAdditionalLibraries.Add(libPath);
262+
}
263+
}
264+
265+
//other platforms
266+
else
267+
{
268+
if (PythonHome == "")
269+
{
270+
PythonHome = DiscoverPythonPath(macKnownPaths, "Mac");
271+
if (PythonHome == "")
272+
{
273+
throw new System.Exception("Unable to find Python installation");
274+
}
275+
System.Console.WriteLine("Using Python at: " + PythonHome);
276+
PublicIncludePaths.Add(PythonHome);
277+
PublicAdditionalLibraries.Add(Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType)));
278+
}
279+
System.Console.WriteLine("Using Python at: " + PythonHome);
280+
PublicIncludePaths.Add(PythonHome);
281+
string libPath = GetMacPythonLibFile(PythonHome);
282+
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
283+
PublicDelayLoadDLLs.Add(libPath);
284+
}
285+
if (Target.Platform == UnrealTargetPlatform.Linux)
267286
{
268287
if (PythonHome == "")
269-
{
270-
pythonHome = DiscoverPythonPath(macKnownPaths, "Mac");
271-
if (pythonHome == "")
272-
{
273-
throw new System.Exception("Unable to find Python installation");
274-
}
275-
System.Console.WriteLine("Using Python at: " + PythonHome);
276-
PublicIncludePaths.Add(PythonHome);
277-
PublicAdditionalLibraries.Add(Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType)));
278-
}
279-
System.Console.WriteLine("Using Python at: " + pythonHome);
280-
PublicIncludePaths.Add(pythonHome);
281-
string libPath = GetMacPythonLibFile(pythonHome);
282-
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
283-
PublicDelayLoadDLLs.Add(libPath);
284-
}
285-
else if (Target.Platform == UnrealTargetPlatform.Linux)
286-
{
287-
if (pythonHome == "")
288288
{
289289
string includesPath = DiscoverLinuxPythonIncludesPath();
290290
if (includesPath == null)

UnrealEnginePython.uplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"FileVersion": 3,
33
"Version": 1,
4-
"VersionName": "1.5.0",
4+
"VersionName": "1.6.0",
55
"FriendlyName": "UnrealEnginePython",
66
"Description": "Embed a Python VM in your project",
77
"Category": "Scripting Languages",

0 commit comments

Comments
 (0)