Merge master into pymod (attempt by @tlima)

This commit is contained in:
Thomas Ferreira de Lima 2018-09-21 16:06:43 -04:00
commit 6e0dc93b55
No known key found for this signature in database
GPG Key ID: 43E98870EAA0A86E
19 changed files with 302 additions and 171 deletions

View File

@ -1,44 +1,71 @@
matrix:
include:
# python 3 osx
- os: osx
# python 2 osx
- name: "klayout python2 osx10.13"
os: osx
osx_image: xcode9.4 # macOS 10.13
env:
- MATRIX_EVAL=""
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
- os: osx
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python2 osx10.12"
os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL="brew install python2 || brew link --overwrite python@2" # deficient python2 in travis's xcode8.3 (no ssl)
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
- os: osx
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python2 osx10.11"
os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL=""
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
# python 2 osx
- os: osx
- PYTHON_BUILD=true
- BREW_BUNDLE=false
# python 3 osx
- name: "klayout python3 osx10.13"
os: osx
osx_image: xcode9.4 # macOS 10.13
env:
- MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
- os: osx
- PYTHON_BUILD=true
- BREW_BUNDLE=true
- name: "klayout python3 osx10.12"
os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
- os: osx
- PYTHON_BUILD=true
- BREW_BUNDLE=true
- name: "klayout python3 osx10.11"
os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL="brew update; brew bundle; shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';"
- ARCHFLAGS="-std=c++11"
- PIP_UPDATE="1"
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=true
- name: "klayout python3.6 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -46,7 +73,11 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="1"
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python2.7 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -54,7 +85,11 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="1"
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python2.6 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -62,7 +97,11 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="0" # setuptools installed from last pip has syntax error on py 2.6
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python3.3 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -70,7 +109,11 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="1"
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python3.4 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -78,7 +121,11 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="1"
- os: linux
- PYTHON_BUILD=true
- BREW_BUNDLE=false
- name: "klayout python3.5 package"
os: linux
dist: trusty # Ubuntu 14.04
sudo: false
language: python
@ -86,12 +133,82 @@ matrix:
env:
- MATRIX_EVAL=""
- PIP_UPDATE="1"
- PYTHON_BUILD=true
- BREW_BUNDLE=false
# KLayout builds for mac
# Python 3
- name: "KLayout macOS 10.13 with py3.7"
os: osx
osx_image: xcode9.4 # macOS 10.13
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=B37
- MACOS_VERSION=HighSierra
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
- name: "KLayout macOS 10.12 with py3.7"
os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=B37
- MACOS_VERSION=Sierra
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
- name: "KLayout macOS 10.11 with py3.7"
os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=B37
- MACOS_VERSION=ElCapitan
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
# Python 2
- name: "KLayout macOS 10.13 with py2.7"
os: osx
osx_image: xcode9.4 # macOS 10.13
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=Sys
- MACOS_VERSION=HighSierra
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
- name: "KLayout macOS 10.12 with py2.7"
os: osx
osx_image: xcode8.3 # macOS 10.12
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=Sys
- MACOS_VERSION=Sierra
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
- name: "KLayout macOS 10.11 with py2.7"
os: osx
osx_image: xcode8 # macOS 10.11
env:
- MATRIX_EVAL=""
- PYTHON_VERSION=Sys
- MACOS_VERSION=ElCapitan
- KLAYOUT_BUILD=true
- BREW_BUNDLE=true
before_install:
- env
- rvm install ruby --latest
- gem install dropbox-deployment
- eval "${MATRIX_EVAL}"
- if [ "$BREW_BUNDLE" = true ]; then
find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' | xargs grep 'EOS.undent' --files-with-matches | xargs sed -i '' 's/EOS.undent/EOS/';
brew update;
brew bundle;
fi
- if [ "${PIP_UPDATE}" == "1" ]; then
pip --version;
pip install --upgrade pip || sudo pip install --upgrade pip;
@ -100,15 +217,20 @@ before_install:
fi
- python -c "import distutils.sysconfig as sysconfig; print(sysconfig.__file__)"
install:
- python setup.py build
- python setup.py bdist_wheel
- python setup.py install
script:
- 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))'
script:
- if [ "$PYTHON_BUILD" = true ]; then
python setup.py build;
python setup.py bdist_wheel;
python setup.py install;
cp -a dist deploy/;
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))';
fi
- if [ "$KLAYOUT_BUILD" = true ]; then
./travis-build.sh;
fi
after_success:
- mkdir -p deploy
- dropbox-deployment

View File

@ -1,2 +1,4 @@
tap "homebrew/core"
brew "python3"
brew "python@2", link: false
brew "qt"

View File

@ -5,11 +5,18 @@
For details see:
https://github.com/klayoutmatthias/klayout/wiki/klayout---Standalone-KLayout-Python-Module
0.25.5 (2018-12-30):
0.25.5 (2018-09-19):
* YET TO BE RELEASED
* Bugfix: https://github.com/klayoutmatthias/klayout/issues/162
GDS2 LIBNAME was not maintained on "File/Save".
* Bugfix: https://github.com/klayoutmatthias/klayout/issues/166
Internal error when writing GDS files (breaking of polygons)
* Bugfix: some potential memory corruption issues fixed
During the efforts for making the code base compatible
with MSVC, some potential candidates for memory corruption
have been identified and fixed.
These fixes are included in this release.
0.25.4 (2018-08-25):
* Bugfix: https://github.com/klayoutmatthias/klayout/issues/121

View File

@ -6,9 +6,10 @@ klayout (0.26-1) unstable; urgency=low
klayout (0.25.5-1) unstable; urgency=low
* YET TO BE RELEASED
* New features and bugfixes
- See changelog
-- Matthias Köfferlein <matthias@koefferlein.de> Sat, 30 Dec 2018 23:15:23 +0200
-- Matthias Köfferlein <matthias@koefferlein.de> Wed, 19 Sep 2018 22:04:35 +0200
klayout (0.25.4-1) unstable; urgency=low

51
Makefile Normal file
View File

@ -0,0 +1,51 @@
.PHONY: help build deploy test dropbox-deploy
GITCOMMIT := $(shell git rev-parse --short HEAD)
KLAYOUT_VERSION := $(shell source version.sh && echo $$KLAYOUT_VERSION)
.ONESHELL:
default: help
help:
@echo "For Mac OS only"
@echo "make build PYTHON_VERSION=B37"
@echo "make deploy PYTHON_VERSION=B37"
@echo "make test MACOS_VERSION=HighSierra"
@echo "Valid Mac OS Versions: [Yosemite, ElCapitan, Sierra, HighSierra]"
@echo "Valid Python Version: [nil, Sys, B37]"
build:
@echo "Building for Mac $(GITCOMMIT)"
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew -c; \
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew
deploy:
@echo "Deploying 4 Mac $(GITCOMMIT)"
./build4mac.py -p $(PYTHON_VERSION) -q Qt5Brew -y
test:
@echo "Testing 4 Mac $(GITCOMMIT)"
qt5.pkg.macos-$(MACOS_VERSION)-release/klayout.app/Contents/MacOS/klayout -b -r test-pylib-script.py; \
cd qt5.build.macos-$(MACOS_VERSION)-release; \
ln -s klayout.app/Contents/MacOS/klayout klayout; \
export TESTTMP=testtmp; \
export TESTSRC=..; \
./ut_runner -h || true; \
cd ..
dropbox-deploy:
@echo "Preparing for dropbox deployment $(MACOS_VERSION) $(GITCOMMIT)"
mkdir -p deploy; \
pwd; \
ls -lah; \
touch build.txt; \
cp build.txt deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).log.txt; \
hdiutil convert macbuild/Resources/klayoutDMGTemplate.dmg -format UDRW -o work-KLayout.dmg; \
hdiutil resize -size 500m work-KLayout.dmg; \
hdiutil attach work-KLayout.dmg -readwrite -noverify -quiet -mountpoint tempKLayout -noautoopen; \
cp -a qt5.pkg.macos-$(MACOS_VERSION)-release/ tempKLayout/; \
hdiutil detach tempKLayout; \
hdiutil convert work-KLayout.dmg -format UDZO -imagekey zlib-level=9 -o deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg; \
md5 -q deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg > deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg.md5; \
rm work-KLayout.dmg

View File

@ -1,4 +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
dropbox_path: /Builds/klayout # The path to the folder on Dropbox where the files will go
artifacts_path: deploy # can be a single file, or a path
debug: true # if you want to see more logs

View File

@ -31,7 +31,7 @@ Also by default, supported script languages, i.e, Ruby and Python, are those sta
You may want to use a non-OS-standard script language such as Python 3.6 from Anaconda2 (https://www.anaconda.com/download/#macos) in combination with KLayout.
Since Anaconda2 is a popular Python development environment, this is worth trying. Unfortunately, however, some dynamic linkage problems are observed as of today.
On the other hand, Python 3.6 provided by MacPorts or Homebrew is usable.
On the other hand, Python 3.7 provided by MacPorts or Homebrew is usable.
Please try this (refer to 3B below or Section #5) if you feel it's useful.
# 3. Use-cases
@ -90,20 +90,20 @@ $ ./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m
# 5. Alternative building options
### 5.1 Python 3.6 from Homebrew, Qt 5.10.1 from Homebrew
### 5.1 Python 3.7 from Homebrew, Qt 5.10.1 from Homebrew
Homebrew's installation of python3 (`brew install python3`) places a `Python.framework` in `/usr/local/opt/python/Frameworks/Python.framework/`, which you can use to build KLayout from. Qt can also be downloaded from brew with `brew install qt`.
```
# Build step
./build4mac.py -p B36 -q Qt5Brew
./build4mac.py -p B37 -q Qt5Brew
# build with log
./build4mac.py -p B36 -q Qt5Brew 2>&1 | tee qt5.build.macos-HighSierra-release-version.log
./build4mac.py -p B37 -q Qt5Brew 2>&1 | tee qt5.build.macos-HighSierra-release-version.log
# Deploy step
./build4mac.py -p B36 -q Qt5Brew -y # normal deploy
./build4mac.py -p B36 -q Qt5Brew -y -v 3 2>&1 | tee qt5.pkg.macos-HighSierra-release.log # deploy with debug options
./build4mac.py -p B37 -q Qt5Brew -y # normal deploy
./build4mac.py -p B37 -q Qt5Brew -y -v 3 2>&1 | tee qt5.pkg.macos-HighSierra-release.log # deploy with debug options
# Packaging step
./makeDMG4mac.py -p qt5.pkg.macos-HighSierra-release -m -q Qt5101

Binary file not shown.

View File

@ -67,7 +67,7 @@ def SetGlobals():
Usage += " : Refer to 'macbuild/build4mac_env.py' for details | \n"
Usage += " [-q|--qt <type>] : type=['Qt4MacPorts', 'Qt5MacPorts', 'Qt5Brew'] | qt5macports \n"
Usage += " [-r|--ruby <type>] : type=['nil', 'Sys', 'Src24', 'MP24', 'B25'] | sys \n"
Usage += " [-p|--python <type>] : type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B36'] | sys \n"
Usage += " [-p|--python <type>] : type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B37'] | sys \n"
Usage += " [-n|--noqtbinding] : don't create Qt bindings for ruby scripts | disabled \n"
Usage += " [-m|--make <option>] : option passed to 'make' | -j4 \n"
Usage += " [-d|--debug] : enable debug mode build | disabled \n"
@ -175,7 +175,7 @@ def ParseCommandLineArguments():
p.add_option( '-p', '--python',
dest='type_python',
help="Python type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36']" )
help="Python type=['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B37']" )
p.add_option( '-n', '--noqtbinding',
action='store_true',
@ -294,7 +294,7 @@ def ParseCommandLineArguments():
exit()
# Determine Python type
candidates = [ i.upper() for i in ['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B36'] ]
candidates = [ i.upper() for i in ['nil', 'Sys', 'Ana27', 'Ana36', 'MP36', 'B37'] ]
ModulePython = ""
index = 0
for item in candidates:
@ -324,7 +324,7 @@ def ParseCommandLineArguments():
ModulePython = 'Python36MacPorts'
NonOSStdLang = True
elif index == 5:
ModulePython = 'Python36Brew'
ModulePython = 'Python37Brew'
NonOSStdLang = True
else:
index += 1
@ -765,12 +765,12 @@ def DeployBinariesForBundle():
deploymentPython = True
if deploymentPython and NonOSStdLang:
from build4mac_util import WalkFrameworkPaths, PerformChanges, DetectChanges
from build4mac_util import WalkFrameworkPaths, PerformChanges
bundlePath = AbsMacPkgDir + '/klayout.app'
# bundlePath = os.getcwd() + '/qt5.pkg.macos-HighSierra-release/klayout.app'
bundleExecPathAbs = '%s/Contents/MacOS/' % bundlePath
pythonOriginalFrameworkPath = '/usr/local/opt/python3/Frameworks/Python.framework'
pythonOriginalFrameworkPath = '/usr/local/opt/python/Frameworks/Python.framework'
pythonFrameworkPath = '%s/Contents/Frameworks/Python.framework' % bundlePath
print(" [8.1] Deploying Python from %s ..." % pythonOriginalFrameworkPath)
@ -1012,8 +1012,6 @@ def main():
if not ret2 == 0:
sys.exit(1)
else:
sys.exit(0)
#===================================================================================
if __name__ == "__main__":

View File

@ -126,7 +126,7 @@ RubyDictionary = { 'nil' : None,
# [3] Python
#-----------------------------------------------------
Pythons = [ 'nil', 'PythonYosemite', 'PythonElCapitan', 'PythonSierra', 'PythonHighSierra' ]
Pythons += [ 'Anaconda27', 'Anaconda36', 'Python36MacPorts', 'Python36Brew' ]
Pythons += [ 'Anaconda27', 'Anaconda36', 'Python36MacPorts', 'Python37Brew' ]
#-----------------------------------------------------
# Whereabout of different components of Python
@ -188,11 +188,11 @@ Python36MacPorts= { 'exe': '/opt/local/Library/Frameworks/Python.framework/Versi
'lib': '/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib'
}
# Python 3.6 from Brew *+*+*+ EXPERIMENTAL *+*+*+
# Python 3.7 from Brew *+*+*+ EXPERIMENTAL *+*+*+
# [Key Type Name] = 'pybrew'
Python36Brew= { 'exe': '/usr/local/opt/python/libexec/bin/python' ,
'inc': '/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/Headers',
'lib': '/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/Python'
Python37Brew= { 'exe': '/usr/local/opt/python/libexec/bin/python' ,
'inc': '/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Headers',
'lib': '/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python'
}
# Consolidated dictionary kit for Python
@ -204,7 +204,7 @@ PythonDictionary= { 'nil' : None,
'Anaconda27' : Anaconda27,
'Anaconda36' : Anaconda36,
'Python36MacPorts': Python36MacPorts,
'Python36Brew' : Python36Brew,
'Python37Brew' : Python37Brew,
}
#-----------------------------------------------------

View File

@ -361,7 +361,7 @@ def MakeTargetDMGFile(msg=""):
# (4) Mount the DMG
#--------------------------------------------------------
print( ">>> (4) Mounting <%s> to <%s>" % (WorkDMG, MountDir ) )
command1 = "hdiutil attach %s -readwrite -noverify -noautoopen -quiet" % WorkDMG
command1 = "hdiutil attach %s -readwrite -noverify -quiet -noautoopen" % WorkDMG
os.system(command1)
command2 = "hdiutil info | grep %s | grep \"/dev/\" | awk '{print $1}'" % VolumeDMG

View File

@ -112,7 +112,7 @@ struct cut_polygon_edge
{
typedef typename PointType::coord_type coord_type;
typedef typename db::edge<coord_type> edge_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
typedef double projection_type;
cut_polygon_edge ()
: contour (-1), index (0), projected (0), point (), last_point ()
@ -179,7 +179,7 @@ public:
bool operator< (const loose_end_struct<CuttingEdgeType> &other) const
{
if (proj () != other.proj ()) {
if (! db::coord_traits<double>::equal (proj (), other.proj ())) {
return proj () < other.proj ();
} else {
return db::vprod_sign (edge (), other.edge ()) > 0;
@ -196,13 +196,13 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
typedef db::edge<coord_type> edge_type;
typedef cut_polygon_edge<point_type> cut_polygon_edge_type;
typedef cut_polygon_segment<cut_polygon_edge_type> cutting_segment_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
bool do_hole_assignment = (input.holes () > 0);
std::vector <PolygonType> hull_polygons;
std::vector <PolygonType> hole_polygons;
std::vector<cutting_segment_type> cutting_segments;
double line_length = line.double_length ();
for (unsigned int nc = 0; nc < input.holes () + 1; ++nc) {
@ -229,7 +229,7 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
int s1 = line.side_of (e.p1 ());
int s2 = line.side_of (e.p2 ());
projection_type p = db::sprod (ip.second - line.p1 (), line.p2 () - line.p1 ());
double p = line_length * double (db::vprod (e.p1 () - line.p1 (), e.d ())) / double (db::vprod (line.d (), e.d ()));
if (s1 < 0 && s2 >= 0) {
// right -> left or on edge

View File

@ -2241,3 +2241,20 @@ TEST(403)
EXPECT_EQ (right_of.size (), size_t (0));
}
}
// issue 166
TEST(404)
{
db::Polygon poly;
std::string s ("(390,0;438,936;176,874;0,832;438,937;541,961;821,102)");
tl::Extractor ex (s.c_str ());
ex.read (poly);
std::vector<db::Polygon> sp;
db::split_polygon (poly, sp);
EXPECT_EQ (sp.size (), size_t (2));
if (sp.size () >= 2) {
EXPECT_EQ (sp[0].to_string (), "(390,0;438,936;390,925;438,937;541,961;821,102)");
EXPECT_EQ (sp[1].to_string (), "(0,832;176,874;390,925)");
}
}

View File

@ -1145,3 +1145,11 @@ TEST(121)
opt.max_vertex_count = 4;
run_test (_this, "t121.oas.gz", "t121_au.gds.gz", true, opt);
}
// Extreme fracturing by max. points
TEST(166)
{
db::GDS2WriterOptions opt;
opt.max_vertex_count = 4;
run_test (_this, "t166.oas.gz", "t166_au.gds.gz", false, opt);
}

View File

@ -1,98 +0,0 @@
import os, subprocess
import sys
from macbuild.build4mac_util import WalkFrameworkPaths, PerformChanges, DetectChanges
from pathlib import Path
# bundlePath = AbsMacPkgDir
bundlePath = os.getcwd() + '/qt5.pkg.macos-HighSierra-release/klayout.app'
bundleExecPathAbs = '%s/Contents/MacOS/' % bundlePath
pythonOriginalFrameworkPath = '/usr/local/opt/python/Frameworks/Python.framework'
pythonFrameworkPath = '%s/Contents/Frameworks/Python.framework' % bundlePath
print("[1] Copying Python Framework")
shell_commands = list()
shell_commands.append(f"rm -rf {pythonFrameworkPath}")
shell_commands.append(f"rsync -a --safe-links {pythonOriginalFrameworkPath}/ {pythonFrameworkPath}")
shell_commands.append(f"mkdir {pythonFrameworkPath}/Versions/3.6/lib/python3.6/site-packages/")
shell_commands.append(f"cp -RL {pythonOriginalFrameworkPath}/Versions/3.6/lib/python3.6/site-packages/{{pip*,pkg_resources,setuptools*,wheel*}} " +
f"{pythonFrameworkPath}/Versions/3.6/lib/python3.6/site-packages/")
shell_commands.append(f"rm -rf {pythonFrameworkPath}/Versions/3.6/lib/python3.6/test")
shell_commands.append(f"rm -rf {pythonFrameworkPath}/Versions/3.6/Resources")
shell_commands.append(f"rm -rf {pythonFrameworkPath}/Versions/3.6/bin")
for command in shell_commands:
if subprocess.call( command, shell=True ) != 0:
msg = "command failed: %s"
print( msg % command, file=sys.stderr )
exit(1)
print("[2] Relinking dylib dependencies inside Python.framework")
depdict = WalkFrameworkPaths(pythonFrameworkPath)
appPythonFrameworkPath = '@executable_path/../Frameworks/Python.framework/'
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
usrLocalPath = '/usr/local/opt/'
appUsrLocalPath = '@executable_path/../Frameworks/'
depdict = WalkFrameworkPaths(pythonFrameworkPath)
PerformChanges(depdict, [(usrLocalPath, appUsrLocalPath)], bundleExecPathAbs, libdir=True)
print("[3] Relinking dylib dependencies for klayout")
klayoutPath = bundleExecPathAbs
depdict = WalkFrameworkPaths(klayoutPath, filter_regex=r'klayout$')
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
libKlayoutPath = bundleExecPathAbs + '../Frameworks'
depdict = WalkFrameworkPaths(libKlayoutPath, filter_regex=r'libklayout')
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
print("[4] Patching site.py, pip/, and distutils/")
site_module = f"{pythonFrameworkPath}/Versions/3.6/lib/python3.6/site.py"
with open(site_module, 'r') as site:
buf = site.readlines()
with open(site_module, 'w') as site:
import re
for line in buf:
# This will fool pip into thinking it's inside a virtual environment
# and install new packates to the correct site-packages
if re.match("^PREFIXES", line) is not None:
line = line + "sys.real_prefix = sys.prefix\n"
# do not allow installation in the user folder.
if re.match("^ENABLE_USER_SITE", line) is not None:
line = "ENABLE_USER_SITE = False\n"
site.write(line)
pip_module = f"{pythonFrameworkPath}/Versions/3.6/lib/python3.6/site-packages/pip/__init__.py"
with open(pip_module, 'r') as pip:
buf = pip.readlines()
with open(pip_module, 'w') as pip:
import re
for line in buf:
# this will reject user's configuration of pip, forcing the isolated mode
line = re.sub("return isolated$", "return isolated or True", line)
pip.write(line)
distutilsconfig = f"{pythonFrameworkPath}/Versions/3.6/lib/python3.6/distutils/distutils.cfg"
with open(distutilsconfig, 'r') as file:
buf = file.readlines()
with open(distutilsconfig, 'w') as file:
import re
for line in buf:
# This will cause all packages to be installed to sys.prefix
if re.match('prefix=', line) is not None:
continue
file.write(line)
# pythonPath = bundleExecPathAbs + '../Frameworks/Python.framework/Versions/3.6/bin/'
# # pythonOriginalPrefixPath = '/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6'
# # appPythonBinPath = '@executable_path/../'
# depdict = WalkFrameworkPaths(pythonPath, filter_regex=r'python')
# print(depdict)
# PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath),
# (Path(pythonOriginalFrameworkPath).resolve(), appPythonFrameworkPath)], bundleExecPathAbs)
# usrLocalPath = '/usr/local/lib/'
# appUsrLocalPath = '@executable_path/../Frameworks/'
# depdict = WalkFrameworkPaths(pythonFrameworkPath)
# PerformChanges(depdict, [(usrLocalPath, appUsrLocalPath)], bundleExecPathAbs)

View File

@ -1,14 +1,28 @@
import site; print(site.getsitepackages())
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
def get_pip_main():
import pip
# check if pip version is new:
if int(pip.__version__.split('.')[0]) > 9:
from pip._internal import main
else:
from pip import main
return main
import sys
print("Executing from: ", sys.executable)
print("-------------")
if pip.main(['install', '--upgrade', 'numpy']) > 0:
import os
print("Environment variables:")
for variable, value in os.environ.items():
if variable == 'DROPBOX_OAUTH_BEARER':
continue
print(variable, ":", value)
pipmain = get_pip_main()
print("-------------")
if pipmain(['install', '--upgrade', 'numpy']) > 0:
exit(1)
print("-------------")
@ -16,14 +30,3 @@ print("-------------")
print("Importing numpy")
import numpy
print("-------------")
import sys;
print("Executing from: ", sys.executable)
print("-------------")
import os
print("Environment variables:")
for variable, value in os.environ.items():
print(variable, ":", value)

BIN
testdata/gds/t166.oas.gz vendored Normal file

Binary file not shown.

BIN
testdata/gds/t166_au.gds.gz vendored Normal file

Binary file not shown.

20
travis-build.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
export PING_SLEEP=30s
bash -c "while true; do echo -n '.'; sleep $PING_SLEEP; done" &
PING_LOOP_PID=$!
make build >> build.txt 2>&1
make deploy >> build.txt 2>&1
make test >> build.txt 2>&1 || true
make dropbox-deploy
tail -500 build.txt
echo "build finished"
kill $PING_LOOP_PID
exit 0