55
66# HINTS:
77# - Edit the lines marked XXX below to localize.
8+ # - Make sure the #! line above matches the localizations.
89# - You must have done "make inclinstall libainstall" in the Python
910# build directory.
11+ # - The script name should end in ".py".
1012# - The script should not use dynamically loaded modules
1113# (*.so on most systems).
1214
1315
1416# Usage message
1517
1618usage_msg = """
17- usage: freeze [-p prefix] [-e extension] ... script [module] ...
19+ usage: freeze [-p prefix] [-P exec_prefix] [- e extension] script [module] ...
1820
1921-p prefix: This is the prefix used when you ran
2022 'Make inclinstall libainstall' in the Python build directory.
2123 (If you never ran this, freeze won't work.)
2224 The default is /usr/local.
2325
26+ -P exec_prefix: Like -p but this is the 'exec_prefix', used to
27+ install objects etc. The default is the value for -p.
28+
2429-e extension: A directory containing additional .o files that
2530 may be used to resolve modules. This directory
2631 should also have a Setup file describing the .o files.
2732 More than one -e option may be given.
2833
2934script: The Python script to be executed by the resulting binary.
35+ It *must* end with a .py suffix!
3036
3137module ...: Additional Python modules (referenced by pathname)
3238 that will be included in the resulting binary. These
3339 may be .py or .pyc files.
40+
41+ NOTES:
42+
43+ In order to use freeze successfully, you must have built Python and
44+ installed it. In particular, the following two non-standard make
45+ targets must have been executed:
46+
47+ make inclinstall
48+ make libainstall # Note: 'liba', not 'lib'
49+
50+ The -p and -P options passed into the freeze script must correspond to
51+ the --prefix and --exec-prefix options passed into Python's configure
52+ script.
3453"""
3554
3655
4059# XXX Change the following line to point to your install prefix
4160PREFIX = '/usr/local'
4261
62+ # XXX Change the following line to point to your install exec_prefix
63+ EXEC_PREFIX = None # If None, use -p option for default
64+
4365
4466# Import standard modules
4567
7698def main ():
7799 # overridable context
78100 prefix = PREFIX # settable with -p option
101+ exec_prefix = None # settable with -P option
79102 extensions = []
80103 path = sys .path
81104
@@ -87,7 +110,7 @@ def main():
87110
88111 # parse command line
89112 try :
90- opts , args = getopt .getopt (sys .argv [1 :], 'e:p:' )
113+ opts , args = getopt .getopt (sys .argv [1 :], 'e:p:P: ' )
91114 except getopt .error , msg :
92115 usage ('getopt error: ' + str (msg ))
93116
@@ -97,24 +120,34 @@ def main():
97120 extensions .append (a )
98121 if o == '-p' :
99122 prefix = a
123+ if o == '-P' :
124+ exec_prefix = a
125+
126+ # default exec_prefix
127+ if exec_prefix is None :
128+ exec_prefix = EXEC_PREFIX
129+ if exec_prefix is None :
130+ exec_prefix = prefix
100131
101132 # locations derived from options
102- binlib = os .path .join (prefix , 'lib/python/lib' )
133+ binlib = os .path .join (exec_prefix , 'lib/python/lib' )
103134 incldir = os .path .join (prefix , 'include/Py' )
104135 config_c_in = os .path .join (binlib , 'config.c.in' )
105136 frozenmain_c = os .path .join (binlib , 'frozenmain.c' )
137+ getpath_c = os .path .join (binlib , 'getpath.c' )
138+ supp_sources = [frozenmain_c , getpath_c ]
106139 makefile_in = os .path .join (binlib , 'Makefile' )
107- defines = ['-DHAVE_CONFIG_H' , '-DUSE_FROZEN' , '-DNO_MAIN' ,
140+ defines = ['-DHAVE_CONFIG_H' ,
108141 '-DPYTHONPATH=\\ "$(PYTHONPATH)\\ "' ]
109142 includes = ['-I' + incldir , '-I' + binlib ]
110143
111144 # sanity check of directories and files
112- for dir in [prefix , binlib , incldir ] + extensions :
145+ for dir in [prefix , exec_prefix , binlib , incldir ] + extensions :
113146 if not os .path .exists (dir ):
114147 usage ('needed directory %s not found' % dir )
115148 if not os .path .isdir (dir ):
116149 usage ('%s: not a directory' % dir )
117- for file in config_c_in , makefile_in , frozenmain_c :
150+ for file in [ config_c_in , makefile_in ] + supp_sources :
118151 if not os .path .exists (file ):
119152 usage ('needed file %s not found' % file )
120153 if not os .path .isfile (file ):
@@ -153,6 +186,11 @@ def main():
153186 # Actual work starts here...
154187
155188 dict = findmodules .findmodules (scriptfile , modules , path )
189+ names = dict .keys ()
190+ names .sort ()
191+ print "Modules being frozen:"
192+ for name in names :
193+ print '\t ' , name
156194
157195 backup = frozen_c + '~'
158196 try :
@@ -223,8 +261,8 @@ def main():
223261 somevars [key ] = makevars [key ]
224262
225263 somevars ['CFLAGS' ] = string .join (cflags ) # override
226- files = ['$(OPT)' , config_c , frozen_c , frozenmain_c ] + \
227- addfiles + libs + \
264+ files = ['$(OPT)' , config_c , frozen_c ] + \
265+ supp_sources + addfiles + libs + \
228266 ['$(MODLIBS)' , '$(LIBS)' , '$(SYSLIBS)' ]
229267
230268 backup = makefile + '~'
0 commit comments