Skip to content

Commit 049b801

Browse files
committed
copy python plugin dll for packaged builds
1 parent 0c36a2b commit 049b801

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

Source/UnrealEnginePython/UnrealEnginePython.Build.cs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,43 @@ private string ScriptsPath
5050
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Content/Scripts/")); }
5151
}
5252

53+
public string GetUProjectPath()
54+
{
55+
return Path.Combine(ModuleDirectory, "../../../..");
56+
}
57+
58+
private void CopyToProjectBinaries(string Filepath, ReadOnlyTargetRules Target)
59+
{
60+
//System.Console.WriteLine("uprojectpath is: " + Path.GetFullPath(GetUProjectPath()));
61+
62+
string BinariesDir = Path.Combine(GetUProjectPath(), "Binaries", Target.Platform.ToString());
63+
string Filename = Path.GetFileName(Filepath);
64+
65+
//convert relative path
66+
string FullBinariesDir = Path.GetFullPath(BinariesDir);
67+
68+
if (!Directory.Exists(FullBinariesDir))
69+
{
70+
Directory.CreateDirectory(FullBinariesDir);
71+
}
72+
73+
string FullExistingPath = Path.Combine(FullBinariesDir, Filename);
74+
bool ValidFile = false;
75+
76+
//File exists, check if they're the same
77+
if (File.Exists(FullExistingPath))
78+
{
79+
ValidFile = true;
80+
}
81+
82+
//No valid existing file found, copy new dll
83+
if(!ValidFile)
84+
{
85+
File.Copy(Filepath, Path.Combine(FullBinariesDir, Filename), true);
86+
}
87+
}
88+
89+
5390
public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target)
5491
{
5592
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
@@ -88,8 +125,18 @@ public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target)
88125
}
89126
}
90127
}
91-
}
92-
}
128+
129+
//Copy the thirdparty dll so ue4 loads it by default
130+
string DLLName = PythonType.ToLower() + ".dll";
131+
string PluginDLLPath = Path.Combine(BinariesPath, PlatformString, DLLName);
132+
CopyToProjectBinaries(PluginDLLPath, Target);
133+
134+
//After it's been copied add it as a dependency so it gets copied on packaging
135+
string DLLPath = Path.GetFullPath(Path.Combine(GetUProjectPath(), "Binaries", PlatformString, DLLName));
136+
RuntimeDependencies.Add(DLLPath);
137+
138+
}//end if thirdparty
139+
}//end windows
93140
}
94141

95142
private string[] windowsKnownPaths =

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

0 commit comments

Comments
 (0)