update build script
This commit is contained in:
parent
2927f4c5d6
commit
3466c4746a
4 changed files with 158 additions and 139 deletions
|
@ -1,4 +1,3 @@
|
||||||
# Build Python environment for OS X
|
# Build Python environment for OS X
|
||||||
|
|
||||||
those scripts are used to build the python environment for OML
|
Build OS X Python environment for OML, XCode must to be installed.
|
||||||
|
|
||||||
|
|
157
build.sh
Executable file
157
build.sh
Executable file
|
@ -0,0 +1,157 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cd `dirname $0`
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BREW="$HOME/.local"
|
||||||
|
BREW="`pwd`/brew"
|
||||||
|
PREFIX="`pwd`/dist"
|
||||||
|
OSXVERSION=10.8
|
||||||
|
pyversion=3.5.2
|
||||||
|
|
||||||
|
export PATH="$BREW/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
|
||||||
|
export HOMEBREW_NO_ANALYTICS=1
|
||||||
|
export HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew"
|
||||||
|
|
||||||
|
if [ ! -e $BREW ]; then
|
||||||
|
mkdir -p $BREW
|
||||||
|
curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C $BREW
|
||||||
|
fi
|
||||||
|
brew update
|
||||||
|
|
||||||
|
function brew_install {
|
||||||
|
pkg=$1
|
||||||
|
brew list | grep -q $pkg || brew install $pkg
|
||||||
|
brew outdated $pkg || brew upgrade $pkg
|
||||||
|
}
|
||||||
|
|
||||||
|
brew_install openssl
|
||||||
|
brew_install sqlite
|
||||||
|
brew_install xz
|
||||||
|
brew_install readline
|
||||||
|
|
||||||
|
brew_install libxml2
|
||||||
|
brew_install libxslt
|
||||||
|
|
||||||
|
# Python
|
||||||
|
CPPFLAGS="-I$BREW/opt/openssl/include/openssl"
|
||||||
|
LDFLAGS=""
|
||||||
|
for pkg in openssl sqlite readline xz; do
|
||||||
|
CPPFLAGS="$CPPFLAGS -I$BREW/opt/$pkg/include"
|
||||||
|
LDFLAGS="$LDFLAGS -L$BREW/opt/$pkg/lib"
|
||||||
|
done
|
||||||
|
export CPPFLAGS
|
||||||
|
export LDFLAGS
|
||||||
|
|
||||||
|
url="https://www.python.org/ftp/python/${pyversion}/Python-${pyversion}.tar.xz"
|
||||||
|
name=`basename $url .tar.xz`
|
||||||
|
tar=`basename $url`
|
||||||
|
|
||||||
|
test -e $tar || curl -O $url
|
||||||
|
test -e $name || tar xf $tar
|
||||||
|
cd $name
|
||||||
|
./configure MACOSX_DEPLOYMENT_TARGET=$OSXVERSION --prefix="$PREFIX"
|
||||||
|
make -j8
|
||||||
|
make altinstall
|
||||||
|
|
||||||
|
unset CPPFLAGS
|
||||||
|
unset LDFLAGS
|
||||||
|
|
||||||
|
ln -sf pip3.5 "$PREFIX/bin/pip"
|
||||||
|
ln -sf pip3.5 "$PREFIX/bin/pip3"
|
||||||
|
ln -sf python3.5 "$PREFIX/bin/python3"
|
||||||
|
|
||||||
|
PATH="$PREFIX/bin:$PATH"
|
||||||
|
hash -r 2>/dev/null
|
||||||
|
|
||||||
|
cd "$BASE"
|
||||||
|
|
||||||
|
curl https://git.0x2620.org/openmedialibrary.git/blob_plain/HEAD:/requirements.txt > requirements.txt
|
||||||
|
$PREFIX/bin/pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
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/readline/lib/libreadline.6.3.dylib \
|
||||||
|
opt/sqlite/lib/libsqlite3.0.dylib \
|
||||||
|
opt/xz/lib/liblzma.5.dylib \
|
||||||
|
; do
|
||||||
|
target="$PREFIX/lib/`basename "$lib"`"
|
||||||
|
rm -f "$target"
|
||||||
|
cp -a "$BREW/$lib" "$target"
|
||||||
|
done
|
||||||
|
chmod -R +rw "$PREFIX/lib"
|
||||||
|
mkdir -p "$PREFIX/etc/openssl/certs"
|
||||||
|
cp $BREW/etc/openssl/cert.pem "$PREFIX/etc/openssl"
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
rm -rf \
|
||||||
|
"$PREFIX/lib/python3.5/test" \
|
||||||
|
"$PREFIX/bin/*.py" \
|
||||||
|
"$PREFIX/bin/edsig" \
|
||||||
|
"$PREFIX/bin/openssl" \
|
||||||
|
"$PREFIX/etc/openssl/man" \
|
||||||
|
"$PREFIX/bin/c_rehash" \
|
||||||
|
"$PREFIX/bin/2to3-3.5" \
|
||||||
|
"$PREFIX/bin/easy_install-3.5" \
|
||||||
|
"$PREFIX/bin/idle3.5" \
|
||||||
|
"$PREFIX/bin/pyvenv-3.5" \
|
||||||
|
"$PREFIX/bin/c_rehash" \
|
||||||
|
"$PREFIX/bin/pydoc3.5"
|
||||||
|
|
||||||
|
for bin in $PREFIX/bin/pip3.5 $PREFIX/bin/python3.5m-config; do
|
||||||
|
sed "s#$PREFIX/bin/python3.5#/usr/bin/env python3.5#g" "$bin" > "$bin.t"
|
||||||
|
mv "$bin.t" "$bin"
|
||||||
|
chmod +x "$bin"
|
||||||
|
done
|
||||||
|
|
||||||
|
find "$PREFIX" -d -name "__pycache__" -type d -exec rm -r "{}" \;
|
||||||
|
find "$PREFIX" -name "*.pyc" -exec rm "{}" \;
|
||||||
|
find "$PREFIX" -name "*.a" -exec rm -f "{}" \;
|
||||||
|
|
||||||
|
for plib in \
|
||||||
|
$PREFIX/lib/python3.5/site-packages/lxml/etree.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/site-packages/lxml/objectify.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/lib-dynload/_hashlib.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/lib-dynload/_lzma.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/lib-dynload/_sqlite3.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/lib-dynload/_ssl.cpython-35m-darwin.so \
|
||||||
|
$PREFIX/lib/python3.5/lib-dynload/readline.cpython-35m-darwin.so \
|
||||||
|
; do
|
||||||
|
if [ -e "$plib" ]; then
|
||||||
|
for lib in \
|
||||||
|
$BREW/Cellar/libxslt/1.1.28_1/lib/libxslt.1.dylib \
|
||||||
|
$BREW/Cellar/openssl/1.0.2d_1/lib/libcrypto.1.0.0.dylib \
|
||||||
|
$BREW/opt/libxml2/lib/libxml2.2.dylib \
|
||||||
|
$BREW/opt/libxslt/lib/libexslt.0.dylib \
|
||||||
|
$BREW/opt/libxslt/lib/libxslt.1.dylib \
|
||||||
|
$BREW/opt/openssl/lib/libcrypto.1.0.0.dylib \
|
||||||
|
$BREW/opt/openssl/lib/libssl.1.0.0.dylib \
|
||||||
|
$BREW/opt/readline/lib/libreadline.6.dylib \
|
||||||
|
$BREW/opt/readline/lib/libreadline.6.3.dylib \
|
||||||
|
$BREW/opt/sqlite/lib/libsqlite3.0.dylib \
|
||||||
|
$BREW/opt/xz/lib/liblzma.5.dylib \
|
||||||
|
$PREFIX/lib/libcrypto.1.0.0.dylib \
|
||||||
|
$PREFIX/lib/libexslt.0.dylib \
|
||||||
|
$PREFIX/lib/liblzma.5.dylib \
|
||||||
|
$PREFIX/lib/libreadline.6.dylib \
|
||||||
|
$PREFIX/lib/libreadline.6.3.dylib \
|
||||||
|
$PREFIX/lib/libsqlite3.0.dylib \
|
||||||
|
$PREFIX/lib/libssl.1.0.0.dylib \
|
||||||
|
$PREFIX/lib/libxml2.2.dylib \
|
||||||
|
$PREFIX/lib/libxslt.1.dylib \
|
||||||
|
/usr/lib/libexslt.0.dylib \
|
||||||
|
/usr/lib/libreadline.6.dylib \
|
||||||
|
/usr/lib/libreadline.6.3.dylib \
|
||||||
|
/usr/lib/libxml2.2.dylib \
|
||||||
|
/usr/lib/libxslt.1.dylib \
|
||||||
|
; do
|
||||||
|
name=`basename $lib`
|
||||||
|
otool -L "$plib" | grep -q "$lib" && install_name_tool -change "$lib" "@executable_path/../lib/$name" "$plib"
|
||||||
|
done
|
||||||
|
otool -L "$plib"
|
||||||
|
fi
|
||||||
|
done
|
81
make.sh
81
make.sh
|
@ -1,81 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd `dirname $0`
|
|
||||||
|
|
||||||
target=Darwin
|
|
||||||
brew=$HOME/.local
|
|
||||||
python_base=$HOME/python
|
|
||||||
base=$brew/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5
|
|
||||||
|
|
||||||
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.5 \
|
|
||||||
; do
|
|
||||||
cp -a $python_base/bin/$bin $target/bin/$python_bin
|
|
||||||
done
|
|
||||||
|
|
||||||
for bin in \
|
|
||||||
pip3 \
|
|
||||||
; do
|
|
||||||
sed "s/#\!.*python.*/#\!\/usr\/bin\/env python3/g" $brew/bin/$bin > $target/bin/$bin
|
|
||||||
done
|
|
||||||
|
|
||||||
cp -a $base/lib/python3.5 $target/lib/python3.5
|
|
||||||
rm $target/lib/python3.5/site-packages
|
|
||||||
rsync -a $brew/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 \
|
|
||||||
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 $brew/$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 \
|
|
||||||
$target/lib/libexslt.0.dylib \
|
|
||||||
$target/lib/libxslt.1.dylib \
|
|
||||||
$target/lib/libcrypto.1.0.0.dylib \
|
|
||||||
$target/lib/libssl.1.0.0.dylib \
|
|
||||||
; do
|
|
||||||
for lib in \
|
|
||||||
Cellar/libxslt/1.1.28_1/lib/libxslt.1.dylib \
|
|
||||||
Cellar/openssl/1.0.2d_1/lib/libcrypto.1.0.0.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
|
|
||||||
name=$(basename $lib)
|
|
||||||
fullpath=$brew/$lib
|
|
||||||
install_name_tool -change "$fullpath" "@rpath/$name" $plib
|
|
||||||
done
|
|
||||||
otool -L $plib
|
|
||||||
done
|
|
56
prepare.sh
56
prepare.sh
|
@ -1,56 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd `dirname $0`
|
|
||||||
set -e
|
|
||||||
|
|
||||||
brew=$HOME/.local
|
|
||||||
prefix=$HOME/python
|
|
||||||
|
|
||||||
export PATH="$brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
|
|
||||||
export HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew"
|
|
||||||
|
|
||||||
if [ ! -e $brew ]; then
|
|
||||||
mkdir -p $brew
|
|
||||||
curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C $brew
|
|
||||||
mkdir -p $brew
|
|
||||||
mkdir homebrew && curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C $brew
|
|
||||||
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
|
|
||||||
|
|
||||||
name=Python-3.5.0
|
|
||||||
rm -rf $name
|
|
||||||
tar xf $HOMEBREW_CACHE/python3-3.5.0.tar.xz
|
|
||||||
cd $name
|
|
||||||
patch -p1 < $HOMEBREW_CACHE/python3--patch-029cc0dc72b1bcf4ddc5f913cc4a3fd970378073c6355921891f041aca2f8b12.diff
|
|
||||||
|
|
||||||
export PATH="$prefix/bin:$PATH"
|
|
||||||
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
|
|
||||||
|
|
||||||
./configure \
|
|
||||||
--prefix=$prefix \
|
|
||||||
--enable-ipv6 \
|
|
||||||
--datarootdir=$prefix/share \
|
|
||||||
--datadir=$prefix/share \
|
|
||||||
--without-gcc MACOSX_DEPLOYMENT_TARGET=10.11
|
|
||||||
|
|
||||||
make
|
|
||||||
make install PYTHONAPPSDIR=$prefix
|
|
Loading…
Reference in a new issue