views:

103

answers:

3

So I have a python script that relies on a couple modules. Specifically pexpect and pyinoitify. I know you can compile a python script into a .exe in windows, but is there something relatively equivalent in linux? I don't care about it being a binary, I'd just like to be able to distribute my script without requiring the separate installation of pexpect and pyinotify. Is that possible/worthwhile?

A: 

Generally, if the first line is

#!/usr/bin/env python

And the file has "x" mode set (chmod +x yourfile.py)

Then it's executable. No compiling required.

And yes, folks have to install the things on which you depend. It's (a) simpler and (b) less surprising if they actually do the installation, so they know what's really going on.

S.Lott
The question is about distributing the script along with its dependencies, not just executing it.
katrielalex
+1  A: 

cx_Freeze is a cross-platform way to "freeze" a Python script into standalone binary form. According to their site:

cx_Freeze is a set of scripts and modules for freezing Python scripts into executables in much the same way that py2exe and py2app do. Unlike these two tools, cx_Freeze is cross platform and should work on any platform that Python itself works on. It requires Python 2.3 or higher since it makes use of the zip import facility which was introduced in that version.

katrielalex
A: 

In linux, try to avoid such things. Most package managers handle dependencies quite fine, just distribute your script and tell what dependencies it needs.

maroxe
What does a package manager have to do with python modules?
Falmarri