5

I currently develop an application which is written in C++. For scripting purposes I use Python 3.2, which is fine -- on my developer machine with Python installed and all the DLLs in the right place.

I deployed "pure" Python applications (i.e. without native code) before using the excellent py2exe, but I don't have a first clue how to deploy this with an embedded Python.

From what my gut says I suppose the following components are necessary:

  • Python3.dll & Python32.dll
  • The .pyd files from Python's "DLLs" directory
  • The Python library

And the last point is what bothers me: How do I deploy that? That are a few thousand files and I don't really want to copy that around. Py2exe packs that into a zip-file, I guess I can do something like that in my case too? And, even more important: How do I tell the Python interpreter at run-time where he finds the library?

1

3 Answers 3

4

This has been addressed in the Python 3.5 release which provides a minimum package intended for integration.

https://docs.python.org/3.5/using/windows.html#embedded-distribution

The embedded distribution is a ZIP file containing a minimal Python environment. It is intended for acting as part of another application, rather than being directly accessed by end-users.

A few pointers as to how to actually embed Python into an application (link python3.dll) are given at https://docs.python.org/3/faq/windows.html#how-can-i-embed-python-into-a-windows-application

Sign up to request clarification or add additional context in comments.

Comments

3

From what I recall what you need to bundle depends on what your python scripts call or make use of. If you really only make use of the core intepreter I think you only need to bundle the dll.

Having said that, it shouldn't be too hard to test this on your development box by disabling any paths to your installed python and putting your app and the python dlls and libs into the same test folder.

1 Comment

As space is no concern (yet) I want to ship the entire library. In the mean time I looked around a bit and it seems like Python automagically importing stuff from a ZIP archive when its name is pythonXY.zip (X = major, Y = minor version, so 32 in my case). I'll look into that and then report back here. But it's probably easier anyway to just copy the files unzipped.
0

This site should guide you well. What you're basically doing is compiling the python script to a .exe instead of letting python interpret the .py file each time. It will also be much faster.

1 Comment

It's not an standalone Python application. The application itself is written in C++ and uses Python only for scripting purposes. Thus I actually don't have anything I could create a .exe from, since the user enters some Python code he wants to execute in the context of my C++ application at runtime...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.