diff --git a/install_tech.py b/install_tech.py index 14e6c318..9f5cd1d1 100644 --- a/install_tech.py +++ b/install_tech.py @@ -3,6 +3,7 @@ import os import pathlib import sys +import subprocess klayout_folder = "KLayout" if sys.platform == "win32" else ".klayout" cwd = pathlib.Path(__file__).resolve().parent @@ -13,6 +14,20 @@ dest = dest_folder / "ubcpdk" +def make_link(src, dest): + try: + os.symlink(src, dest) + except OSError as err: + print("Could not create symlink!") + print(" Error: ", err) + if sys.platform == "win32": + # https://stackoverflow.com/questions/32877260/privlege-error-trying-to-create-symlink-using-python-on-windows-10 + print("Trying to create a junction instead of a symlink...") + proc = subprocess.check_call(f"mklink /J {dest} {src}", shell=True) + if proc != 0: + print("Could not create link!") + + def install_tech(src, dest): """Installs tech.""" if dest.exists(): @@ -20,10 +35,11 @@ def install_tech(src, dest): return try: - os.symlink(src, dest) + make_link(src, dest) except Exception: os.remove(dest) - os.symlink(src, dest) + make_link(src, dest) + print(f"layermap installed to {dest}") @@ -36,11 +52,12 @@ def install_drc(src, dest): dest_folder = dest.parent dest_folder.mkdir(exist_ok=True, parents=True) try: - os.symlink(src, dest) + make_link(src, dest) except Exception: os.remove(dest) - os.symlink(src, dest) - print(f"layermap installed to {dest}") + make_link(src, dest) + + print(f"drc installed to {dest}") if __name__ == "__main__":