How to deploy Python to Windows users?

23,322

Solution 1

Copy a Portable Python folder out of your installer, into the same folder as your Delphi/Lazarus app. Set all paths appropriately for that.

Solution 2

You might try using py2exe. It creates a .exe file with Python already included!

Solution 3

Integrate the python interpreter into your Delphi app with P4D. These components actually work, and in both directions too (Delphi classes exposed to Python as binary extensions, and Python interpreter inside Delphi). I also saw a patch for Lazarus compatibility on the Google Code "issues" page, but it seems there might be some unresolved issues there.

Solution 4

I think there's no problem combining .EXE packaging with a tool like PyInstaller or py2exe and Python-written plugins. The created .EXE can easily detect where it's installed and the code inside can then simply import files from some pre-determined plugin directory. Don't forget that once you package a Python script into an executable, it also packages the Python interpreter inside, so there you have it - a full Python environment customized with your own code.

Share:
23,322
mamcx
Author by

mamcx

CEO & Developer of "El malabarista", maker of the POS for the iPhone BestSeller. 12+ years of experience creating software in use for more than +2000 users in my country. Experience in Python, Django, Web apps, APIs, .NET, Objective-C, iPhone/iPad development, RemObjects & more. CV: http://careers.stackoverflow.com/cv/employer/20796

Updated on July 28, 2022

Comments

  • mamcx
    mamcx almost 2 years

    I'm soon to launch a beta app and this have the option to create custom integration scripts on Python.

    The app will target Mac OS X and Windows, and my problem is with Windows where Python normally is not present.

    My actual aproach is silently run the Python 2.6 install. However I face the problem that is not activated by default and the path is not set when use the command line options. And I fear that if Python is installed before and I upgrade to a new version this could break something else...

    So, I wonder how this can be done cleanly. Is it OK if I copy the whole Python 2.6 directory, and put it in a sub-directory of my app and install everything there? Or with virtualenv is posible run diferents versions of Python (if Python is already installed in the machine?).

    I also play before embedding Python with a DLL, and found it easy but I lost the ability to debug, so I switch to command-line plug-ins.

    I execute the plug-ins from command line and read the STDOUT and STDERR output. The app is made with Delphi/Lazarus. I install others modules like JSON and RPC clients, Win32com, ORM, etc. I create the installer with bitrock.

    UPDATE: The end-users are small business owners, and the Python scripts are made by developers. I want to avoid any additional step in the deployment, so I want a fully integrated setup.