forked from iqm-finland/KQCircuits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startkl.py
executable file
·45 lines (37 loc) · 1.85 KB
/
startkl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
# This code is part of KQCircuits
# Copyright (C) 2022 IQM Finland Oy
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see
# https://www.gnu.org/licenses/gpl-3.0.html.
#
# The software distribution should follow IQM trademark policy for open-source software
# (meetiqm.com/developers/osstmpolicy). IQM welcomes contributions to the code. Please see our contribution agreements
# for individuals (meetiqm.com/developers/clas/individual) and organizations (meetiqm.com/developers/clas/organization).
# Starts KLayout with KQCircuits configured in this directory. Force edit mode.
import os
import sys
import subprocess
from kqcircuits.defaults import ROOT_PATH
sys.path.append(str(ROOT_PATH))
from setup_helper import klayout_configdir
configdir = klayout_configdir(ROOT_PATH)
if not os.path.exists(f"{configdir}/python/kqcircuits"):
print("Not configured? Please run setup_within_klayout.py first.")
sys.exit(-1)
startupinfo = None
if os.name == "nt":
exe = os.path.join(os.getenv("APPDATA"), "KLayout", "klayout_app.exe")
exe = f'set "KLAYOUT_HOME={configdir}" & "{exe}"'
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
else:
exe = f'KLAYOUT_HOME={configdir} klayout'
subprocess.run(f'{exe} -e', shell=True, check=True, startupinfo=startupinfo)