diff --git a/.travis.yml b/.travis.yml index 1c828bcbc..cec6b84c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,77 @@ matrix: include: - - os: osx - osx_image: xcode9.3beta - env: - - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '2.6' + env: + - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '2.7' + env: + - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '3.3' + env: + - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '3.4' + env: + - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '3.5' + env: + - MATRIX_EVAL="" + - os: linux + dist: trusty # Ubuntu 14.04 + sudo: false + language: python + python: '3.6' + env: + - MATRIX_EVAL="" + - os: osx + osx_image: xcode9.3 # macOS 10.13 + env: + - MATRIX_EVAL="" + - os: osx + osx_image: xcode8.3 # macOS 10.12 + env: + - MATRIX_EVAL="" + - os: osx + osx_image: xcode8 # macOS 10.11 + env: + - MATRIX_EVAL="" before_install: - - eval "${MATRIX_EVAL}" - - brew update - - brew bundle - env + - rvm install ruby --latest + - gem install dropbox-deployment + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; fi + - eval "${MATRIX_EVAL}" + - python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)" install: - - python3 setup.py install + - python setup.py build + - python setup.py bdist_wheel + - python setup.py install + script: - - python3 -c 'import klayout.db as db; print(dir(db))' - - python3 -c 'import klayout.rdb as rdb; print(dir(rdb))' - - python3 -c 'import klayout.tl as tl; print(dir(tl))' + - python -c 'import klayout.db as db; print(dir(db))' + - python -c 'import klayout.rdb as rdb; print(dir(rdb))' + - python -c 'import klayout.tl as tl; print(dir(tl))' + +after_success: + - dropbox-deployment diff --git a/dropbox-deployment.yml b/dropbox-deployment.yml new file mode 100644 index 000000000..945f867d8 --- /dev/null +++ b/dropbox-deployment.yml @@ -0,0 +1,4 @@ +deploy: + dropbox_path: /Builds/klayout-pymod # The path to the folder on Dropbox where the files will go + artifacts_path: dist # can be a single file, or a path + debug: true # if you want to see more logs diff --git a/setup.py b/setup.py index 2ba243d95..23635782d 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ from setuptools import setup, Extension, Distribution import glob import os import platform -import sysconfig +import distutils.sysconfig as sysconfig # ---------------------------------------------------------------------------------------- @@ -78,6 +78,9 @@ class Config(object): self.build_platlib = build_cmd.build_platlib self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") + if self.ext_suffix is None: + self.ext_suffix = ".so" + self.root = "klayout" def libname_of(self, mod): diff --git a/src/tl/tl/tlLog.cc b/src/tl/tl/tlLog.cc index f251191c8..1c8cace45 100644 --- a/src/tl/tl/tlLog.cc +++ b/src/tl/tl/tlLog.cc @@ -26,6 +26,7 @@ #include #include +#include #if defined(_WIN32) # include @@ -64,13 +65,13 @@ static int default_verbosity () static int m_verbosity_level = default_verbosity (); -void +void verbosity (int level) { m_verbosity_level = level; } -int +int verbosity () { return m_verbosity_level; @@ -79,7 +80,7 @@ verbosity () // ------------------------------------------------ // Channel implementation -Channel::Channel () +Channel::Channel () : m_no_endl (false), m_active (false) { // .. nothing else .. @@ -90,7 +91,7 @@ Channel::~Channel () // .. nothing yet .. } -ChannelProxy +ChannelProxy Channel::issue_proxy () { m_no_endl = false; @@ -102,7 +103,7 @@ Channel::issue_proxy () return ChannelProxy (this); } -void +void Channel::release_proxy () { if (! m_no_endl) { @@ -130,7 +131,7 @@ LogTee::LogTee (Channel *first, bool owned) add (first, owned); } -void +void LogTee::add (Channel *other, bool owned) { m_lock.lock (); @@ -161,7 +162,7 @@ LogTee::clear () m_lock.unlock (); } -void +void LogTee::puts (const char *s) { try { @@ -173,7 +174,7 @@ LogTee::puts (const char *s) } } -void +void LogTee::endl () { try { @@ -185,7 +186,7 @@ LogTee::endl () } } -void +void LogTee::end () { try { @@ -197,7 +198,7 @@ LogTee::end () } } -void +void LogTee::begin () { try { @@ -292,7 +293,7 @@ InfoChannel::~InfoChannel () // .. nothing yet .. } -void +void InfoChannel::puts (const char *s) { if (verbosity () >= m_verbosity) { @@ -300,7 +301,7 @@ InfoChannel::puts (const char *s) } } -void +void InfoChannel::endl () { if (verbosity () >= m_verbosity) { @@ -308,7 +309,7 @@ InfoChannel::endl () } } -void +void InfoChannel::end () { if (verbosity () >= m_verbosity) { @@ -319,7 +320,7 @@ InfoChannel::end () } } -void +void InfoChannel::begin () { if (verbosity () >= m_verbosity) { @@ -362,19 +363,19 @@ WarningChannel::~WarningChannel () // .. nothing yet .. } -void +void WarningChannel::puts (const char *s) { fputs (s, stdout); } -void +void WarningChannel::endl () { fputs ("\n", stdout); } -void +void WarningChannel::end () { if (m_colorized) { @@ -383,7 +384,7 @@ WarningChannel::end () fflush (stdout); } -void +void WarningChannel::begin () { if (m_colorized) { @@ -426,19 +427,19 @@ ErrorChannel::~ErrorChannel () // .. nothing yet .. } -void +void ErrorChannel::puts (const char *s) { fputs (s, stderr); } -void +void ErrorChannel::endl () { fputs ("\n", stderr); } -void +void ErrorChannel::end () { if (m_colorized) { @@ -447,7 +448,7 @@ ErrorChannel::end () fflush (stderr); } -void +void ErrorChannel::begin () { if (m_colorized) { diff --git a/src/tl/tl/tlThreads.cc b/src/tl/tl/tlThreads.cc index 4dc6ed49e..239dcaa5f 100644 --- a/src/tl/tl/tlThreads.cc +++ b/src/tl/tl/tlThreads.cc @@ -23,12 +23,12 @@ #if !defined(HAVE_QT) #include "tlThreads.h" +#include "tlUtils.h" #include "tlLog.h" #include "tlInternational.h" #include #include -#include #include #include #if defined(_WIN32) @@ -82,7 +82,7 @@ public: if (time < std::numeric_limits::max ()) { struct timespec end_time; - clock_gettime (CLOCK_REALTIME, &end_time); + current_utc_time (&end_time); end_time.tv_sec += (time / 1000); end_time.tv_nsec += (time % 1000) * 1000000; @@ -270,7 +270,7 @@ bool Thread::wait (unsigned long time) if (time < std::numeric_limits::max ()) { struct timespec end_time; - clock_gettime (CLOCK_REALTIME, &end_time); + current_utc_time (&end_time); end_time.tv_sec += (time / 1000); end_time.tv_nsec += (time % 1000) * 1000000; @@ -285,7 +285,7 @@ bool Thread::wait (unsigned long time) while (isRunning ()) { struct timespec current_time; - clock_gettime (CLOCK_REALTIME, ¤t_time); + current_utc_time (¤t_time); if (end_time.tv_sec < current_time.tv_sec || (end_time.tv_sec == current_time.tv_sec && end_time.tv_nsec < current_time.tv_nsec)) { return false; } diff --git a/src/tl/tl/tlTimer.cc b/src/tl/tl/tlTimer.cc index de3181891..c8058f30e 100644 --- a/src/tl/tl/tlTimer.cc +++ b/src/tl/tl/tlTimer.cc @@ -22,6 +22,7 @@ #include "tlTimer.h" +#include "tlUtils.h" #include "tlLog.h" #include "tlString.h" @@ -30,7 +31,6 @@ #endif #include -#include #ifndef _MSC_VER // not available on MS VC++ # include @@ -45,7 +45,7 @@ namespace tl static int64_t ms_time () { struct timespec spec; - clock_gettime (CLOCK_REALTIME, &spec); + current_utc_time (&spec); return int64_t (spec.tv_sec) * 1000 + int64_t (0.5 + spec.tv_nsec / 1.0e6); } @@ -77,7 +77,7 @@ Timer::start () #endif struct timespec spec; - clock_gettime (CLOCK_REALTIME, &spec); + current_utc_time (&spec); m_wall_ms += ms_time (); } diff --git a/src/tl/tl/tlUtils.h b/src/tl/tl/tlUtils.h index 84bdf5a5f..498fd4fd1 100644 --- a/src/tl/tl/tlUtils.h +++ b/src/tl/tl/tlUtils.h @@ -27,10 +27,37 @@ #include "tlAssert.h" #include +#include + +#if defined(__MACH__) +#include +#include +#endif namespace tl { +/** +* @brief clock_gettime is not implemented in Mac OS X 10.11 and lower +* From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c +*/ + +inline void current_utc_time(struct timespec *ts) { + +#if defined(__MACH__) + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + ts->tv_sec = mts.tv_sec; + ts->tv_nsec = mts.tv_nsec; +#else + clock_gettime(CLOCK_REALTIME, ts); +#endif + +} + /** * @brief A template class mapping a begin .. end iterator pair to the at_end semantics */