diff --git a/ci-scripts/docker/docker_prepare.sh b/ci-scripts/docker/docker_prepare.sh index e380fdc45..4fb6e50c5 100644 --- a/ci-scripts/docker/docker_prepare.sh +++ b/ci-scripts/docker/docker_prepare.sh @@ -5,7 +5,7 @@ set -xe if [[ -f "/etc/centos-release" ]]; then # sometimes the epel server is down. retry 5 times for i in $(seq 1 5); do - yum install -y zlib-devel curl-devel expat-devel ccache && s=0 && break || s=$? && sleep 15; + yum install -y zlib-devel curl-devel expat-devel libpng-devel ccache && s=0 && break || s=$? && sleep 15; done [ $s -eq 0 ] || exit $s @@ -27,7 +27,7 @@ if [[ -f "/etc/centos-release" ]]; then elif [[ -f "/etc/alpine-release" ]]; then # musllinux prep # ccache already present - apk add curl-dev expat-dev zlib-dev ccache + apk add curl-dev expat-dev zlib-dev libpng-dev ccache export PATH="/usr/lib/ccache/bin:$PATH" fi diff --git a/pyproject.toml b/pyproject.toml index 422f75739..60f5b05e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "python {package}/testdata/pymod/import_lay.py", + "python {package}/testdata/pymod/import_lay_noqt.py", "python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms diff --git a/src/pymod/lay/lay.pro b/src/pymod/lay/lay.pro index 789393308..d62c2c847 100644 --- a/src/pymod/lay/lay.pro +++ b/src/pymod/lay/lay.pro @@ -9,12 +9,13 @@ SOURCES = \ HEADERS += \ -equals(HAVE_QT, "0") { - LIBS += -lklayout_laybasic -} else { +LIBS += -lklayout_layview + +!equals(HAVE_QT, "0") { + LIBS += -lklayout_layui LIBS += -lklayout_lay } # hard linked as they contribute GSI classes to "lay" module: -LIBS += -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym +LIBS += -lklayout_laybasic -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index f952ea9bb..a622fc2f2 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -23,7 +23,11 @@ #include "../pymodHelper.h" // to force linking of the layview module +#if defined(HAVE_QT) +# include "../../lay/lay/layForceLink.h" +#else # include "../../layview/layview/layviewForceLink.h" +#endif // Force-include other dependencies // NOTE: these libraries contribute to the "lay" module space. Hence we have to include them. @@ -33,4 +37,3 @@ #include "../../lym/lym/lymForceLink.h" DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") - diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 8f4b352f9..b9dd8ae03 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -87,12 +87,7 @@ PYMODTEST (bridge, "bridge.py") PYMODTEST (import_tl, "import_tl.py") PYMODTEST (import_db, "import_db.py") PYMODTEST (import_rdb, "import_rdb.py") - -#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) PYMODTEST (import_lay, "import_lay.py") -#else -PYMODTEST (import_lay, "import_lay_noqt.py") -#endif #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) diff --git a/testdata/pymod/import_lay.py b/testdata/pymod/import_lay.py index 990bbe2eb..3d37f0e5e 100755 --- a/testdata/pymod/import_lay.py +++ b/testdata/pymod/import_lay.py @@ -21,18 +21,38 @@ import klayout.lay as lay import unittest import sys +def can_create_layoutview(): + if not "MainWindow" in lay.__dict__: + return True # Qt-less + elif not "Application" in lay.__dict__: + return False # cannot instantiate Application + elif lay.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + # Tests the basic abilities of the module class BasicTest(unittest.TestCase): def test_1(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be instantiated") + return + lv = lay.LayoutView() lv.resize(800, 600) lv.zoom_box(db.DBox(-42, -17, 142, 117)) bx = lv.box() self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)") + def test_2(self): + + p = lay.LayerPropertiesNode() + p.name = "u" + self.assertEqual(p.name, "u") + # run unit tests if __name__ == '__main__': suite = unittest.TestSuite() diff --git a/testdata/pymod/import_lay_noqt.py b/testdata/pymod/import_lay_noqt.py deleted file mode 100755 index f12c4b34c..000000000 --- a/testdata/pymod/import_lay_noqt.py +++ /dev/null @@ -1,47 +0,0 @@ -# KLayout Layout Viewer -# Copyright (C) 2006-2022 Matthias Koefferlein -# -# 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 2 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, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -import testprep -import klayout.db as db -import klayout.lay as lay -import unittest -import sys - -# Tests the basic abilities of the module - -class BasicTest(unittest.TestCase): - - def test_1(self): - self.assertEqual("Annotation" in lay.__all__, True) - - def test_2(self): - # Some smoke test - ant = lay.Annotation() - ant.style = lay.Annotation.StyleRuler - self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) - ant.fmt_x = "abc" - self.assertEqual(ant.fmt_x, "abc") - -# run unit tests -if __name__ == '__main__': - suite = unittest.TestSuite() - suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest) - - if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): - sys.exit(1) - - diff --git a/testdata/python/dbLayoutVsSchematic.py b/testdata/python/dbLayoutVsSchematic.py index ea17abbec..3e8f0f0d4 100644 --- a/testdata/python/dbLayoutVsSchematic.py +++ b/testdata/python/dbLayoutVsSchematic.py @@ -177,7 +177,7 @@ class DBLayoutVsSchematicTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutVsSchematicTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/dbNetlistCrossReference.py b/testdata/python/dbNetlistCrossReference.py index 25ffecd80..7ed25ea57 100644 --- a/testdata/python/dbNetlistCrossReference.py +++ b/testdata/python/dbNetlistCrossReference.py @@ -179,7 +179,7 @@ class DBNetlistCrossReferenceTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBNetlistCrossReferenceTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/layLayers.py b/testdata/python/layLayers.py index 6db38847e..b0af39c26 100644 --- a/testdata/python/layLayers.py +++ b/testdata/python/layLayers.py @@ -21,6 +21,16 @@ import unittest import os import sys +def can_create_layoutview(): + if not "MainWindow" in pya.__dict__: + return True # Qt-less + elif not "Application" in pya.__dict__: + return False # cannot instantiate Application + elif pya.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + def astr(a): astr = [] for i in a: @@ -57,6 +67,10 @@ class LAYLayersTests(unittest.TestCase): def test_1(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) @@ -202,6 +216,10 @@ class LAYLayersTests(unittest.TestCase): def test_1a(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + mgr = pya.Manager() cv = pya.LayoutView(False, mgr) @@ -647,6 +665,10 @@ class LAYLayersTests(unittest.TestCase): # direct replacement of objects and attributes def test_3(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True) @@ -765,6 +787,10 @@ class LAYLayersTests(unittest.TestCase): # propagation of "real" attributes through the hierarchy def test_4(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) @@ -795,6 +821,10 @@ class LAYLayersTests(unittest.TestCase): # delete method of iterator def test_5(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) @@ -883,6 +913,10 @@ class LAYLayersTests(unittest.TestCase): # custom stipples and line styles def test_6(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) @@ -926,7 +960,7 @@ if __name__ == '__main__': suite = unittest.TestSuite() # NOTE: Use this instead of loadTestsfromTestCase to select a specific test: # suite.addTest(BasicTest("test_26")) - suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTest) + suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTests) # Only runs with Application available if "Application" in pya.__all__ and not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():