Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good way to flatten a multiple file python program for distribution?

I am writing a console application in python that will consist of a handful of modules, each with a couple hundred lines of code.

For development it would be nice to modularize the program, but for distribution I like the idea of being able to post the program as a single python script.

Are there any good scripts out there for flattening multiple python modules?

I know that eventually I should brave the complicated mess that is setuptools, dpkg, etc... but I'm not ready to invest that effort yet.

like image 484
Andrew Wagner Avatar asked May 22 '26 21:05

Andrew Wagner


1 Answers

A zipfile (with just the .pyc or .pyo files in it, ideally) would suffice, especially if you're distributing code supporting a specific X.Y version of Python (any Z in X.Y.Z will do, i.e., if you support Python 2.6, that will work in 2.6.1, 2.6.2, and so on). Just make the zipfile part of the PYTHONPATH, just as if it was a directory, and you're good to go.

If you support many different Python versions (in the X.Y sense) you can make a zipfile per version, it's still pretty simple.

like image 176
Alex Martelli Avatar answered May 26 '26 06:05

Alex Martelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!