Skip to content

Commit

Permalink
Merge pull request #36 from thomasdorch/fix_windows_install
Browse files Browse the repository at this point in the history
fixed 'required privilege' error (1314) on windows
  • Loading branch information
joamatab authored May 8, 2022
2 parents e87dc99 + 22eadbd commit ac82b0b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions install_tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,17 +14,32 @@
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():
print(f"tech already installed in {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}")


Expand All @@ -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__":
Expand Down

0 comments on commit ac82b0b

Please sign in to comment.