From e709cad9c8761323b04deff3f406035fadc60fd7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 14 Jul 2018 20:24:28 +0000 Subject: [PATCH 1/3] Fixed an include path for better compatibility with Python's distutil. --- src/tl/tl/atomic/spinlock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tl/tl/atomic/spinlock.h b/src/tl/tl/atomic/spinlock.h index 3e9959672..9e9653b04 100644 --- a/src/tl/tl/atomic/spinlock.h +++ b/src/tl/tl/atomic/spinlock.h @@ -25,7 +25,7 @@ #ifndef ATOMIC_SPINLOCK_H_ #define ATOMIC_SPINLOCK_H_ -#include "atomic/atomic.h" +#include "atomic.h" namespace atomic { class spinlock { From 6a3914fcf6268903b01c265b82aadfc34fcd36d7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 14 Jul 2018 20:32:13 +0000 Subject: [PATCH 2/3] Fixed pya.cc build with Py3/Linux --- src/pya/pya/pya.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/pya/pya/pya.cc b/src/pya/pya/pya.cc index 93fb9354b..044151f4e 100644 --- a/src/pya/pya/pya.cc +++ b/src/pya/pya/pya.cc @@ -250,13 +250,8 @@ PythonInterpreter::PythonInterpreter () const char *python_path = getenv ("KLAYOUT_PYTHONPATH"); if (python_path) { - QString path = QString::fromLocal8Bit (python_path); - - if (sizeof (wchar_t) == 4) { - Py_SetPath ((const wchar_t *) path.toUcs4 ().constData ()); - } else if (sizeof (wchar_t) == 2) { - Py_SetPath ((const wchar_t *) path.utf16 ()); - } + std::wstring path = tl::to_wstring (tl::to_string_from_local (python_path)); + Py_SetPath (path.c_str ()); } From 6d3490811d976b633ea96e8b16669d47c7afa15a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 14 Jul 2018 22:01:37 +0000 Subject: [PATCH 3/3] First steps towards a setup.py script. --- setup.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..bb22539e3 --- /dev/null +++ b/setup.py @@ -0,0 +1,79 @@ + +from distutils.core import setup, Extension, Distribution +from distutils.command.build import build +import glob + +# TODO: what is the portable way of finding the path of a +def libname_of(mod): + return mod + ".cpython-35m-x86_64-linux-gnu.so" + +# TODO: what is the portable way of finding the path of a +# library +# .... +def path_of(mod): + return "build/lib.linux-x86_64-3.5/klayout/" + libname_of(mod) +# .... + +# TODO: what is the portable way of getting the RPATH +def rpath(): + return ['/usr/local/lib/python3.5/dist-packages/klayout'] + +# TODO: should be platform specific +def link_args(mod): + return ['-Wl,-soname,' + libname_of(mod)] + +# ------------------------------------------------------------------ + +macros = [ ('HAVE_CURL', 1), ('HAVE_EXPAT', 1) ] + +_tl_sources = glob.glob("src/tl/tl/*.cc") + +# Exclude sources which are compatible with Qt only +_tl_sources.remove("src/tl/tl/tlHttpStreamQt.cc") +_tl_sources.remove("src/tl/tl/tlFileSystemWatcher.cc") +_tl_sources.remove("src/tl/tl/tlDeferredExecutionQt.cc") + +_tl = Extension('klayout._tl', + define_macros = macros + [ ('MAKE_TL_LIBRARY', 1) ], + language = 'c++', + libraries = [ 'curl', 'expat' ], + extra_link_args = link_args('_tl'), + sources = _tl_sources) + +_gsi_sources = glob.glob("src/gsi/gsi/*.cc") + +_gsi = Extension('klayout._gsi', + define_macros = macros + [ ('MAKE_GSI_LIBRARY', 1) ], + include_dirs = [ 'src/tl/tl' ], + extra_objects = [ path_of('_tl') ], + runtime_library_dirs = rpath(), + language = 'c++', + extra_link_args = link_args('_gsi'), + sources = _gsi_sources) + +_pya_sources = glob.glob("src/pya/pya/*.cc") + +_pya = Extension('klayout._pya', + define_macros = macros + [ ('MAKE_PYA_LIBRARY', 1) ], + include_dirs = [ 'src/tl/tl', 'src/gsi/gsi' ], + extra_objects = [ path_of('_tl'), path_of('_gsi') ], + runtime_library_dirs = rpath(), + language = 'c++', + extra_link_args = link_args('_pya'), + sources = _pya_sources) + +tl_sources = glob.glob("src/pymod/tl/*.cc") + +tl = Extension('klayout.tl', + define_macros = macros, + include_dirs = [ 'src/tl/tl', 'src/gsi/gsi', 'src/pya/pya' ], + extra_objects = [ path_of('_tl'), path_of('_gsi'), path_of('_pya') ], + runtime_library_dirs = rpath(), + sources = tl_sources) + +setup (name = 'KLayout', + version = '0.26', + description = 'KLayout standalone Python package', + author = 'Matthias Koefferlein', + author_email = 'matthias@klayout.de', + ext_modules = [ _tl, _gsi, _pya, tl ])