|
| 1 | +#!/bin/bash |
| 2 | +# Need to build linux wheel using manylinux |
| 3 | +# |
| 4 | +# https://github.com/pypa/manylinux |
| 5 | +# https://github.com/pypa/python-manylinux-demo |
| 6 | +# https://www.python.org/dev/peps/pep-0513/ |
| 7 | +# |
| 8 | +# You may need to make the build script executable |
| 9 | +# chmod +x /dev/build_wheels.sh |
| 10 | +# |
| 11 | +# Standard manylinux docker containers provided by pypa. For more information see the links above. |
| 12 | +# docker pull quay.io/pypa/manylinux1_x86_64 |
| 13 | +# docker pull quay.io/pypa/manylinux1_i686 |
| 14 | +# |
| 15 | +# The next set of instructions will let you run the container interactively |
| 16 | +# Provide a container name so it is easier to reference later |
| 17 | +# sudo docker run --name manylinux_x86_x64 -it -d --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 |
| 18 | +# docker ps |
| 19 | +# |
| 20 | +# Use the docker exec command to interact with our container |
| 21 | +# docker exec -it manylinux_x86_x64 ls |
| 22 | +# docker exec -it manylinux_x86_x64 ./io/dev/build_wheels.sh |
| 23 | +# |
| 24 | +# Stop the conatiner when done |
| 25 | +# docker stop manylinux_x86_x64 |
| 26 | +# |
| 27 | +# These docker commands will run, build the wheel, attempt to install and then finally upload |
| 28 | +# docker run --name manylinux_x86_x64 --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/dev/build_wheels.sh |
| 29 | +# docker run --name manylinux_i686 --rm -v `pwd`:/io quay.io/pypa/manylinux1_i686 /io/dev/build_wheels.sh |
| 30 | +# |
| 31 | +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html |
| 32 | +set -e -x |
| 33 | + |
| 34 | +# Remove freetds package distributed with the repo if present. |
| 35 | +rm -rf /io/freetds0.95 |
| 36 | + |
| 37 | +# Install freetds and use in build. Yum channel shows version 0.91. Retrieving latest stable release for builds. |
| 38 | +export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1 |
| 39 | + |
| 40 | +rm -rf /io/freetds |
| 41 | +mkdir /io/freetds |
| 42 | +curl -sS ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz > freetds.tar.gz |
| 43 | +tar -zxvf freetds.tar.gz -C /io/freetds --strip-components=1 |
| 44 | + |
| 45 | +export CFLAGS="-fPIC" # for the 64 bits version |
| 46 | + |
| 47 | +pushd /io/freetds |
| 48 | +./configure --enable-msdblib \ |
| 49 | + --prefix=/usr --sysconfdir=/etc/freetds --with-tdsver=7.1 \ |
| 50 | + --disable-apps --disable-server --disable-pool --disable-odbc \ |
| 51 | + --with-openssl=no --with-gnutls=no |
| 52 | + |
| 53 | +make install |
| 54 | +popd |
| 55 | + |
| 56 | + |
| 57 | +#Make wheelhouse directory if it doesn't exist yet |
| 58 | +mkdir /io/wheelhouse |
| 59 | + |
| 60 | +# Install Python dependencies and compile wheels |
| 61 | +for PYBIN in /opt/python/*/bin; do |
| 62 | + "${PYBIN}/pip" install --upgrade pip setuptools |
| 63 | + "${PYBIN}/pip" install pytest SQLAlchemy Sphinx sphinx-rtd-theme Cython wheel |
| 64 | + "${PYBIN}/pip" wheel /io/ -w /io/wheelhouse/ |
| 65 | +done |
| 66 | + |
| 67 | +# Verify the wheels and move from *-linux_* to -manylinux_* |
| 68 | +for whl in /io/wheelhouse/*.whl; do |
| 69 | + auditwheel repair "$whl" -w /io/wheelhouse/ |
| 70 | +done |
| 71 | + |
| 72 | +# Remove non manylinux wheels |
| 73 | +find /io/wheelhouse/ -type f ! -name '*manylinux*' -delete |
| 74 | + |
| 75 | +# Create .tar.gz dist if it doesn't exists. |
| 76 | +if [ ! -f /io/dist/*tar.gz* ]; then |
| 77 | + mkdir /io/dist |
| 78 | + pushd /io/ |
| 79 | + /opt/python/cp36-cp36m/bin/python setup.py sdist |
| 80 | + popd |
| 81 | +fi |
| 82 | + |
| 83 | +# Move wheels to dist for install and upload |
| 84 | +mv /io/wheelhouse/* /io/dist/ |
| 85 | + |
| 86 | +# Remove wheel and egg directory for next container build (i686 vs x86_x64) |
| 87 | +rm -rf /io/wheelhouse/ /io/.eggs/ /io/pymssql.egg-info/ |
| 88 | + |
| 89 | +# Cleanup FreeTDS directories |
| 90 | +rm -rf /io/freetds/ # /io/misc/ /io/include/ /io/doc/ /io/samples/ /io/vms/ /io/wins32/ |
| 91 | + |
| 92 | +echo "Done building wheels." |
0 commit comments