Skip to content

Commit 9b1c863

Browse files
authored
fix: make update-imported-docs.py works on macOS. (#19667)
1 parent 6848ca4 commit 9b1c863

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

update-imported-docs/update-imported-docs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
import subprocess
3434
import sys
3535
import tempfile
36+
import platform
3637

3738
error_msgs = []
3839

3940
# pip should be installed when Python is installed, but just in case...
4041
if not (shutil.which('pip') or shutil.which('pip3')):
41-
error_msgs.append("Install pip so you can install PyYAML. https://pip.pypa.io/en/stable/installing")
42+
error_msgs.append(
43+
"Install pip so you can install PyYAML. https://pip.pypa.io/en/stable/installing")
4244

4345
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
4446
installed_packages = [r.decode().split('==')[0] for r in reqs.split()]
@@ -203,7 +205,9 @@ def main():
203205
# create the temp work_dir
204206
try:
205207
print("Making temp work_dir")
206-
work_dir = tempfile.mkdtemp()
208+
work_dir = tempfile.mkdtemp(
209+
dir='/tmp' if platform.system() == 'Darwin' else tempfile.gettempdir()
210+
)
207211
except OSError as ose:
208212
print("[Error] Unable to create temp work_dir {}; error: {}"
209213
.format(work_dir, ose))

0 commit comments

Comments
 (0)