mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-136895: Fixes for pulling LLVM as a release artifact (#141002)
This commit is contained in:
parent
9bf5100037
commit
42d0140860
2 changed files with 25 additions and 17 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
|
||||||
import sys
|
import sys
|
||||||
|
import tarfile
|
||||||
import time
|
import time
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
@ -56,7 +56,8 @@ def fetch_release(tag, tarball_dir, *, org='python', verbose=False):
|
||||||
|
|
||||||
def extract_tarball(externals_dir, tarball_path, tag):
|
def extract_tarball(externals_dir, tarball_path, tag):
|
||||||
output_path = externals_dir / tag
|
output_path = externals_dir / tag
|
||||||
shutil.unpack_archive(os.fspath(tarball_path), os.fspath(output_path))
|
with tarfile.open(tarball_path) as tf:
|
||||||
|
tf.extractall(os.fspath(externals_dir))
|
||||||
return output_path
|
return output_path
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -115,21 +116,23 @@ def main():
|
||||||
verbose=args.verbose,
|
verbose=args.verbose,
|
||||||
)
|
)
|
||||||
extracted = extract_zip(args.externals_dir, zip_path)
|
extracted = extract_zip(args.externals_dir, zip_path)
|
||||||
for wait in [1, 2, 3, 5, 8, 0]:
|
|
||||||
try:
|
if extracted != final_name:
|
||||||
extracted.replace(final_name)
|
for wait in [1, 2, 3, 5, 8, 0]:
|
||||||
break
|
try:
|
||||||
except PermissionError as ex:
|
extracted.replace(final_name)
|
||||||
retry = f" Retrying in {wait}s..." if wait else ""
|
break
|
||||||
print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
|
except PermissionError as ex:
|
||||||
time.sleep(wait)
|
retry = f" Retrying in {wait}s..." if wait else ""
|
||||||
else:
|
print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
|
||||||
print(
|
time.sleep(wait)
|
||||||
f"ERROR: Failed to extract {final_name}.",
|
else:
|
||||||
"You may need to restart your build",
|
print(
|
||||||
file=sys.stderr,
|
f"ERROR: Failed to rename {extracted} to {final_name}.",
|
||||||
)
|
"You may need to restart your build",
|
||||||
sys.exit(1)
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,11 @@ async def _find_tool(tool: str, llvm_version: str, *, echo: bool = False) -> str
|
||||||
# PCbuild externals:
|
# PCbuild externals:
|
||||||
externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
|
externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
|
||||||
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
|
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
|
||||||
|
# On Windows, executables need .exe extension
|
||||||
|
if os.name == "nt" and not path.endswith(".exe"):
|
||||||
|
path_with_exe = path + ".exe"
|
||||||
|
if os.path.exists(path_with_exe):
|
||||||
|
path = path_with_exe
|
||||||
if await _check_tool_version(path, llvm_version, echo=echo):
|
if await _check_tool_version(path, llvm_version, echo=echo):
|
||||||
return path
|
return path
|
||||||
# Homebrew-installed executables:
|
# Homebrew-installed executables:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue