Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 26e33dc

Browse files
committed
auto-copy scripts to packaged
- copies content/scripts in plugin and project - copies embedded python if used
1 parent 106022b commit 26e33dc

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

Source/UnrealEnginePython/UnrealEnginePython.Build.cs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
using UnrealBuildTool;
44
using System.IO;
55
using System.Collections.Generic;
6+
//using Tools.DotNETCommon;
67

78
public class UnrealEnginePython : ModuleRules
89
{
910

1011
// leave this string as empty for triggering auto-discovery of python installations...
1112
private string PythonHome = "";
1213
bool UseThirdPartyPython = true; //embedded
14+
bool AutoAddProjectScriptsInPackaging = true;
1315

14-
//Or use the one included in third party folder
15-
protected string ThirdPartyPythonHome
16+
//Or use the one included in third party folder
17+
protected string ThirdPartyPythonHome
1618
{
1719
get
1820
{
@@ -43,7 +45,50 @@ private string BinariesPath
4345
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Binaries/")); }
4446
}
4547

46-
private string[] windowsKnownPaths =
48+
private string ScriptsPath
49+
{
50+
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Content/Scripts/")); }
51+
}
52+
53+
public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target)
54+
{
55+
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
56+
{
57+
RuntimeDependencies.Add(Path.Combine(ScriptsPath, "..."));
58+
59+
if(AutoAddProjectScriptsInPackaging)
60+
{
61+
RuntimeDependencies.Add("$(ProjectDir)/Content/Scripts/...");
62+
}
63+
//Copy binaries as dependencies
64+
if(UseThirdPartyPython)
65+
{
66+
string PlatformString = Target.Platform.ToString();
67+
bool VerboseBuild = false;
68+
69+
//Don't add android stuff so we use a manual method to enum a directory
70+
Tools.DotNETCommon.DirectoryReference BinDir = new Tools.DotNETCommon.DirectoryReference(Path.Combine(BinariesPath, PlatformString, "..."));
71+
72+
if (Tools.DotNETCommon.DirectoryReference.Exists(BinDir))
73+
{
74+
foreach (Tools.DotNETCommon.FileReference File in Tools.DotNETCommon.DirectoryReference.EnumerateFiles(BinDir, "*", SearchOption.AllDirectories))
75+
{
76+
if (!File.ToString().Contains("android"))
77+
{
78+
RuntimeDependencies.Add(File.ToString());
79+
}
80+
else if (VerboseBuild)
81+
{
82+
Log.TraceInformation("Not adding the following file as RuntimeDependency: ");
83+
Log.TraceInformation(File.ToString());
84+
}
85+
}
86+
}
87+
}
88+
}
89+
}
90+
91+
private string[] windowsKnownPaths =
4792
{
4893
"C:/Program Files/Python37",
4994
"C:/Program Files/Python36",
@@ -247,6 +292,8 @@ public UnrealEnginePython(TargetInfo Target)
247292

248293
string dllPath = Path.Combine(BinariesPath, "Win64", string.Format("{0}.dll", PythonType.ToLower()));
249294
RuntimeDependencies.Add(dllPath);
295+
296+
AddRuntimeDependenciesForCopying(Target);
250297
}
251298
else if (PythonHome == "")
252299
{

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.7.0",
4+
"VersionName": "1.7.1",
55
"FriendlyName": "UnrealEnginePython",
66
"Description": "Embed a Python VM in your project",
77
"Category": "Scripting Languages",

0 commit comments

Comments
 (0)