From ddba75742766597e65fa9b67fc4f83aa138a9496 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 25 Nov 2015 14:58:17 +0100 Subject: [PATCH] switch to brew based build --- README.md | 4 ++ build/Python/build.sh | 17 -------- build/PythonPackages/build.sh | 12 ------ build/boost/build.sh | 14 ------- build/build.sh | 9 ---- build/env | 16 ------- build/freetype/build.sh | 18 -------- build/jpeg/build.sh | 14 ------- build/libpng/build.sh | 12 ------ build/libtorrent/build.sh | 25 ----------- build/pip/build.sh | 6 --- build/zlib/build.sh | 12 ------ make.sh | 78 +++++++++++++++++++++++++---------- prepare.sh | 57 +++++++++++++++++++++++++ src/pull.sh | 44 -------------------- 15 files changed, 118 insertions(+), 220 deletions(-) create mode 100644 README.md delete mode 100755 build/Python/build.sh delete mode 100755 build/PythonPackages/build.sh delete mode 100755 build/boost/build.sh delete mode 100755 build/build.sh delete mode 100644 build/env delete mode 100755 build/freetype/build.sh delete mode 100755 build/jpeg/build.sh delete mode 100755 build/libpng/build.sh delete mode 100755 build/libtorrent/build.sh delete mode 100755 build/pip/build.sh delete mode 100755 build/zlib/build.sh create mode 100755 prepare.sh delete mode 100755 src/pull.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ee1f907 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Build Python environment for OS X + +those scripts are used to build the python environment for OML + diff --git a/build/Python/build.sh b/build/Python/build.sh deleted file mode 100755 index 39d2ae8..0000000 --- a/build/Python/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=Python-3.4.1 -rm -rf $name -mkdir $name -cd $name - - -$src/$name/configure \ - --prefix=$prefix -make && make install -install_name_tool -add_rpath @loader_path/../lib $prefix/bin/python3 - -install_name_tool -change "$prefix/lib/libz.1.dylib" "@rpath/libz.1.dylib" $prefix/lib/python3.4/lib-dynload/binascii.so -install_name_tool -change "$prefix/lib/libz.1.dylib" "@rpath/libz.1.dylib" $prefix/lib/python3.4/lib-dynload/zlib.so diff --git a/build/PythonPackages/build.sh b/build/PythonPackages/build.sh deleted file mode 100755 index 32e1975..0000000 --- a/build/PythonPackages/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -export PIP_DOWNLOAD_CACHE=`pwd`/pip_cache - -$prefix/bin/pip3 install -r ../../../openmedialibrary/requirements.txt -$prefix/bin/pip3 install -U pillow - -install_name_tool -change "$prefix/lib/libjpeg.62.dylib" "@rpath/libjpeg.62.dylib" $prefix/lib/python3.4/site-packages/PIL/_imaging.so -install_name_tool -change "$prefix/lib/libz.1.dylib" "@rpath/libz.1.dylib" $prefix/lib/python3.4/site-packages/PIL/_imaging.so -install_name_tool -change "$prefix/lib/libfreetype.6.dylib" "@rpath/libfreetype.6.dylib" $prefix/lib/python3.4/site-packages/PIL/_imagingft.so diff --git a/build/boost/build.sh b/build/boost/build.sh deleted file mode 100755 index fd86931..0000000 --- a/build/boost/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=boost_1_53_0 -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -export PATH=$prefix/bin:$PATH -./bootstrap.sh \ - --prefix=$prefix \ - --with-python=$prefix/bin/python -./b2 install diff --git a/build/build.sh b/build/build.sh deleted file mode 100755 index d8d0127..0000000 --- a/build/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cd `dirname $0` -./zlib/build.sh -./jpeg/build.sh -./libpng/build.sh -./freetype/build.sh -./Python/build.sh -./pip/build.sh -./PythonPackages/build.sh diff --git a/build/env b/build/env deleted file mode 100644 index ea20d7b..0000000 --- a/build/env +++ /dev/null @@ -1,16 +0,0 @@ -build=`pwd` -cd ../.. -base=`pwd` -dist=$base/dist -src=$base/src -prefix=$base - -export PATH=$base/osx/build/bin:$PATH -export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=0 -export PKG_CONFIG_ALLOW_SYSTEM_LIBS=0 -export PKG_CONFIG_LIBDIR=$prefix/lib/pkgconfig -export PKG_CONFIG_PATH=$prefix/lib/pkgconfig -#export CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5" -#export LDFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5" - -cd $build diff --git a/build/freetype/build.sh b/build/freetype/build.sh deleted file mode 100755 index bb7e18e..0000000 --- a/build/freetype/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=freetype-2.5.0 -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -export PATH=$prefix/bin:$PATH - -./configure \ - --without-zlib \ - --prefix=$prefix -make && make install -install_name_tool -change "$prefix/lib/libz.1.dylib" "@rpath/libz.1.dylib" $prefix/lib/libfreetype.6.dylib -install_name_tool -change "$prefix/lib/libpng12.0.dylib" "@rpath/libpng12.0.dylib" $prefix/lib/libfreetype.6.dylib - diff --git a/build/jpeg/build.sh b/build/jpeg/build.sh deleted file mode 100755 index 40b16ff..0000000 --- a/build/jpeg/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=jpeg-6b -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -mkdir -p $prefix/man/man1/ -./configure \ - --enable-shared \ - --prefix=$prefix -make LIBTOOL=glibtool && make install LIBTOOL=glibtool diff --git a/build/libpng/build.sh b/build/libpng/build.sh deleted file mode 100755 index 2435ad2..0000000 --- a/build/libpng/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=libpng-1.2.51 -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -./configure \ - --prefix=$prefix -make && make install diff --git a/build/libtorrent/build.sh b/build/libtorrent/build.sh deleted file mode 100755 index dd576d6..0000000 --- a/build/libtorrent/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=libtorrent-rasterbar-0.16.12 -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -export PATH=$prefix/bin:$PATH - -sed "s/if platform.system() != 'Darwin': //g" bindings/python/setup.py.in > setup.py.in -mv setup.py.in bindings/python/setup.py.in - -#breaks boost 1.54 -# --disable-encryption \ - -./configure \ - --enable-python-binding \ - --with-boost=$prefix \ - --prefix=$prefix -make && make install -install_name_tool -change "$prefix/lib/libtorrent-rasterbar.7.dylib" "@rpath/libtorrent-rasterbar.7.dylib" $prefix/lib/python2.7/site-packages/libtorrent.so -install_name_tool -change "libboost_system.dylib" "@rpath/libboost_system.dylib" $prefix/lib/python2.7/site-packages/libtorrent.so -install_name_tool -change libboost_system.dylib @rpath/libboost_system.dylib $prefix/lib/libtorrent-rasterbar.7.dylib diff --git a/build/pip/build.sh b/build/pip/build.sh deleted file mode 100755 index 24a7dd3..0000000 --- a/build/pip/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -$prefix/bin/python $src/ez_setup.py -$prefix/bin/easy_install pip diff --git a/build/zlib/build.sh b/build/zlib/build.sh deleted file mode 100755 index 5d08fc2..0000000 --- a/build/zlib/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -cd `dirname $0` -. ../env - -name=zlib-1.2.8 -rm -rf $name -tar xzf $src/$name.tar.gz -cd $name - -./configure \ - --prefix=$prefix -make && make install diff --git a/make.sh b/make.sh index 1f140e5..ecba16f 100755 --- a/make.sh +++ b/make.sh @@ -1,39 +1,75 @@ +#!/bin/bash cd `dirname $0` -#./src/pull.sh -#./build/build.sh +target=Darwin +brew=$HOME/.local +python_base=$HOME/python +base=$brew/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5 -rm -rf dist -mkdir -p dist/bin dist/lib dist/include +if [ ! -e $python_base ]; then + echo prepare your installation before creating the distributable version + echo read prepare.sh and run it + exit 1 +fi + +rm -rf $target +mkdir -p $target/bin $target/lib $target/include for bin in \ python3 \ - python3.4 \ + python3.5 \ ; do - cp -a bin/$bin dist/bin/$bin + cp -a $python_base/bin/$bin $target/bin/$python_bin done for bin in \ pip3 \ ; do - sed "s/#\!.*python.*/#\!\/usr\/bin\/env python3/g" bin/$bin > dist/bin/$bin + sed "s/#\!.*python.*/#\!\/usr\/bin\/env python3/g" bin/$bin > $target/bin/$bin done -cp -a lib/python3.4 dist/lib/python3.4 -cp -a include/python3.4m dist/include/python3.4m -rm -r dist/lib/python3.4/test -find dist/ -name __pycache__ -type d | xargs rm -r - -# libboost_system.dylib \ -# libtorrent-rasterbar.7.dylib \ -# libtorrent-rasterbar.dylib \ +cp -a $base/lib/python3.5 $target/lib/python3.5 +rm $target/lib/python3.5/site-packages +rsync -a lib/python3.5/site-packages/ $target/lib/python3.5/site-packages/ +cp -a $base/include/python3.5m $target/include/python3.5m +rm -r $target/lib/python3.5/test +find $target/ -name __pycache__ -type d | xargs rm -r for lib in \ - libfreetype.6.dylib \ - libpng12.0.dylib \ - libjpeg.62.dylib \ - libz.1.dylib \ - libz.1.2.8.dylib \ + opt/libxml2/lib/libxml2.2.dylib \ + opt/libxslt/lib/libexslt.0.dylib \ + opt/libxslt/lib/libxslt.1.dylib \ + opt/openssl/lib/libcrypto.1.0.0.dylib \ + opt/openssl/lib/libssl.1.0.0.dylib \ + opt/readline/lib/libreadline.6.dylib \ + opt/sqlite/lib/libsqlite3.0.dylib \ + opt/xz/lib/liblzma.5.dylib \ ; do - cp -a lib/$lib dist/lib/$lib + cp -a ./$lib $target/lib/$(basename $lib) +done + +for plib in \ + $target/lib/python3.5/site-packages/lxml/etree.cpython-35m-darwin.so \ + $target/lib/python3.5/site-packages/lxml/objectify.cpython-35m-darwin.so \ + $target/lib/python3.5/lib-dynload/_hashlib.cpython-35m-darwin.so \ + $target/lib/python3.5/lib-dynload/_lzma.cpython-35m-darwin.so \ + $target/lib/python3.5/lib-dynload/_sqlite3.cpython-35m-darwin.so \ + $target/lib/python3.5/lib-dynload/_ssl.cpython-35m-darwin.so \ + $target/lib/python3.5/lib-dynload/readline.cpython-35m-darwin.so \ +; do + for lib in \ + opt/libxml2/lib/libxml2.2.dylib \ + opt/libxslt/lib/libexslt.0.dylib \ + opt/libxslt/lib/libxslt.1.dylib \ + opt/openssl/lib/libcrypto.1.0.0.dylib \ + opt/openssl/lib/libssl.1.0.0.dylib \ + opt/readline/lib/libreadline.6.dylib \ + opt/sqlite/lib/libsqlite3.0.dylib \ + opt/xz/lib/liblzma.5.dylib \ + ; do + name=$(basename $lib) + fullpath=$brew/$lib + install_name_tool -change "$fullpath" "@rpath/$name" $plib + done + otool -L $plib done diff --git a/prepare.sh b/prepare.sh new file mode 100755 index 0000000..59c772d --- /dev/null +++ b/prepare.sh @@ -0,0 +1,57 @@ +#!/bin/bash +cd `dirname $0` +set -e + +if [ ! -e ~/.local ]; then + mkdir -p ~/.local + curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C ~/.local + mkdir -p ~/.local + mkdir homebrew && curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C ~/.local + + cat >> ~/.bashrc << EOF +. ~/.bash_profile +EOF + cat >> ~/.bash_profile << EOF +export PATH="$HOME/.local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin" +export HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew" +EOF + . ~/.bash_profile + brew update +fi + +brew install openssl +brew install sqlite +brew install xz + +brew install python3 +pip3 install --upgrade pip setuptools +brew install libxml2 +brew install libxslt +brew link libxml2 --force +brew link libxslt --force + +curl https://git.0x2620.org/openmedialibrary.git/blob_plain/HEAD:/requirements.txt > requirements.txt +pip3 install -r requirements.txt + +tar xf ~/Library/Caches/Homebrew/python3-3.5.0.tar.xz +cd Python-3.5.0 +patch -p1 < ~/Library/Caches/Homebrew/python3--patch-029cc0dc72b1bcf4ddc5f913cc4a3fd970378073c6355921891f041aca2f8b12.diff + +prefix=$HOME/python +./configure \ + --prefix=$prefix \ + --enable-ipv6 \ + --datarootdir=$prefix/share \ + --datadir=$prefix/share \ + --without-gcc MACOSX_DEPLOYMENT_TARGET=10.11 + +CPPFLAGS="-I$brew/opt/openssl/include/openssl" +LDFLAGS="" +for pkg in openssl sqlite readline gdbm xz; do + CPPFLAGS="$CPPFLAGS -I$brew/opt/$pkg/include" + LDFLAGS="$LDFLAGS -L$brew/opt/$pkg/lib" +done +export CPPFLAGS +export LDFLAGS +make +make install PYTHONAPPSDIR=$prefix diff --git a/src/pull.sh b/src/pull.sh deleted file mode 100755 index 533f971..0000000 --- a/src/pull.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -cd `dirname $0` -base=`pwd` - -git_repository() { - name=$1 - url=$2 - echo get $name from $url - test -e $name || git clone $url $name - cd $name - git pull - cd $base -} -svn_repository() { - name=$1 - url=$2 - echo get $name from $url - test -e $name || svn co $url $name - cd $name - svn update - cd $base -} -tarball() { - name=$1 - url=$2 - echo get $name from $url - test -e $name || ( curl -L $url > $name.tar.gz && tar xzf $name.tar.gz && rm $name.tar.gz ) -} - -file() { - name=$1 - url=$2 - echo get $name from $url - test -e $name || (curl -L $url > $name) -} - -tarball Python-3.4.1 http://python.org/ftp/python/3.4.1/Python-3.4.1.tgz -file ez_setup.py https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py - -file zlib-1.2.8.tar.gz http://zlib.net/zlib-1.2.8.tar.gz -file jpeg-6b.tar.gz http://optimate.dl.sourceforge.net/project/libjpeg/libjpeg/6b/jpegsrc.v6b.tar.gz -file libpng-1.2.51.tar.gz http://dfn.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.51.tar.gz -file freetype-2.5.0.tar.gz http://download.savannah.gnu.org/releases-redirect/freetype/freetype-2.5.0.tar.gz -