Changeset View
Changeset View
Standalone View
Standalone View
ext/python/Tools/freeze/freeze.py
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | def main(): | ||||
try: | try: | ||||
opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:b:qs:wX:x:l:') | opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:b:qs:wX:x:l:') | ||||
except getopt.error, msg: | except getopt.error, msg: | ||||
usage('getopt error: ' + str(msg)) | usage('getopt error: ' + str(msg)) | ||||
# process option arguments | # process option arguments | ||||
for o, a in opts: | for o, a in opts: | ||||
if o == '-h': | if o == '-h': | ||||
print __doc__ | print(__doc__) | ||||
return | return | ||||
if o == '-b': | if o == '-b': | ||||
binlib = a | binlib = a | ||||
if o == '-d': | if o == '-d': | ||||
debug = debug + 1 | debug = debug + 1 | ||||
if o == '-e': | if o == '-e': | ||||
extensions.append(a) | extensions.append(a) | ||||
if o == '-m': | if o == '-m': | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def main(): | ||||
# determine whether -p points to the Python source tree | # determine whether -p points to the Python source tree | ||||
ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) | ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) | ||||
# locations derived from options | # locations derived from options | ||||
version = sys.version[:3] | version = sys.version[:3] | ||||
if win: | if win: | ||||
extensions_c = 'frozen_extensions.c' | extensions_c = 'frozen_extensions.c' | ||||
if ishome: | if ishome: | ||||
print "(Using Python source directory)" | print("(Using Python source directory)") | ||||
binlib = exec_prefix | binlib = exec_prefix | ||||
incldir = os.path.join(prefix, 'Include') | incldir = os.path.join(prefix, 'Include') | ||||
config_h_dir = exec_prefix | config_h_dir = exec_prefix | ||||
config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') | config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') | ||||
frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') | frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') | ||||
makefile_in = os.path.join(exec_prefix, 'Makefile') | makefile_in = os.path.join(exec_prefix, 'Makefile') | ||||
if win: | if win: | ||||
frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') | frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | def main(): | ||||
# handle -o option | # handle -o option | ||||
base_frozen_c = frozen_c | base_frozen_c = frozen_c | ||||
base_config_c = config_c | base_config_c = config_c | ||||
base_target = target | base_target = target | ||||
if odir and not os.path.isdir(odir): | if odir and not os.path.isdir(odir): | ||||
try: | try: | ||||
os.mkdir(odir) | os.mkdir(odir) | ||||
print "Created output directory", odir | print("Created output directory", odir) | ||||
except os.error, msg: | except os.error, msg: | ||||
usage('%s: mkdir failed (%s)' % (odir, str(msg))) | usage('%s: mkdir failed (%s)' % (odir, str(msg))) | ||||
base = '' | base = '' | ||||
if odir: | if odir: | ||||
base = os.path.join(odir, '') | base = os.path.join(odir, '') | ||||
frozen_c = os.path.join(odir, frozen_c) | frozen_c = os.path.join(odir, frozen_c) | ||||
config_c = os.path.join(odir, config_c) | config_c = os.path.join(odir, config_c) | ||||
target = os.path.join(odir, target) | target = os.path.join(odir, target) | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def main(): | ||||
# Add the main script as either __main__, or the actual module name. | # Add the main script as either __main__, or the actual module name. | ||||
if python_entry_is_main: | if python_entry_is_main: | ||||
mf.run_script(scriptfile) | mf.run_script(scriptfile) | ||||
else: | else: | ||||
mf.load_file(scriptfile) | mf.load_file(scriptfile) | ||||
if debug > 0: | if debug > 0: | ||||
mf.report() | mf.report() | ||||
print() | |||||
dict = mf.modules | dict = mf.modules | ||||
if error_if_any_missing: | if error_if_any_missing: | ||||
missing = mf.any_missing() | missing = mf.any_missing() | ||||
if missing: | if missing: | ||||
sys.exit("There are some missing modules: %r" % missing) | sys.exit("There are some missing modules: %r" % missing) | ||||
# generate output for frozen modules | # generate output for frozen modules | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | def main(): | ||||
try: | try: | ||||
makemakefile.makemakefile(outfp, somevars, files, base_target) | makemakefile.makemakefile(outfp, somevars, files, base_target) | ||||
finally: | finally: | ||||
outfp.close() | outfp.close() | ||||
# Done! | # Done! | ||||
if odir: | if odir: | ||||
print 'Now run "make" in', odir, | print('Now run "make" in', odir, end=' ') | ||||
print 'to build the target:', base_target | print('to build the target:', base_target) | ||||
else: | else: | ||||
print 'Now run "make" to build the target:', base_target | print('Now run "make" to build the target:', base_target) | ||||
# Print usage message and exit | # Print usage message and exit | ||||
def usage(msg): | def usage(msg): | ||||
sys.stdout = sys.stderr | sys.stdout = sys.stderr | ||||
print "Error:", msg | print("Error:", msg) | ||||
print "Use ``%s -h'' for help" % sys.argv[0] | print("Use ``%s -h'' for help" % sys.argv[0]) | ||||
sys.exit(2) | sys.exit(2) | ||||
main() | main() |