Skip to content

Commit ffcd1a8

Browse files
authored
Merge pull request #2 from deepdrive/revert-1-embedded-python
Revert "Bundle embedded Python interpreter under Linux and add CI build script"
2 parents e79420a + c356b81 commit ffcd1a8

112 files changed

Lines changed: 17530 additions & 106 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Config/FilterPlugin.ini‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎EmbeddedPython/.gitignore‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎Packaging/package-linux.sh‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎Packaging/package.py‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎Source/PythonAutomation/Public/PythonAutomationModule.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#pragma once
44

55
#include "CoreMinimal.h"
6-
#include "Modules/ModuleManager.h"
6+
#include "ModuleInterface.h"
77

88
class FPythonAutomationModule : public IModuleInterface
99
{

‎Source/UnrealEnginePython/Private/UnrealEnginePython.cpp‎

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ const char *ue4_module_options = "linux_global_symbols";
5151
#include "Android/AndroidApplication.h"
5252
#endif
5353

54-
#include "Misc/Paths.h"
55-
#include "HAL/FileManager.h"
56-
57-
58-
//Deleter class for TUniquePtr<wchar_t> pointers that store the result of Py_DecodeLocale()
59-
class PyMemDeleter
60-
{
61-
public:
62-
PyMemDeleter() = default;
63-
PyMemDeleter(const PyMemDeleter&) = default;
64-
PyMemDeleter& operator=(const PyMemDeleter&) = default;
65-
~PyMemDeleter() = default;
66-
67-
void operator()(wchar_t* mem) const {
68-
PyMem_RawFree(mem);
69-
}
70-
};
71-
7254

7355
const char *UEPyUnicode_AsUTF8(PyObject *py_str)
7456
{
@@ -203,7 +185,7 @@ static void setup_stdout_stderr()
203185
" def isatty(self):\n"
204186
" return False\n"
205187
"sys.stdout = UnrealEngineOutput(unreal_engine.log)\n"
206-
"sys.stderr = UnrealEngineOutput(unreal_engine.log)\n"
188+
"sys.stderr = UnrealEngineOutput(unreal_engine.log_error)\n"
207189
"\n"
208190
"class event:\n"
209191
" def __init__(self, event_signature):\n"
@@ -491,41 +473,7 @@ void FUnrealEnginePythonModule::StartupModule()
491473
Py_SetPath(Py_DecodeLocale(TCHAR_TO_UTF8(*BasePythonPath), NULL));
492474
#endif
493475
#endif
494-
495-
//Retrieve the paths to the Engine and project plugin directories
496-
FString enginePlugins = FPaths::ConvertRelativePathToFull(FPaths::EnginePluginsDir());
497-
FString projectPlugins = FPaths::ConvertRelativePathToFull(FPaths::ProjectPluginsDir());
498-
499-
//Attempt to detect the absolute path to our EmbeddedPython directory
500-
TArray<FString> matches;
501-
FString dirToFind = TEXT("EmbeddedPython");
502-
IFileManager& fileManager = IFileManager::Get();
503-
fileManager.FindFilesRecursive(matches, *enginePlugins, *dirToFind, false, true, false);
504-
fileManager.FindFilesRecursive(matches, *projectPlugins, *dirToFind, false, true, false);
505-
506-
//If we detected our embedded Python then set the name of the Python interpreter appropriately
507-
if (matches.Num() > 0)
508-
{
509-
//Make sure we use the correct version of the embedded interpreter for the host platform
510-
#if PLATFORM_LINUX
511-
#define _PLATFORM_NAME TEXT("Linux")
512-
#elif PLATFORM_MAC
513-
#define _PLATFORM_NAME TEXT("Mac")
514-
#elif PLATFORM_WINDOWS
515-
#define _PLATFORM_NAME TEXT("Windows")
516-
#else
517-
#define _PLATFORM_NAME TEXT("Unknown")
518-
#endif
519-
FString programName = FPaths::Combine(matches[0], _PLATFORM_NAME, TEXT("bin"), TEXT("python3"));
520-
UE_LOG(LogPython, Log, TEXT("Setting Python program name to %s"), *programName);
521-
#undef _PLATFORM_NAME
522-
523-
//Pass the interpreter path to Python, ensuring the memory containing the string outlives the interpreter
524-
static TUniquePtr<wchar_t, PyMemDeleter> programNamePtr;
525-
programNamePtr.Reset(Py_DecodeLocale(TCHAR_TO_UTF8(*programName), NULL));
526-
Py_SetProgramName(programNamePtr.Get());
527-
}
528-
476+
529477
Py_Initialize();
530478

531479
#if PLATFORM_WINDOWS

‎Source/UnrealEnginePython/UnrealEnginePython.Build.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ public UnrealEnginePython(TargetInfo Target)
258258
// PublicIncludePaths.Add("/usr/include");
259259
// PublicIncludePaths.Add("/home/a/src/deepdrive-sim-2.1/Plugins/UnrealEnginePython/linux/include");
260260
PublicAdditionalLibraries.Add(libsPath);
261-
PublicAdditionalLibraries.AddRange(new string[] { "pthread", "dl", "util", "m" });
262-
RuntimeDependencies.Add(System.IO.Path.Combine(ModuleDirectory, "../../EmbeddedPython/..."), StagedFileType.NonUFS);
261+
263262
}
264263
else
265264
{
@@ -336,7 +335,7 @@ private string DiscoverPythonPath(string[] knownPaths, string binaryPath)
336335
private string DiscoverLinuxPythonIncludesPath()
337336
{
338337
List<string> paths = new List<string>(linuxKnownIncludesPaths);
339-
string projPy35path = Path.Combine(ModuleDirectory, "../../EmbeddedPython/Linux", "include", "python3.6m");
338+
string projPy35path = Path.Combine(ModuleDirectory, "../../linux", "python3.5m", "include");
340339
System.Console.WriteLine("Adding project python include path: " + projPy35path);
341340
paths.Insert(0, projPy35path);
342341
paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", "Linux", "include"));
@@ -355,7 +354,7 @@ private string DiscoverLinuxPythonIncludesPath()
355354
private string DiscoverLinuxPythonLibsPath()
356355
{
357356
List<string> paths = new List<string>(linuxKnownLibsPaths);
358-
string projPy35path = Path.Combine(ModuleDirectory, "../../EmbeddedPython/Linux", "lib", "libpython3.6m.a");
357+
string projPy35path = Path.Combine(ModuleDirectory, "../../linux", "x86_64-linux-gnu", "libpython3.5m.so");
359358
System.Console.WriteLine("Adding project python lib path: " + projPy35path);
360359
paths.Insert(0, projPy35path);
361360
paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", "Linux", "lib"));

‎linux/python3.5m/include/ImDib.h‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* The Python Imaging Library
3+
* $Id$
4+
*
5+
* Windows DIB specifics
6+
*
7+
* Copyright (c) Secret Labs AB 1997-98.
8+
* Copyright (c) Fredrik Lundh 1996.
9+
*
10+
* See the README file for information on usage and redistribution.
11+
*/
12+
13+
#ifdef _WIN32
14+
15+
#include "ImPlatform.h"
16+
17+
#if defined(__cplusplus)
18+
extern "C" {
19+
#endif
20+
21+
struct ImagingDIBInstance {
22+
/* Windows interface */
23+
HDC dc;
24+
HBITMAP bitmap;
25+
HGDIOBJ old_bitmap;
26+
BITMAPINFO *info;
27+
UINT8 *bits;
28+
HPALETTE palette;
29+
/* Used by cut and paste */
30+
char mode[4];
31+
int xsize, ysize;
32+
int pixelsize;
33+
int linesize;
34+
ImagingShuffler pack;
35+
ImagingShuffler unpack;
36+
};
37+
38+
typedef struct ImagingDIBInstance* ImagingDIB;
39+
40+
extern char* ImagingGetModeDIB(int size_out[2]);
41+
42+
extern ImagingDIB ImagingNewDIB(const char *mode, int xsize, int ysize);
43+
44+
extern void ImagingDeleteDIB(ImagingDIB im);
45+
46+
extern void ImagingDrawDIB(ImagingDIB dib, void *dc, int dst[4], int src[4]);
47+
extern void ImagingExposeDIB(ImagingDIB dib, void *dc);
48+
49+
extern int ImagingQueryPaletteDIB(ImagingDIB dib, void *dc);
50+
51+
extern void ImagingPasteDIB(ImagingDIB dib, Imaging im, int xy[4]);
52+
53+
#if defined(__cplusplus)
54+
}
55+
#endif
56+
57+
#endif
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* The Python Imaging Library
3+
* $Id$
4+
*
5+
* platform declarations for the imaging core library
6+
*
7+
* Copyright (c) Fredrik Lundh 1995-2003.
8+
*/
9+
10+
#include "Python.h"
11+
12+
/* Check that we have an ANSI compliant compiler */
13+
#ifndef HAVE_PROTOTYPES
14+
#error Sorry, this library requires support for ANSI prototypes.
15+
#endif
16+
#ifndef STDC_HEADERS
17+
#error Sorry, this library requires ANSI header files.
18+
#endif
19+
20+
#if defined(PIL_NO_INLINE)
21+
#define inline
22+
#else
23+
#if defined(_MSC_VER) && !defined(__GNUC__)
24+
#define inline __inline
25+
#endif
26+
#endif
27+
28+
#ifdef _WIN32
29+
30+
#define WIN32_LEAN_AND_MEAN
31+
#include <Windows.h>
32+
33+
#else
34+
/* For System that are not Windows, we'll need to define these. */
35+
36+
#if SIZEOF_SHORT == 2
37+
#define INT16 short
38+
#elif SIZEOF_INT == 2
39+
#define INT16 int
40+
#else
41+
#define INT16 short /* most things works just fine anyway... */
42+
#endif
43+
44+
#if SIZEOF_SHORT == 4
45+
#define INT32 short
46+
#elif SIZEOF_INT == 4
47+
#define INT32 int
48+
#elif SIZEOF_LONG == 4
49+
#define INT32 long
50+
#else
51+
#error Cannot find required 32-bit integer type
52+
#endif
53+
54+
#if SIZEOF_LONG == 8
55+
#define INT64 long
56+
#elif SIZEOF_LONG_LONG == 8
57+
#define INT64 long
58+
#endif
59+
60+
#define INT8 signed char
61+
#define UINT8 unsigned char
62+
63+
#define UINT16 unsigned INT16
64+
#define UINT32 unsigned INT32
65+
66+
#endif
67+
68+
/* assume IEEE; tweak if necessary (patches are welcome) */
69+
#define FLOAT32 float
70+
#define FLOAT64 double
71+
72+
#ifdef _MSC_VER
73+
typedef signed __int64 int64_t;
74+
#endif
75+
76+
#ifdef __GNUC__
77+
#define GCC_VERSION (__GNUC__ * 10000 \
78+
+ __GNUC_MINOR__ * 100 \
79+
+ __GNUC_PATCHLEVEL__)
80+
#endif

0 commit comments

Comments
 (0)