scripts: Install IREE python tool in cache instead of at $HOME Change-Id: Iab99b76432a0bf0a5f31e0accd09f787824f911e
diff --git a/download_iree_compiler.py b/download_iree_compiler.py index 3be06a8..3c45055 100755 --- a/download_iree_compiler.py +++ b/download_iree_compiler.py
@@ -1,6 +1,7 @@ #!/usr/bin/env python3 """Download IREE host compiler from the snapshot release.""" +import errno import os import sys import tarfile @@ -111,7 +112,8 @@ snapshot["assets"], ["linux-x86_64.tar"], tmp_dir) # Install IREE TFLite tool - cmd = (f"pip3 install {whl_file} --no-cache-dir") + cmd = (f"pip3 install --target={iree_compiler_dir} {whl_file} " + "--upgrade --no-cache-dir") os.system(cmd) # Extract the tarball to ${iree_compiler_dir}/install @@ -122,6 +124,15 @@ with tarfile.open(tar_file) as tar: tar.extractall(path=install_dir) + try: + os.symlink(f"{iree_compiler_dir}/bin/iree-import-tflite", + f"{install_dir}/bin/iree-import-tflite") + except OSError as e: + if e.errno == errno.EEXIST: + os.remove(f"{install_dir}/bin/iree-import-tflite") + os.symlink(f"{iree_compiler_dir}/bin/iree-import-tflite", + f"{install_dir}/bin/iree-import-tflite") + os.remove(tar_file) os.remove(whl_file) print("\nIREE compiler is installed")