views:

427

answers:

4

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.

+8  A: 

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

Jason Baker
This not work for me, because is a important part of the product the ability to create plugins in python. Think like if my app is apache and anybody can build their website in python or php.
mamcx
+5  A: 

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

cjrh
+4  A: 

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.

cjrh
+1  A: 

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.

Eli Bendersky
mamcx
I don't understand the context of the comment, mamcx. You can surely use py2exe for all platforms, and the .py plugins need not change.
Eli Bendersky
According to the website of py2exe is only for windows... or I miss something?
mamcx
mamcx, you're right. Then use http://www.pyinstaller.org/ (the first one I mentioned, accidentally, because this is what I use for my code)
Eli Bendersky