20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.77k stars 754 forks source link

Embedding Python in Packaged Project #418

Open thegiffman opened 6 years ago

thegiffman commented 6 years ago

Hi - thanks for all your hard work on this plugin!

I'm trying to embed python for a UE4 app to be used at runtime, and it doesn't seem to be doing it by default. I try running the main executable (WindowsNoEditor/[ProjectName].exe) and get an error about not being able to find the python dll. If I unzip the embedded Python distribution (python-3.6.5-embed-amd64.zip) to the binary folder of the already packaged build (WindowsNoEditor/[ProjectName]/Binaries/Win64), then the main executable will run just fine. However, this requires a manual second step after packaging, which isn't really good for our development pipeline. Is there any way to get the packaging system to add the embedded python distribution by default, for use at runtime? The documentation wasn't terribly clear on this point.

Remember that unless you add an embedded python in your final build, the final users of your project will require python installed in his/her system.

OK, but how do I do that?

When you package your projects, remember to include the libpython (dll or dylib or .so based on your operating system) in the binaries folder and the Scripts directory (if you do not want to force the user to have python installed in its system). For Windows system you can use the embedded distributions available in the official python.org site. Just uncompress the zip in the plugin binary folder (at the same level of UnrealEnginePython.dll)

OK, I uncompressed the python embedded distribution zip into the plugin binary folder, but that didn't do anything when the app was packaged. The only solution was to manually copy the files as described above, but this is not automated. Any advice?

getnamo commented 6 years ago

see: https://wiki.unrealengine.com/How_To_Package_Extra_NonUASSET_Files_With_Your_Game and I believe there are also ways to do copies via build.cs so you could move them to e.g. project folders for packaging