Question

I'm planning to package my large python program into a single file;

My requirements are:

  • only 1 file to download
  • file can be checksummed
  • ideally file contains some version info
  • uses system python

so far the best candidates for package format are .egg and .zip.

What are practical differences between eggs and zips?

What I intend to do:

An embedded system downloads my code, e.g. package.zip; it starts my code, e.g. python2 package.zip my code can verify itself, e.g. md5sum sys.argv[0]. Checksum is reported and monitored on my server.

Was it helpful?

Solution

An egg is a zip file.

You'll be able to use the md5sum (or any other hash function) on your file regardless of which method you use to package it - they don't care about the extension of the file, just that the binary contents are the same.

OTHER TIPS

Zipfiles are a bit magical, in that the built-in import will automagically import them. I've never tried importing an egg directly, so I don't know if that will or will not work.

The big boon you get from using eggs is that you can specify dependencies for your package. This may not be a big deal for you. With eggs you setup the requirements, publish to the pypi (if you want), and you've made your users life easier.

Once things are packaged up, pip (http://pypi.python.org/pypi/pip) makes dealing with your package easier. Here are examples of this ripped directly from the pip page -

$ pip install simplejson

$ pip install --upgrade simplejson

$ pip uninstall simplejson

You get a lot of bang from a little work. If you don't want to push your things up to the pypi, you can publish it on your own secret Pypi (read webserver), and specify that pip use a different URL for finding packages.

$ pip install -i http://mycoolserver.com/pypi

I'm no PIP expert, but with easy install (pip's predecessor) you could create your own PYPI pretty easy with Apache. Just publish the pypi directory, and allow it to show indexes (I think thats the right terminology), so that you can browse the file system for the pypi. With this setup, create a directory named after your package and drop your eggs in there. It "just works" (well for me :-))

Edit: I wrote this before you clarified your needs. This does not seem to fit as it doesn't use the systems python executable.

Your question title suggests to me that you want to package it for regular (i.e. non-pythonista) windows end users so that they can just double-click to run it. Py2exe serves exactly this purpose.

I took this assumption because most linux users would expect it to be an archive with a setup.py file, not a single executable. As for Mac OS X, I really don't know.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top