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 ]) 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 ()); } 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 {