Skip to content

Commit

Permalink
compile fixes for 4.20 fork
Browse files Browse the repository at this point in the history
  • Loading branch information
getnamo committed Jul 21, 2018
1 parent 3b04a35 commit 01c46e8
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 92 deletions.
3 changes: 2 additions & 1 deletion Source/UnrealEnginePython/Private/PipConsoleManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.

#include "PipConsoleManager.h"
#include "UnrealEnginePythonPrivatePCH.h"
#include "IPluginManager.h"
#include "PipConsoleManager.h"


UPipConsoleManager::UPipConsoleManager(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
Expand Down
1 change: 0 additions & 1 deletion Source/UnrealEnginePython/Private/PythonComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)

Py_XDECREF(ep_ret);
}
Py_DECREF(bp_ret);

Super::EndPlay(EndPlayReason);
}
Expand Down
29 changes: 4 additions & 25 deletions Source/UnrealEnginePython/Private/UEPyEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,10 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj

FGraphEventRef task = FFunctionGraphTask::CreateAndDispatchWhenReady([&, py_callable_s, py_params_s]() {
//UE_LOG(LogPython, Log, TEXT("In task graph, are in game thread? %d"), IsInGameThread());

<<<<<<< HEAD
=======

FGraphEventRef task = FFunctionGraphTask::CreateAndDispatchWhenReady([&]() {
>>>>>>> pr/9
FScopePythonGIL gil;
PyObject *ret = nullptr;
PyObject *py_tuple_params = nullptr;

//do we have parameters?
if (py_params_s)
{
Expand All @@ -793,16 +787,14 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj
}

//did we get a valid return from our call?
if (ret)
if (ret)
{
Py_DECREF(ret);
}
else
else
{
unreal_engine_py_log_error();
}
<<<<<<< HEAD

if (py_params_s)
{
Py_DECREF(py_params_s);
Expand All @@ -813,21 +805,9 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj
}
Py_DECREF(py_callable_s);
}, TStatId(), nullptr, ENamedThreads::GameThread);

Py_INCREF(Py_None);
return Py_None;
=======
Py_DECREF(py_callable);
}, TStatId(), nullptr, (ENamedThreads::Type)named_thread);


Py_BEGIN_ALLOW_THREADS;
FTaskGraphInterface::Get().WaitUntilTaskCompletes(task);
Py_END_ALLOW_THREADS;
// TODO Implement signal triggering in addition to WaitUntilTaskCompletes
// FTaskGraphInterface::Get().TriggerEventWhenTaskCompletes

Py_RETURN_NONE;
}


Expand Down Expand Up @@ -862,7 +842,6 @@ PyObject *py_unreal_engine_main_thread_call(PyObject * self, PyObject * args)
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
>>>>>>> pr/9
}
#endif

Expand Down
1 change: 1 addition & 0 deletions Source/UnrealEnginePython/Private/UEPyLambda.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "UEPyLambda.h"
#include "UnrealEnginePythonPrivatePCH.h"

PyObject * py_ue_run_on_game_thread(PyObject* PyFunction, PyObject* Args)
Expand Down
15 changes: 2 additions & 13 deletions Source/UnrealEnginePython/Private/UnrealEnginePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,6 @@ void FUnrealEnginePythonModule::StartupModule()
}
else
{
<<<<<<< HEAD
// TODO gracefully manage the error
UE_LOG(LogPython, Warning, TEXT("ue_site not found (if you don't use the startup file ignore this warning)"));
//unreal_engine_py_log_error();
}
=======
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 6
if (PyErr_ExceptionMatches(PyExc_ModuleNotFoundError))
{
Expand All @@ -455,7 +449,6 @@ void FUnrealEnginePythonModule::StartupModule()
unreal_engine_py_log_error();
#endif
}
>>>>>>> pr/9

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

void FUnrealEnginePythonModule::AddPathToSysPath(const FString& Path)
{
PythonGILAcquire();
FScopePythonGIL gil;

PyObject *py_sys = PyImport_ImportModule("sys");
PyObject *py_sys_dict = PyModule_GetDict(py_sys);
Expand All @@ -644,8 +637,6 @@ void FUnrealEnginePythonModule::AddPathToSysPath(const FString& Path)
char *charPath = TCHAR_TO_UTF8(*Path);
PyObject *py_scripts_path = PyUnicode_FromString(charPath);
PyList_Insert(py_path, 0, py_scripts_path);

PythonGILRelease();
}

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

PythonGILAcquire();
FScopePythonGIL gil;

if (PyRun_SimpleString(TCHAR_TO_UTF8(*RunImport)) == 0) {
UE_LOG(LogPython, Log, TEXT("%s Plugin upymodule.json parsed"), *PluginName);
}
else {
unreal_engine_py_log_error();
}

PythonGILRelease();
}

#undef LOCTEXT_NAMESPACE
Expand Down
1 change: 1 addition & 0 deletions Source/UnrealEnginePython/Public/PipConsoleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma once

#include "Runtime/Engine/Classes/GameFramework/CheatManager.h"
#include "PipConsoleManager.generated.h"

/**
Expand Down
102 changes: 51 additions & 51 deletions Source/UnrealEnginePython/UnrealEnginePython.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ protected string ThirdPartyPythonHome


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

//Swap python versions here
private string PythonType = "Python36";
Expand Down Expand Up @@ -229,62 +229,62 @@ public UnrealEnginePython(TargetInfo Target)
});
}

if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
{
if (UseThirdPartyPython)
{
PythonHome = ThirdPartyPythonHome;
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
{
if (UseThirdPartyPython)
{
PythonHome = ThirdPartyPythonHome;

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

System.Console.WriteLine("full lib path: " + libPath);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicAdditionalLibraries.Add(libPath);
System.Console.WriteLine("full lib path: " + libPath);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicAdditionalLibraries.Add(libPath);

string dllPath = Path.Combine(BinariesPath, "Win64", string.Format("{0}.dll", PythonType.ToLower()));
RuntimeDependencies.Add(new RuntimeDependency(dllPath));
RuntimeDependencies.Add(dllPath);
}
else if (PythonHome == "")
{
pythonHome = DiscoverPythonPath(windowsKnownPaths, "Win64");
if (pythonHome == "")
{
throw new System.Exception("Unable to find Python installation");
}

System.Console.WriteLine("Using Python at: " + PythonHome);
PublicIncludePaths.Add(PythonHome);
string libPath = GetWindowsPythonLibFile(PythonHome);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicAdditionalLibraries.Add(libPath);
}
}

//other platforms
else
else if (PythonHome == "")
{
PythonHome = DiscoverPythonPath(windowsKnownPaths, "Win64");
if (PythonHome == "")
{
throw new System.Exception("Unable to find Python installation");
}

System.Console.WriteLine("Using Python at: " + PythonHome);
PublicIncludePaths.Add(PythonHome);
string libPath = GetWindowsPythonLibFile(PythonHome);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicAdditionalLibraries.Add(libPath);
}
}

//other platforms
else
{
if (PythonHome == "")
{
PythonHome = DiscoverPythonPath(macKnownPaths, "Mac");
if (PythonHome == "")
{
throw new System.Exception("Unable to find Python installation");
}
System.Console.WriteLine("Using Python at: " + PythonHome);
PublicIncludePaths.Add(PythonHome);
PublicAdditionalLibraries.Add(Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType)));
}
System.Console.WriteLine("Using Python at: " + PythonHome);
PublicIncludePaths.Add(PythonHome);
string libPath = GetMacPythonLibFile(PythonHome);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicDelayLoadDLLs.Add(libPath);
}
if (Target.Platform == UnrealTargetPlatform.Linux)
{
if (PythonHome == "")
{
pythonHome = DiscoverPythonPath(macKnownPaths, "Mac");
if (pythonHome == "")
{
throw new System.Exception("Unable to find Python installation");
}
System.Console.WriteLine("Using Python at: " + PythonHome);
PublicIncludePaths.Add(PythonHome);
PublicAdditionalLibraries.Add(Path.Combine(PythonHome, "Lib", string.Format("{0}.lib", PythonType)));
}
System.Console.WriteLine("Using Python at: " + pythonHome);
PublicIncludePaths.Add(pythonHome);
string libPath = GetMacPythonLibFile(pythonHome);
PublicLibraryPaths.Add(Path.GetDirectoryName(libPath));
PublicDelayLoadDLLs.Add(libPath);
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
if (pythonHome == "")
{
string includesPath = DiscoverLinuxPythonIncludesPath();
if (includesPath == null)
Expand Down
2 changes: 1 addition & 1 deletion UnrealEnginePython.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.5.0",
"VersionName": "1.6.0",
"FriendlyName": "UnrealEnginePython",
"Description": "Embed a Python VM in your project",
"Category": "Scripting Languages",
Expand Down

0 comments on commit 01c46e8

Please sign in to comment.