Skip to content

Commit

Permalink
auto-copy scripts to packaged
Browse files Browse the repository at this point in the history
- copies content/scripts in plugin and project
- copies embedded python if used
  • Loading branch information
getnamo committed Oct 20, 2018
1 parent 106022b commit 26e33dc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
53 changes: 50 additions & 3 deletions Source/UnrealEnginePython/UnrealEnginePython.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
using UnrealBuildTool;
using System.IO;
using System.Collections.Generic;
//using Tools.DotNETCommon;

public class UnrealEnginePython : ModuleRules
{

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

//Or use the one included in third party folder
protected string ThirdPartyPythonHome
//Or use the one included in third party folder
protected string ThirdPartyPythonHome
{
get
{
Expand Down Expand Up @@ -43,7 +45,50 @@ private string BinariesPath
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Binaries/")); }
}

private string[] windowsKnownPaths =
private string ScriptsPath
{
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Content/Scripts/")); }
}

public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target)
{
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
{
RuntimeDependencies.Add(Path.Combine(ScriptsPath, "..."));

if(AutoAddProjectScriptsInPackaging)
{
RuntimeDependencies.Add("$(ProjectDir)/Content/Scripts/...");
}
//Copy binaries as dependencies
if(UseThirdPartyPython)
{
string PlatformString = Target.Platform.ToString();
bool VerboseBuild = false;

//Don't add android stuff so we use a manual method to enum a directory
Tools.DotNETCommon.DirectoryReference BinDir = new Tools.DotNETCommon.DirectoryReference(Path.Combine(BinariesPath, PlatformString, "..."));

if (Tools.DotNETCommon.DirectoryReference.Exists(BinDir))
{
foreach (Tools.DotNETCommon.FileReference File in Tools.DotNETCommon.DirectoryReference.EnumerateFiles(BinDir, "*", SearchOption.AllDirectories))
{
if (!File.ToString().Contains("android"))
{
RuntimeDependencies.Add(File.ToString());
}
else if (VerboseBuild)
{
Log.TraceInformation("Not adding the following file as RuntimeDependency: ");
Log.TraceInformation(File.ToString());
}
}
}
}
}
}

private string[] windowsKnownPaths =
{
"C:/Program Files/Python37",
"C:/Program Files/Python36",
Expand Down Expand Up @@ -247,6 +292,8 @@ public UnrealEnginePython(TargetInfo Target)

string dllPath = Path.Combine(BinariesPath, "Win64", string.Format("{0}.dll", PythonType.ToLower()));
RuntimeDependencies.Add(dllPath);

AddRuntimeDependenciesForCopying(Target);
}
else if (PythonHome == "")
{
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.7.0",
"VersionName": "1.7.1",
"FriendlyName": "UnrealEnginePython",
"Description": "Embed a Python VM in your project",
"Category": "Scripting Languages",
Expand Down

0 comments on commit 26e33dc

Please sign in to comment.