MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Tools/freeze/freeze.py:111–482  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109# Main program
110
111def main():
112 # overridable context
113 prefix = None # settable with -p option
114 exec_prefix = None # settable with -P option
115 extensions = []
116 exclude = [] # settable with -x option
117 addn_link = [] # settable with -l, but only honored under Windows.
118 path = sys.path[:]
119 modargs = 0
120 debug = 1
121 odir = ''
122 win = sys.platform[:3] == 'win'
123 replace_paths = [] # settable with -r option
124 error_if_any_missing = 0
125
126 # default the exclude list for each platform
127 if win: exclude = exclude + [
128 'dos', 'dospath', 'mac', 'macfs', 'MACFS', 'posix', ]
129
130 fail_import = exclude[:]
131
132 # output files
133 frozen_c = 'frozen.c'
134 config_c = 'config.c'
135 target = 'a.out' # normally derived from script name
136 makefile = 'Makefile'
137 subsystem = 'console'
138
139 if sys.platform == "darwin" and sysconfig.get_config_var("PYTHONFRAMEWORK"):
140 print(f"{sys.argv[0]} cannot be used with framework builds of Python", file=sys.stderr)
141 sys.exit(1)
142
143
144 # parse command line by first replacing any "-i" options with the
145 # file contents.
146 pos = 1
147 while pos < len(sys.argv)-1:
148 # last option can not be "-i", so this ensures "pos+1" is in range!
149 if sys.argv[pos] == '-i':
150 try:
151 with open(sys.argv[pos+1]) as infp:
152 options = infp.read().split()
153 except IOError as why:
154 usage("File name '%s' specified with the -i option "
155 "can not be read - %s" % (sys.argv[pos+1], why) )
156 # Replace the '-i' and the filename with the read params.
157 sys.argv[pos:pos+2] = options
158 pos = pos + len(options) - 1 # Skip the name and the included args.
159 pos = pos + 1
160
161 # Now parse the command line with the extras inserted.
162 try:
163 opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:qs:wX:x:l:')
164 except getopt.error as msg:
165 usage('getopt error: ' + str(msg))
166
167 # process option arguments
168 for o, a in opts:

Callers 1

freeze.pyFile · 0.70

Calls 15

add_moduleMethod · 0.95
import_hookMethod · 0.95
load_fileMethod · 0.95
run_scriptMethod · 0.95
reportMethod · 0.95
any_missingMethod · 0.95
strFunction · 0.85
splitextMethod · 0.80
openFunction · 0.70
usageFunction · 0.70
exitMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…