-
Notifications
You must be signed in to change notification settings - Fork 3
/
reveda.py
125 lines (106 loc) · 4.47 KB
/
reveda.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# “Commons Clause” License Condition v1.0
# #
# The Software is provided to you by the Licensor under the License, as defined
# below, subject to the following condition.
#
# Without limiting other conditions in the License, the grant of rights under the
# License will not include, and the License does not grant to you, the right to
# Sell the Software.
#
# For purposes of the foregoing, “Sell” means practicing any or all of the rights
# granted to you under the License to provide to third parties, for a fee or other
# consideration (including without limitation fees for hosting or consulting/
# support services related to the Software), a product or service whose value
# derives, entirely or substantially, from the functionality of the Software. Any
# license notice or attribution required by the License must also include this
# Commons Clause License Condition notice.
#
# Add-ons and extensions developed for this software may be distributed
# under their own separate licenses.
#
# Software: Revolution EDA
# License: Mozilla Public License 2.0
# Licensor: Revolution Semiconductor (Registered in the Netherlands)
#
# The PySide6 plugin covers qt-plugins
# nuitka project: --include-plugin-directory=revedaEditor
# nuitka-project: --enable-plugin=pyside6
# nuitka-project --product-version=0.7.2
import os
import platform
import sys
from PySide6.QtWidgets import QApplication
import revedaEditor.gui.revedaMain as rvm
import revedaEditor.gui.pythonConsole as pcon
from contextlib import redirect_stdout, redirect_stderr
from dotenv import load_dotenv
from pathlib import Path
import cProfile
import pstats
from pstats import SortKey
class revedaApp(QApplication):
"""
Initializes the class instance and sets the paths to the revedaeditor and revedasim if the corresponding
environment variables exist. Also adds the paths to the system path if available.
Returns:
None
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Load environment variables
self.revedaeditor_pathObj = None
self.revedasim_pathObj = None
load_dotenv()
reveda_runpathObj = Path(__file__).resolve().parent
self.revedaeditor_path = None
self.revedasim_path = None
self.reveda_pdk_path = None
self.setPaths(reveda_runpathObj)
def setPaths(self, reveda_runpathObj):
# Set the paths to the revedaeditor and revedasim
self.revedaeditor_path = os.environ.get("REVEDAEDIT_PATH", None)
if self.revedaeditor_path:
if Path(self.revedaeditor_path).is_absolute():
self.revedaeditor_pathObj = Path(self.revedaeditor_path)
else:
self.revedaeditor_pathObj = reveda_runpathObj.joinpath(
self.revedaeditor_path
)
self.revedasim_path = os.environ.get("REVEDASIM_PATH", None)
if self.revedasim_path:
if Path(self.revedasim_path).is_absolute():
self.revedasim_pathObj = Path(self.revedasim_path)
else:
self.revedasim_pathObj = reveda_runpathObj.joinpath(self.revedasim_path)
sys.path.append(str(self.revedasim_pathObj))
self.reveda_pdk_path = os.environ.get("REVEDA_PDK_PATH", None)
if self.reveda_pdk_path:
if Path(self.reveda_pdk_path).is_absolute():
self.reveda_pdk_pathObj = Path(self.reveda_pdk_path)
else:
self.reveda_pdk_pathObj = reveda_runpathObj.joinpath(self.reveda_pdk_path)
sys.path.append(str(self.reveda_pdk_pathObj))
def main():
# Start Main application window
app = revedaApp(sys.argv)
os_name = platform.system()
if os_name == "Windows":
app.setStyle("Windows")
elif os_name == "Linux":
app.setStyle("Breeze")
elif os_name == "Darwin": # macOS
app.setStyle("macOS")
mainW = rvm.MainWindow()
mainW.setWindowTitle("Revolution EDA")
# empty argument as there is no parent window.
redirect = pcon.Redirect(mainW.centralW.console.errorwrite)
with redirect_stdout(mainW.centralW.console), redirect_stderr(redirect):
mainW.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()
# cProfile.run('main()', 'output.prof')
#
# # Print the 20 lines that took the most cumulative time
# p = pstats.Stats('output.prof')
# p.strip_dirs().sort_stats(SortKey.CUMULATIVE).print_stats(20)