diff --git a/.travis.yml b/.travis.yml index 40201f5e0..193cfd592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -555,6 +555,7 @@ script: python testdata/pymod/import_db.py; python testdata/pymod/import_rdb.py; python testdata/pymod/import_tl.py; + python testdata/pymod/import_lib.py; python testdata/pymod/pya_tests.py; fi fi @@ -565,6 +566,7 @@ script: python testdata/pymod/import_db.py; python testdata/pymod/import_rdb.py; python testdata/pymod/import_tl.py; + python testdata/pymod/import_lib.py; python testdata/pymod/pya_tests.py; klayout_version=$(python -c 'import setup; print(setup.Config().version())'); mkdir -p deploy/dist-pymod/$klayout_version; diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e35efce39..71f9d69c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -84,6 +84,7 @@ jobs: python testdata/pymod/import_db.py python testdata/pymod/import_rdb.py python testdata/pymod/import_tl.py + python testdata/pymod/import_lib.py python testdata/pymod/pya_tests.py displayName: 'Test KLayout pymod' diff --git a/setup.py b/setup.py index 9b13b54b9..bee480c5d 100644 --- a/setup.py +++ b/setup.py @@ -403,6 +403,22 @@ _db = Library(config.root + '._db', sources=list(_db_sources)) config.add_extension(_db) +# ------------------------------------------------------------------ +# _lib dependency library + +_lib_path = os.path.join("src", "lib", "lib") +_lib_sources = set(glob.glob(os.path.join(_lib_path, "*.cc"))) + +_lib = Library(config.root + '._lib', + define_macros=config.macros() + [('MAKE_LIB_LIBRARY', 1)], + include_dirs=[_tl_path, _gsi_path, _db_path, _lib_path], + extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + extra_link_args=config.link_args('_lib'), + extra_compile_args=config.compile_args('_lib'), + sources=list(_lib_sources)) +config.add_extension(_lib) + # ------------------------------------------------------------------ # _rdb dependency library @@ -472,6 +488,19 @@ db = Extension(config.root + '.dbcore', extra_link_args=config.link_args('dbcore'), sources=list(db_sources)) +# ------------------------------------------------------------------ +# lib extension library + +lib_path = os.path.join("src", "pymod", "lib") +lib_sources = set(glob.glob(os.path.join(lib_path, "*.cc"))) + +lib = Extension(config.root + '.libcore', + define_macros=config.macros(), + include_dirs=[_lib_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_lib', _lib_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('libcore'), + sources=list(lib_sources)) + # ------------------------------------------------------------------ # rdb extension library @@ -481,7 +510,7 @@ rdb_sources = set(glob.glob(os.path.join(rdb_path, "*.cc"))) rdb = Extension(config.root + '.rdbcore', define_macros=config.macros(), - include_dirs=[_rdb_path, _db_path, _tl_path, _gsi_path, _pya_path], + include_dirs=[_rdb_path, _tl_path, _gsi_path, _pya_path], extra_objects=[config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], extra_link_args=config.link_args('rdbcore'), sources=list(rdb_sources)) @@ -511,4 +540,4 @@ if __name__ == '__main__': url='https://github.com/klayoutmatthias/klayout', packages=find_packages('src/pymod/distutils_src'), package_dir={'': 'src/pymod/distutils_src'}, # https://github.com/pypa/setuptools/issues/230 - ext_modules=[_tl, _gsi, _pya, _db, _rdb] + db_plugins + [tl, db, rdb]) + ext_modules=[_tl, _gsi, _pya, _db, _lib, _rdb] + db_plugins + [tl, db, lib, rdb]) diff --git a/src/pymod/__init__.py.noqt b/src/pymod/__init__.py.noqt index dce96f8e4..4213afffb 100644 --- a/src/pymod/__init__.py.noqt +++ b/src/pymod/__init__.py.noqt @@ -1,5 +1,5 @@ # klayout library definition file -__all__ = [ "tl", "db", "lay", "rdb" ] +__all__ = [ "tl", "db", "lib", "lay", "rdb" ] diff --git a/src/pymod/__init__.py.qt4 b/src/pymod/__init__.py.qt4 index 18e5d527d..1404dbe71 100644 --- a/src/pymod/__init__.py.qt4 +++ b/src/pymod/__init__.py.qt4 @@ -1,5 +1,5 @@ # klayout library definition file -__all__ = [ "tl", "db", "rdb", "QtCore", "QtGui", "QtXml", "QtSql", "QtNetwork", "QtDesigner", "lay" ] +__all__ = [ "tl", "db", "lib", "rdb", "QtCore", "QtGui", "QtXml", "QtSql", "QtNetwork", "QtDesigner", "lay" ] diff --git a/src/pymod/__init__.py.qt5 b/src/pymod/__init__.py.qt5 index 9a943103f..6077d2f06 100644 --- a/src/pymod/__init__.py.qt5 +++ b/src/pymod/__init__.py.qt5 @@ -1,7 +1,7 @@ # klayout library definition file -__all__ = [ "tl", "db", "rdb", +__all__ = [ "tl", "db", "lib", "rdb", "QtCore", "QtGui", "QtNetwork", "QtSql", "QtWidgets", "QtDesigner", "QtMultimedia", "QtPrintSupport", "QtSvg", "QtXmlPatterns", "QtXml", "lay" ] diff --git a/src/pymod/__init__.py.qtless b/src/pymod/__init__.py.qtless index 6aef40aa9..776d25ace 100644 --- a/src/pymod/__init__.py.qtless +++ b/src/pymod/__init__.py.qtless @@ -1,4 +1,4 @@ # klayout library definition file -__all__ = [ "tl", "db", "rdb" ] +__all__ = [ "tl", "db", "lib", "rdb" ] diff --git a/src/pymod/distutils_src/klayout/lib/__init__.py b/src/pymod/distutils_src/klayout/lib/__init__.py new file mode 100644 index 000000000..90fb8d3de --- /dev/null +++ b/src/pymod/distutils_src/klayout/lib/__init__.py @@ -0,0 +1,4 @@ +import klayout.libcore +from klayout.libcore import * + +__all__ = klayout.libcore.__all__ diff --git a/src/pymod/distutils_src/pya/__init__.py b/src/pymod/distutils_src/pya/__init__.py index 70e2f49b9..08879d72b 100644 --- a/src/pymod/distutils_src/pya/__init__.py +++ b/src/pymod/distutils_src/pya/__init__.py @@ -3,5 +3,6 @@ # TODO: We need a specification document explaining what should go into pya from klayout.db import * # noqa +from klayout.lib import * # noqa from klayout.tl import * # noqa from klayout.rdb import * # noqa diff --git a/src/pymod/lib/lib.pro b/src/pymod/lib/lib.pro new file mode 100644 index 000000000..f78877a69 --- /dev/null +++ b/src/pymod/lib/lib.pro @@ -0,0 +1,13 @@ + +TARGET = libcore +REALMODULE = lib + +include($$PWD/../pymod.pri) + +SOURCES = \ + libMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lib + diff --git a/src/pymod/lib/libMain.cc b/src/pymod/lib/libMain.cc new file mode 100644 index 000000000..2e1a1fb38 --- /dev/null +++ b/src/pymod/lib/libMain.cc @@ -0,0 +1,33 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2019 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 + +*/ + +#include "../pymodHelper.h" + +// to force linking of the lib module +#include "../../lib/lib/libForceLink.h" + +static PyObject *lib_module_init (const char *pymod_name, const char *mod_name, const char *mod_description) +{ + return module_init (pymod_name, mod_name, mod_description); +} + +DEFINE_PYMOD_WITH_INIT(libcore, "lib", "KLayout core module 'lib'", lib_module_init) diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index ba4300cea..3cd7e2fe6 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -4,6 +4,7 @@ SUBDIRS = \ db \ tl \ rdb \ + lib \ !equals(HAVE_QT, "0") {