File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ """
3+ Wrap Python module into executable .zip file
4+
5+ Public domain work by:
6+ anatoly techtonik <techtonik@gmail.com>
7+ """
8+ import os
9+ import sys
10+
11+ def get_version (path ):
12+ '''Read version info from a file without importing it'''
13+ for line in open (path , 'rb' ):
14+ # Decode to unicode for PY2/PY3 in a fail-safe way
15+ line = line .decode ('cp437' )
16+ if '__version__' in line :
17+ # __version__ = "0.9"
18+ return line .split ('"' )[1 ]
19+
20+
21+ if not sys .argv [1 :]:
22+ sys .exit ("usage: pack.py <module.py>" )
23+
24+ modpath = sys .argv [1 ]
25+ modname = os .path .basename (modpath )
26+ version = get_version (modpath )
27+ packname = modname + "-" + version + ".zip"
28+ print ("[*] Packing %s into %s" % (modpath , packname ))
29+
You can’t perform that action at this time.
0 commit comments