diff --git a/CMakeLists.txt b/CMakeLists.txt index 40102d99..0b09d292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ protobuf_generate( #_____________________________________________________________________________________________ -set(PROTOBUF_PYTHON_GENERATED "${CMAKE_CURRENT_LIST_DIR}/build/python_kpex_protobuf") +set(PROTOBUF_PYTHON_GENERATED "${CMAKE_CURRENT_LIST_DIR}/build/python/klayout_pex_protobuf") file(MAKE_DIRECTORY "${PROTOBUF_PYTHON_GENERATED}") protobuf_generate( diff --git a/klayout_pex/fastcap/__init__.py b/klayout_pex/fastcap/__init__.py new file mode 100644 index 00000000..73952843 --- /dev/null +++ b/klayout_pex/fastcap/__init__.py @@ -0,0 +1,23 @@ +# +# -------------------------------------------------------------------------------- +# SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl +# Johannes Kepler University, Institute for Integrated Circuits. +# +# This file is part of KPEX +# (see https://github.com/martinjankoehler/klayout-pex). +# +# 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 . +# SPDX-License-Identifier: GPL-3.0-or-later +# -------------------------------------------------------------------------------- +# diff --git a/klayout_pex/fastcap/fastcap_runner.py b/klayout_pex/fastcap/fastcap_runner.py index 870bbbd6..4c5c2b0f 100644 --- a/klayout_pex/fastcap/fastcap_runner.py +++ b/klayout_pex/fastcap/fastcap_runner.py @@ -28,7 +28,7 @@ import os import subprocess -from kpex.log import ( +from ..log import ( debug, info, warning, @@ -36,7 +36,7 @@ rule, subproc, ) -from kpex.common.capacitance_matrix import CapacitanceMatrix +from ..common.capacitance_matrix import CapacitanceMatrix def run_fastcap(exe_path: str, diff --git a/klayout_pex/fastercap/fastercap_input_builder.py b/klayout_pex/fastercap/fastercap_input_builder.py index c20bef6d..70cf51ef 100644 --- a/klayout_pex/fastercap/fastercap_input_builder.py +++ b/klayout_pex/fastercap/fastercap_input_builder.py @@ -46,7 +46,7 @@ ) from ..tech_info import TechInfo -import process_stack_pb2 +import klayout_pex_protobuf.process_stack_pb2 class FasterCapInputBuilder: diff --git a/klayout_pex/fastercap/fastercap_model_generator.py b/klayout_pex/fastercap/fastercap_model_generator.py index 902625d3..1a4da99e 100644 --- a/klayout_pex/fastercap/fastercap_model_generator.py +++ b/klayout_pex/fastercap/fastercap_model_generator.py @@ -71,7 +71,7 @@ import klayout.db as kdb -from kpex.log import ( +from ..log import ( debug, info, warning, diff --git a/klayout_pex/fastercap/fastercap_runner.py b/klayout_pex/fastercap/fastercap_runner.py index 31f32855..1ff3d0e2 100644 --- a/klayout_pex/fastercap/fastercap_runner.py +++ b/klayout_pex/fastercap/fastercap_runner.py @@ -26,13 +26,13 @@ import time from typing import * -from kpex.log import ( +from ..log import ( info, # warning, rule, subproc, ) -from kpex.common.capacitance_matrix import CapacitanceMatrix +from ..common.capacitance_matrix import CapacitanceMatrix def run_fastercap(exe_path: str, diff --git a/klayout_pex/klayout/lvs_runner.py b/klayout_pex/klayout/lvs_runner.py index a2052ed7..ce9166b7 100644 --- a/klayout_pex/klayout/lvs_runner.py +++ b/klayout_pex/klayout/lvs_runner.py @@ -27,7 +27,7 @@ import subprocess import time -from kpex.log import ( +from ..log import ( debug, info, warning, diff --git a/klayout_pex/klayout/lvsdb_extractor.py b/klayout_pex/klayout/lvsdb_extractor.py index 89282e22..e9b55182 100755 --- a/klayout_pex/klayout/lvsdb_extractor.py +++ b/klayout_pex/klayout/lvsdb_extractor.py @@ -30,7 +30,7 @@ import klayout.db as kdb -import tech_pb2 +import klayout_pex_protobuf.tech_pb2 from ..log import ( console, debug, diff --git a/klayout_pex/klayout/netlist_csv.py b/klayout_pex/klayout/netlist_csv.py index aee76cc9..e0a61b96 100644 --- a/klayout_pex/klayout/netlist_csv.py +++ b/klayout_pex/klayout/netlist_csv.py @@ -25,7 +25,7 @@ import klayout.db as kdb -from kpex.log import ( +from klayout_pex.log import ( info, ) diff --git a/klayout_pex/klayout/netlist_expander.py b/klayout_pex/klayout/netlist_expander.py index 4dc1996e..19625dd3 100644 --- a/klayout_pex/klayout/netlist_expander.py +++ b/klayout_pex/klayout/netlist_expander.py @@ -28,11 +28,11 @@ import klayout.db as kdb -from kpex.log import ( +from ..log import ( info, warning, ) -from kpex.common.capacitance_matrix import CapacitanceMatrix +from ..common.capacitance_matrix import CapacitanceMatrix class NetlistExpander: diff --git a/klayout_pex/klayout/repair_rdb.py b/klayout_pex/klayout/repair_rdb.py index 2e2fede7..1721e39e 100644 --- a/klayout_pex/klayout/repair_rdb.py +++ b/klayout_pex/klayout/repair_rdb.py @@ -30,7 +30,7 @@ import xml.etree.ElementTree as ET import klayout.rdb as rdb -from kpex.log import ( +from ..log import ( LogLevel, set_log_level, register_additional_handler, diff --git a/klayout_pex/magic/magic_runner.py b/klayout_pex/magic/magic_runner.py index 4ba9afa1..708301c9 100644 --- a/klayout_pex/magic/magic_runner.py +++ b/klayout_pex/magic/magic_runner.py @@ -28,13 +28,13 @@ import os import subprocess -from kpex.log import ( +from ..log import ( info, # warning, rule, subproc, ) -from kpex.version import __version__ +from ..version import __version__ class MagicPEXMode(StrEnum): diff --git a/klayout_pex/rcx25/extraction_results.py b/klayout_pex/rcx25/extraction_results.py index 0ba6c660..f368b8cc 100644 --- a/klayout_pex/rcx25/extraction_results.py +++ b/klayout_pex/rcx25/extraction_results.py @@ -26,7 +26,7 @@ from dataclasses import dataclass, field from typing import * -import process_parasitics_pb2 +import klayout_pex_protobuf.process_parasitics_pb2 NetName = str diff --git a/klayout_pex/rcx25/extractor.py b/klayout_pex/rcx25/extractor.py index 6c0a9c1a..193c5499 100644 --- a/klayout_pex/rcx25/extractor.py +++ b/klayout_pex/rcx25/extractor.py @@ -40,7 +40,7 @@ ) from ..tech_info import TechInfo from .extraction_results import * -import process_stack_pb2 +import klayout_pex_protobuf.process_stack_pb2 EdgeInterval = Tuple[float, float] diff --git a/klayout_pex/tech_info.py b/klayout_pex/tech_info.py index e92c216a..bc8a2b11 100644 --- a/klayout_pex/tech_info.py +++ b/klayout_pex/tech_info.py @@ -29,9 +29,9 @@ import google.protobuf.json_format from .util.multiple_choice import MultipleChoicePattern -import tech_pb2 -import process_stack_pb2 -import process_parasitics_pb2 +import klayout_pex_protobuf.tech_pb2 +import klayout_pex_protobuf.process_stack_pb2 +import klayout_pex_protobuf.process_parasitics_pb2 class TechInfo: """Helper class for Protocol Buffer tech_pb2.Technology""" diff --git a/klayout_pex_protobuf/NOTE_-_POETRY_WILL_AUGMENT_THIS_WITH_GENERATED_PROTOBUF_FILES.txt b/klayout_pex_protobuf/NOTE_-_POETRY_WILL_AUGMENT_THIS_WITH_GENERATED_PROTOBUF_FILES.txt new file mode 100644 index 00000000..e69de29b diff --git a/klayout_pex_protobuf/__init__.py b/klayout_pex_protobuf/__init__.py new file mode 100644 index 00000000..e3097fa4 --- /dev/null +++ b/klayout_pex_protobuf/__init__.py @@ -0,0 +1,34 @@ +# +# -------------------------------------------------------------------------------- +# SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl +# Johannes Kepler University, Institute for Integrated Circuits. +# +# This file is part of KPEX +# (see https://github.com/martinjankoehler/klayout-pex). +# +# 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 . +# SPDX-License-Identifier: GPL-3.0-or-later +# -------------------------------------------------------------------------------- +# + +import os +import sys + +# NOTE: generated protobuf files will import other protobuf python files as if they were on the top-level, +# while we want to have them in package klayout_kpex_protobuf +# FIXME: see also https://github.com/protocolbuffers/protobuf/issues/7061 + +_path = os.path.dirname(os.path.realpath(__file__)) +if _path not in sys.path: + sys.path.append(_path) diff --git a/kpex.sh b/kpex.sh index 35564f46..c9d171fc 100755 --- a/kpex.sh +++ b/kpex.sh @@ -26,5 +26,4 @@ DIR=$(dirname -- $(realpath ${BASH_SOURCE})) export PYTHONPATH=$DIR/:$DIR/build/python:${PYTHONPATH} -# /usr/bin/env python3 $DIR/kpex/kpex_cli.py $* /usr/bin/env python3 -m kpex $* diff --git a/pyproject.toml b/pyproject.toml index e0db5ad6..875b15b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,26 +25,29 @@ classifiers = [ ] packages = [ - { include = "kpex", to = "klayout_pex" }, + { include = "klayout_pex" }, { include = "pdk", to = "klayout_pex" }, - { include = "process_stack_pb2.py", from = "build/python_kpex_protobuf/", to = "klayout_pex" }, - { include = "process_parasitics_pb2.py", from = "build/python_kpex_protobuf/", to = "klayout_pex" }, - { include = "tech_pb2.py", from = "build/python_kpex_protobuf/", to = "klayout_pex" }, + { include = "process_stack_pb2.py", from = "build/python/klayout_pex_protobuf/", to = "klayout_pex_protobuf" }, + { include = "process_parasitics_pb2.py", from = "build/python/klayout_pex_protobuf/", to = "klayout_pex_protobuf" }, + { include = "tech_pb2.py", from = "build/python/klayout_pex_protobuf/", to = "klayout_pex_protobuf" }, + { include = "__init__.py", from = "klayout_pex_protobuf/", to = "klayout_pex_protobuf" }, { include = "build/sky130A_tech.pb.json", to = "klayout_pex" }, { include = "build/ihp_sg13g2_tech.pb.json", to = "klayout_pex" }, ] include = [ "kpex", + "klayout_pex_protobuf", "pdk/**/*", - "build/python_kpex_protobuf/*", - "build/*.json" + "build/python/klayout_pex_protobuf/*", + "build/*.json", + "klayout_pex_protobuf/__init__.py" ] [tool.poetry.urls] "Bug Tracker" = "https://github.com/martinjankoehler/klayout-pex/issues" [tool.poetry.scripts] -kpex = 'kpex.__main__:main' +kpex = 'klayout_pex.__main__:main' [tool.poetry.dependencies] python = "^3.12"