Skip to content

Instantly share code, notes, and snippets.

@josephbisch
Created September 9, 2015 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephbisch/cf2d32a798f063f0bf71 to your computer and use it in GitHub Desktop.
Save josephbisch/cf2d32a798f063f0bf71 to your computer and use it in GitHub Desktop.
Updated version of build_py3.sh script for building Python 3.4.3 using Mingw on Linux.
#!/bin/sh
CWD=$(pwd)
cd src/Python-3.4.3
# created by patches
rm -f Misc/config_mingw Misc/cross_mingw32 Python/fileblocks.c
for i in ../../patches/python3-arch/*; do patch -Np1 < $i; done
autoreconf -vfi
touch Include/graminit.h
touch Python/graminit.c
touch Parser/Python.asdl
touch Parser/asdl.py
touch Parser/asdl_c.py
touch Include/Python-ast.h
touch Python/Python-ast.c
echo \"\" > Parser/pgen.stamp
export ac_cv_working_tzset=no
export LD_LIBRARY_PATH="$CWD/lib"
conf_flags="--prefix=$CWD --host=x86_64-w64-mingw32 --build=x86_64-linux-gnu --enable-shared --with-threads --without-ensurepip"
MSYSTEM=MINGW ./configure $conf_flags OPT= CFLAGS="-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG -I$CWD/include -I$CWD/include/openssl" CXXFLAGS="-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG" LDFLAGS="-L$CWD/lib -Wl,-rpath=$CWD/lib -static -static-libgcc" CPPFLAGS="-static -I$CWD/include -I$CWD/include/openssl" LIBS="-lwsock32 -lws2_32 -lole32 -loleaut32 -lssl -lcrypto -lgdi32"
sed -i "1s|^|*static*\n|" Modules/Setup.local
MSYSTEM=MINGW ./configure $conf_flags OPT= CFLAGS="-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG -I$CWD/include -I$CWD/include/openssl" CXXFLAGS="-fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG" LDFLAGS="-L$CWD/lib -Wl,-rpath=$CWD/lib -static -static-libgcc" CPPFLAGS="-static -I$CWD/include -I$CWD/include/openssl" LIBS="-lwsock32 -lws2_32 -lole32 -loleaut32 -lssl -lcrypto -lgdi32"
sed -i "s/\#cmath cmathmodule.c _math.c/cmath cmathmodule.c _math.c/" Modules/Setup
sed -i "s/\#math mathmodule.c _math.c/math mathmodule.c _math.c/" Modules/Setup
sed -i "s/\#_struct _struct.c/_struct _struct.c/" Modules/Setup
sed -i "s/\#_random _randommodule.c/_random _randommodule.c/" Modules/Setup
#sed -i "s/\#mmap mmapmodule.c/mmap mmapmodule.c/" Modules/Setup
sed -i "s/\#_csv _csv.c/_csv _csv.c/" Modules/Setup
sed -i "s/\#_socket socketmodule.c/_socket socketmodule.c/" Modules/Setup
sed -i "s/\#_md5 md5module.c/_md5 md5module.c/" Modules/Setup
sed -i "s/\#_sha1 sha1module.c/_sha1 sha1module.c/" Modules/Setup
sed -i "s/\#_sha256 sha256module.c/_sha256 sha256module.c/" Modules/Setup
sed -i "s/\#_sha512 sha512module.c/_sha512 sha512module.c/" Modules/Setup
sed -i "s/\#binascii binascii.c/binascii binascii.c/" Modules/Setup
sed -i "s/\#_multibytecodec cjkcodecs/multibytecodec.c/_multibytecodec cjkcodecs/multibytecodec.c" Modules/Setup
sed -i "s|\#SSL=.*|SSL=$CWD|" Modules/Setup
#sed -i "s|\#SSL=.*|SSL=/usr/local|" Modules/Setup
sed -i "s|\#_ssl _ssl.c|_ssl _ssl.c|" Modules/Setup
sed -i "s|\#.*-DUSE_SSL|-DUSE_SSL|" Modules/Setup
sed -i 's|#.*-L$(SSL)/lib -lssl -lcrypto|-L$(SSL)/lib -lssl.dll -lcrypto.dll -lgdi32|' Modules/Setup
#grep -q '^_opcode _opcode.c' Modules/Setup && true || echo '_opcode _opcode.c' >> Modules/Setup
sed -i "s/_ssl_libs = \['ssl', 'crypto'\]/_ssl_libs = ['ssl', 'crypto', 'gdi32']/" setup.py
sed -i "s/^LIBS=/LIBS=-lwsock32 -lws2_32 -lole32 -loleaut32 -lgdi32 -lcrypt32 -luuid/" Makefile
sed -i 's|$(SYSLIBS)|$(LIBS)|g' Makefile
make -j4
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment