Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining module files in Python

Is there a way to put together Python files, akin to JAR in Java? I need a way of packaging set of Python classes and functions, but unlike a standard module, I'd like it to be in one file.

like image 364
c4757p Avatar asked Jul 09 '09 13:07

c4757p


2 Answers

After looking for a solution to the same problem, I ended up writing a simple tool which combines multiple .py files into one: PyBreeder

It will only work with pure-Python modules and may require some trial-and-error to get the order of modules right, but it is quite handy whenever you want to deploy a script with some dependencies as a single .py. Comments/patches/critique are very welcome!

like image 108
Bjarni R. Einasson Avatar answered Sep 18 '22 23:09

Bjarni R. Einasson


Take a look at Python Eggs: http://peak.telecommunity.com/DevCenter/PythonEggs

Or, you can use regular zips: http://docs.python.org/library/zipimport.html

like image 45
mthurlin Avatar answered Sep 21 '22 23:09

mthurlin