Skip to content

Commit 42d0140

Browse files
GH-136895: Fixes for pulling LLVM as a release artifact (#141002)
1 parent 9bf5100 commit 42d0140

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

PCbuild/get_external.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import argparse
44
import os
55
import pathlib
6-
import shutil
76
import sys
7+
import tarfile
88
import time
99
import urllib.error
1010
import urllib.request
@@ -56,7 +56,8 @@ def fetch_release(tag, tarball_dir, *, org='python', verbose=False):
5656

5757
def extract_tarball(externals_dir, tarball_path, tag):
5858
output_path = externals_dir / tag
59-
shutil.unpack_archive(os.fspath(tarball_path), os.fspath(output_path))
59+
with tarfile.open(tarball_path) as tf:
60+
tf.extractall(os.fspath(externals_dir))
6061
return output_path
6162

6263

@@ -115,21 +116,23 @@ def main():
115116
verbose=args.verbose,
116117
)
117118
extracted = extract_zip(args.externals_dir, zip_path)
118-
for wait in [1, 2, 3, 5, 8, 0]:
119-
try:
120-
extracted.replace(final_name)
121-
break
122-
except PermissionError as ex:
123-
retry = f" Retrying in {wait}s..." if wait else ""
124-
print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
125-
time.sleep(wait)
126-
else:
127-
print(
128-
f"ERROR: Failed to extract {final_name}.",
129-
"You may need to restart your build",
130-
file=sys.stderr,
131-
)
132-
sys.exit(1)
119+
120+
if extracted != final_name:
121+
for wait in [1, 2, 3, 5, 8, 0]:
122+
try:
123+
extracted.replace(final_name)
124+
break
125+
except PermissionError as ex:
126+
retry = f" Retrying in {wait}s..." if wait else ""
127+
print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
128+
time.sleep(wait)
129+
else:
130+
print(
131+
f"ERROR: Failed to rename {extracted} to {final_name}.",
132+
"You may need to restart your build",
133+
file=sys.stderr,
134+
)
135+
sys.exit(1)
133136

134137

135138
if __name__ == '__main__':

Tools/jit/_llvm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ async def _find_tool(tool: str, llvm_version: str, *, echo: bool = False) -> str
8383
# PCbuild externals:
8484
externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
8585
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
86+
# On Windows, executables need .exe extension
87+
if os.name == "nt" and not path.endswith(".exe"):
88+
path_with_exe = path + ".exe"
89+
if os.path.exists(path_with_exe):
90+
path = path_with_exe
8691
if await _check_tool_version(path, llvm_version, echo=echo):
8792
return path
8893
# Homebrew-installed executables:

0 commit comments

Comments
 (0)