summaryrefslogtreecommitdiffstats
path: root/Tools/freeze/freeze.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-03-20 20:43:34 (GMT)
committerGuido van Rossum <guido@python.org>2001-03-20 20:43:34 (GMT)
commit6b767ac81aba6e51f9a84efe44d31a1db1e1edba (patch)
treec22c5455415a6f1e2b1b1757ac90aa271bd34ced /Tools/freeze/freeze.py
parentb845cb0946a278a1f4bf5710d471b90a18e688d5 (diff)
downloadcpython-6b767ac81aba6e51f9a84efe44d31a1db1e1edba.zip
cpython-6b767ac81aba6e51f9a84efe44d31a1db1e1edba.tar.gz
cpython-6b767ac81aba6e51f9a84efe44d31a1db1e1edba.tar.bz2
Lawrence Hudson, SF #401702: Modify co_filename in frozen programs
This patch was developed primarily to reduce the size of the frozen binary. It is particularly useful when freezing for 'small' platforms, such as Palm OS, where you really want to save that last miserable byte. A limitation of this patch is that it does not provide any feedback about the replacements being made. As the path matching is case-sensitive this may lead to unexpected behaviour for DOS and Windows people, eg > freeze.py -r C:\Python\Lib\=py\ goats.py should probably be: > freeze.py -r c:\python\lib\=py\ goats.py
Diffstat (limited to 'Tools/freeze/freeze.py')
-rwxr-xr-xTools/freeze/freeze.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index eea8134..dfd0369 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -57,6 +57,10 @@ Options:
(For debugging only -- on a win32 platform, win32 behavior
is automatic.)
+-r prefix=f: Replace path prefix.
+ Replace prefix with f in the source path references
+ contained in the resulting binary.
+
Arguments:
script: The Python script to be executed by the resulting binary.
@@ -109,6 +113,7 @@ def main():
debug = 1
odir = ''
win = sys.platform[:3] == 'win'
+ replace_paths = [] # settable with -r option
# default the exclude list for each platform
if win: exclude = exclude + [
@@ -139,7 +144,7 @@ def main():
# Now parse the command line with the extras inserted.
try:
- opts, args = getopt.getopt(sys.argv[1:], 'a:de:hmo:p:P:qs:wx:l:')
+ opts, args = getopt.getopt(sys.argv[1:], 'r:a:de:hmo:p:P:qs:wx:l:')
except getopt.error, msg:
usage('getopt error: ' + str(msg))
@@ -174,6 +179,9 @@ def main():
addn_link.append(a)
if o == '-a':
apply(modulefinder.AddPackagePath, tuple(string.split(a,"=", 2)))
+ if o == '-r':
+ f,r = string.split(a,"=", 2)
+ replace_paths.append( (f,r) )
# default prefix and exec_prefix
if not exec_prefix:
@@ -310,7 +318,7 @@ def main():
# collect all modules of the program
dir = os.path.dirname(scriptfile)
path[0] = dir
- mf = modulefinder.ModuleFinder(path, debug, exclude)
+ mf = modulefinder.ModuleFinder(path, debug, exclude, replace_paths)
if win and subsystem=='service':
# If a Windows service, then add the "built-in" module.