Changeset View
Changeset View
Standalone View
Standalone View
ext/python/Tools/freeze/freeze.py
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | def main(): | ||||
# parse command line by first replacing any "-i" options with the | # parse command line by first replacing any "-i" options with the | ||||
# file contents. | # file contents. | ||||
pos = 1 | pos = 1 | ||||
while pos < len(sys.argv)-1: | while pos < len(sys.argv)-1: | ||||
# last option can not be "-i", so this ensures "pos+1" is in range! | # last option can not be "-i", so this ensures "pos+1" is in range! | ||||
if sys.argv[pos] == '-i': | if sys.argv[pos] == '-i': | ||||
try: | try: | ||||
options = open(sys.argv[pos+1]).read().split() | options = open(sys.argv[pos+1]).read().split() | ||||
except IOError, why: | except IOError as why: | ||||
usage("File name '%s' specified with the -i option " | usage("File name '%s' specified with the -i option " | ||||
"can not be read - %s" % (sys.argv[pos+1], why) ) | "can not be read - %s" % (sys.argv[pos+1], why) ) | ||||
# Replace the '-i' and the filename with the read params. | # Replace the '-i' and the filename with the read params. | ||||
sys.argv[pos:pos+2] = options | sys.argv[pos:pos+2] = options | ||||
pos = pos + len(options) - 1 # Skip the name and the included args. | pos = pos + len(options) - 1 # Skip the name and the included args. | ||||
pos = pos + 1 | pos = pos + 1 | ||||
# Now parse the command line with the extras inserted. | # Now parse the command line with the extras inserted. | ||||
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 as 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': | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | def main(): | ||||
custom_entry_point = None # Currently only used on Windows | custom_entry_point = None # Currently only used on Windows | ||||
python_entry_is_main = 1 # Is the entry point called __main__? | python_entry_is_main = 1 # Is the entry point called __main__? | ||||
# handle -s option on Windows | # handle -s option on Windows | ||||
if win: | if win: | ||||
import winmakemakefile | import winmakemakefile | ||||
try: | try: | ||||
custom_entry_point, python_entry_is_main = \ | custom_entry_point, python_entry_is_main = \ | ||||
winmakemakefile.get_custom_entry_point(subsystem) | winmakemakefile.get_custom_entry_point(subsystem) | ||||
except ValueError, why: | except ValueError as why: | ||||
usage(why) | usage(why) | ||||
# Actual work starts here... | # Actual work starts here... | ||||
# collect all modules of the program | # collect all modules of the program | ||||
dir = os.path.dirname(scriptfile) | dir = os.path.dirname(scriptfile) | ||||
path[0] = dir | path[0] = dir | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |