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

Function main

PCbuild/get_external.py:130–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128
129
130def main():
131 args = parse_args()
132 final_name = args.externals_dir / args.tag
133
134 # Check if the dependency already exists in externals/ directory
135 # (either already downloaded/extracted, or checked into the git tree)
136 if final_name.exists():
137 if args.verbose:
138 print(f'{args.tag} already exists at {final_name}, skipping download.')
139 return
140
141 # Determine download method: release artifacts for large deps (like LLVM),
142 # otherwise zip download from GitHub branches
143 if args.release:
144 tarball_path = fetch_release(
145 args.tag,
146 args.externals_dir / 'tarballs',
147 org=args.organization,
148 verbose=args.verbose,
149 )
150 extracted = extract_tarball(args.externals_dir, tarball_path, args.tag)
151 else:
152 # Use zip download from GitHub branches
153 # (cpython-bin-deps if --binary, cpython-source-deps otherwise)
154 zip_path = fetch_zip(
155 args.tag,
156 args.externals_dir / 'zips',
157 org=args.organization,
158 binary=args.binary,
159 verbose=args.verbose,
160 )
161 extracted = extract_zip(args.externals_dir, zip_path)
162
163 if extracted != final_name:
164 for wait in [1, 2, 3, 5, 8, 0]:
165 try:
166 extracted.replace(final_name)
167 break
168 except PermissionError as ex:
169 retry = f" Retrying in {wait}s..." if wait else ""
170 print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
171 time.sleep(wait)
172 else:
173 print(
174 f"ERROR: Failed to rename {extracted} to {final_name}.",
175 "You may need to restart your build",
176 file=sys.stderr,
177 )
178 sys.exit(1)
179
180
181if __name__ == '__main__':

Callers 1

get_external.pyFile · 0.70

Calls 9

fetch_releaseFunction · 0.85
extract_tarballFunction · 0.85
fetch_zipFunction · 0.85
extract_zipFunction · 0.85
parse_argsFunction · 0.70
existsMethod · 0.45
replaceMethod · 0.45
sleepMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…