migrate to python3.7

This commit is contained in:
j 2019-01-10 15:15:21 +05:30
parent 3466c4746a
commit 1753075ff3

View file

@ -2,11 +2,10 @@
cd `dirname $0` cd `dirname $0`
set -e set -e
BREW="$HOME/.local"
BREW="`pwd`/brew" BREW="`pwd`/brew"
PREFIX="`pwd`/dist" PREFIX="`pwd`/dist"
OSXVERSION=10.8 OSXVERSION=10.8
pyversion=3.5.2 pyversion=3.7.2
export PATH="$BREW/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin" export PATH="$BREW/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
export HOMEBREW_NO_ANALYTICS=1 export HOMEBREW_NO_ANALYTICS=1
@ -27,6 +26,7 @@ function brew_install {
brew_install openssl brew_install openssl
brew_install sqlite brew_install sqlite
brew_install xz brew_install xz
brew_install zlib
brew_install readline brew_install readline
brew_install libxml2 brew_install libxml2
@ -35,13 +35,32 @@ brew_install libxslt
# Python # Python
CPPFLAGS="-I$BREW/opt/openssl/include/openssl" CPPFLAGS="-I$BREW/opt/openssl/include/openssl"
LDFLAGS="" LDFLAGS=""
for pkg in openssl sqlite readline xz; do for pkg in openssl sqlite readline xz zlib; do
CPPFLAGS="$CPPFLAGS -I$BREW/opt/$pkg/include" CPPFLAGS="$CPPFLAGS -I$BREW/opt/$pkg/include"
LDFLAGS="$LDFLAGS -L$BREW/opt/$pkg/lib" LDFLAGS="$LDFLAGS -L$BREW/opt/$pkg/lib"
done done
export CPPFLAGS export CPPFLAGS
export LDFLAGS export LDFLAGS
mkdir -p "$PREFIX/lib"
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.7.dylib \
opt/readline/lib/libreadline.7.0.dylib \
opt/sqlite/lib/libsqlite3.0.dylib \
opt/xz/lib/liblzma.5.dylib \
opt/zlib/lib/libz.1.dylib \
opt/zlib/lib/libz.1.2.11.dylib \
; do
target="$PREFIX/lib/`basename "$lib"`"
rm -f "$target"
cp -a "$BREW/$lib" "$target"
done
url="https://www.python.org/ftp/python/${pyversion}/Python-${pyversion}.tar.xz" url="https://www.python.org/ftp/python/${pyversion}/Python-${pyversion}.tar.xz"
name=`basename $url .tar.xz` name=`basename $url .tar.xz`
tar=`basename $url` tar=`basename $url`
@ -49,16 +68,16 @@ tar=`basename $url`
test -e $tar || curl -O $url test -e $tar || curl -O $url
test -e $name || tar xf $tar test -e $name || tar xf $tar
cd $name cd $name
./configure MACOSX_DEPLOYMENT_TARGET=$OSXVERSION --prefix="$PREFIX" ./configure MACOSX_DEPLOYMENT_TARGET=$OSXVERSION --with-openssl=$BREW/opt/openssl --prefix="$PREFIX"
make -j8 make -j8
make altinstall make altinstall
unset CPPFLAGS unset CPPFLAGS
unset LDFLAGS unset LDFLAGS
ln -sf pip3.5 "$PREFIX/bin/pip" ln -sf pip3.7 "$PREFIX/bin/pip"
ln -sf pip3.5 "$PREFIX/bin/pip3" ln -sf pip3.7 "$PREFIX/bin/pip3"
ln -sf python3.5 "$PREFIX/bin/python3" ln -sf python3.7 "$PREFIX/bin/python3"
PATH="$PREFIX/bin:$PATH" PATH="$PREFIX/bin:$PATH"
hash -r 2>/dev/null hash -r 2>/dev/null
@ -68,21 +87,6 @@ cd "$BASE"
curl https://git.0x2620.org/openmedialibrary.git/blob_plain/HEAD:/requirements.txt > requirements.txt curl https://git.0x2620.org/openmedialibrary.git/blob_plain/HEAD:/requirements.txt > requirements.txt
$PREFIX/bin/pip3 install -r 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" chmod -R +rw "$PREFIX/lib"
mkdir -p "$PREFIX/etc/openssl/certs" mkdir -p "$PREFIX/etc/openssl/certs"
cp $BREW/etc/openssl/cert.pem "$PREFIX/etc/openssl" cp $BREW/etc/openssl/cert.pem "$PREFIX/etc/openssl"
@ -95,15 +99,15 @@ rm -rf \
"$PREFIX/bin/openssl" \ "$PREFIX/bin/openssl" \
"$PREFIX/etc/openssl/man" \ "$PREFIX/etc/openssl/man" \
"$PREFIX/bin/c_rehash" \ "$PREFIX/bin/c_rehash" \
"$PREFIX/bin/2to3-3.5" \ "$PREFIX/bin/2to3-3.7" \
"$PREFIX/bin/easy_install-3.5" \ "$PREFIX/bin/easy_install-3.7" \
"$PREFIX/bin/idle3.5" \ "$PREFIX/bin/idle3.7" \
"$PREFIX/bin/pyvenv-3.5" \ "$PREFIX/bin/pyvenv-3.7" \
"$PREFIX/bin/c_rehash" \ "$PREFIX/bin/c_rehash" \
"$PREFIX/bin/pydoc3.5" "$PREFIX/bin/pydoc3.7"
for bin in $PREFIX/bin/pip3.5 $PREFIX/bin/python3.5m-config; do for bin in $PREFIX/bin/pip3.7 $PREFIX/bin/python3.7m-config; do
sed "s#$PREFIX/bin/python3.5#/usr/bin/env python3.5#g" "$bin" > "$bin.t" sed "s#$PREFIX/bin/python3.7#/usr/bin/env python3.7#g" "$bin" > "$bin.t"
mv "$bin.t" "$bin" mv "$bin.t" "$bin"
chmod +x "$bin" chmod +x "$bin"
done done
@ -113,13 +117,14 @@ find "$PREFIX" -name "*.pyc" -exec rm "{}" \;
find "$PREFIX" -name "*.a" -exec rm -f "{}" \; find "$PREFIX" -name "*.a" -exec rm -f "{}" \;
for plib in \ for plib in \
$PREFIX/lib/python3.5/site-packages/lxml/etree.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/site-packages/lxml/objectify.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/site-packages/lxml/objectify.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/lib-dynload/_hashlib.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/lib-dynload/_hashlib.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/lib-dynload/_lzma.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/lib-dynload/_lzma.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/lib-dynload/_sqlite3.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/lib-dynload/_ssl.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so \
$PREFIX/lib/python3.5/lib-dynload/readline.cpython-35m-darwin.so \ $PREFIX/lib/python3.7/lib-dynload/readline.cpython-37m-darwin.so \
$PREFIX/lib/python3.7/lib-dynload/zlib.cpython-37m-darwin.so \
; do ; do
if [ -e "$plib" ]; then if [ -e "$plib" ]; then
for lib in \ for lib in \
@ -130,10 +135,11 @@ for plib in \
$BREW/opt/libxslt/lib/libxslt.1.dylib \ $BREW/opt/libxslt/lib/libxslt.1.dylib \
$BREW/opt/openssl/lib/libcrypto.1.0.0.dylib \ $BREW/opt/openssl/lib/libcrypto.1.0.0.dylib \
$BREW/opt/openssl/lib/libssl.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.7.dylib \
$BREW/opt/readline/lib/libreadline.6.3.dylib \ $BREW/opt/readline/lib/libreadline.7.0.dylib \
$BREW/opt/sqlite/lib/libsqlite3.0.dylib \ $BREW/opt/sqlite/lib/libsqlite3.0.dylib \
$BREW/opt/xz/lib/liblzma.5.dylib \ $BREW/opt/xz/lib/liblzma.5.dylib \
$BREW/opt/zlib/lib/libz.1.dylib \
$PREFIX/lib/libcrypto.1.0.0.dylib \ $PREFIX/lib/libcrypto.1.0.0.dylib \
$PREFIX/lib/libexslt.0.dylib \ $PREFIX/lib/libexslt.0.dylib \
$PREFIX/lib/liblzma.5.dylib \ $PREFIX/lib/liblzma.5.dylib \