0

First things first, I am still in the process of learning Python (its best-practices and how things work regarding the whole distribution system), so I am NOT an expert.

I need to create a single package containing a specific Python binary (let's say v2.6), a Python script wrote by me and its module dependencies (2 modules -argparse and yaml-).

I want them all packaged for the following reasons :

  • The boxes on which I'll deploy the script don't have the same Python version (ranges from v2.3x to v2.6x)
  • I cannot rely on installing manually the Python modules because they are not always packaged on the repositories
  • I cannot write my code without at least one of the modules because it is needed to parse a YAML file
  • I obviously cannot upgrade Python on all the boxes

What I tried :

  • I used cx_Freeze to create a bundle (containing my script + the argparse and yaml modules) but since some of the methods used throughout the code are not Python2.3-compliant, it refused to run
  • I tried creating a self-executing Python egg but either I did something wrong or I was faced with the same problems as with cx_Freeze

I hope I am not asking for the impossible but, at least, I would like to have some feedbacks about developping Python script on such an heterogeneous environment (Python v2.3 to v2.7) and its dependencies nightmare.

Thank you all in advance.

Regards.

iceman94
  • 129
  • 2
  • 10

1 Answers1

0

It sounds like you need pyinstaller. * Warning * -- I've never used it, but according to the docs, it's super simple:

Goto the directory of your script (assuming it's named myscript.py) and execute these commands: (This is from the doc link above)

pyinstaller myscript.py

PyInstaller analyzes myscript.py and:

Writes myscript.spec in the same folder as the script.
Creates a folder build in the same folder as the script if it does not exist.
Writes some log files and working files in the build folder.
Creates a folder dist in the same folder as the script if it does not exist.
Writes the myscript executable folder in the dist folder.

In the dist folder you find the bundled app you distribute to your users.

jaime
  • 2,234
  • 1
  • 19
  • 22
  • Thanks for the tip. One small detail : it seems you need to build your package on the distro with the lowest version of Python and C library, otherwise you'll run into issues described in this post : http://stackoverflow.com/questions/17654363/pyinstaller-glibc-2-15-not-found – iceman94 Jun 02 '14 at 14:54