File: build_manylinux_wheels.sh

package info (click to toggle)
pymssql 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 972 kB
  • sloc: python: 3,801; sh: 152; makefile: 151; ansic: 1
file content (104 lines) | stat: -rwxr-xr-x 3,609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# Need to build linux wheel using manylinux
#
# https://github.com/pypa/manylinux
# https://github.com/pypa/python-manylinux-demo
# https://www.python.org/dev/peps/pep-0513/
#
# You may need to make the build script executable
# chmod +x /dev/build_wheels.sh
#
# Standard manylinux docker containers provided by pypa. For more information see the links above.
# docker pull quay.io/pypa/manylinux1_x86_64
# docker pull quay.io/pypa/manylinux1_i686
#
# The next set of instructions will let you run the container interactively
# Provide a container name so it is easier to reference later
# sudo docker run --name manylinux_x86_x64 -it -d --rm -w=/io -v `pwd`:/io quay.io/pypa/manylinux1_x86_64
# docker ps
#
# Use the docker exec command to interact with our container
# docker exec -it manylinux_x86_x64 ls
# docker exec -it manylinux_x86_x64 ./io/dev/build_wheels.sh
#
# Stop the conatiner when done
# docker stop manylinux_x86_x64
#
# These docker commands will run, build the wheel, attempt to install and then finally upload
# docker run --name manylinux_x86_x64 --rm -w=/io -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/dev/build_wheels.sh
# docker run --name manylinux_i686 --rm -w=/io -v `pwd`:/io quay.io/pypa/manylinux1_i686 /io/dev/build_wheels.sh
#
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
set -e -x

if ! git status ; then
  git config --global --add safe.directory "$(pwd)"
fi
git status

if which yum; then
    yum install -y openssl-devel krb5-devel
else
    if which apk; then # Alpinr linux - #864
        apk update
        apk add curl gcc g++ git openssl-dev krb5-dev linux-headers make
    else
        apt-get update
        apt-get install -y libssl1.1
        apt-get install -y libssl-dev libkrb5-dev
    fi
fi
git config --global --add safe.directory /pymssql
/opt/python/cp39-cp39/bin/python dev/build.py \
    --ws-dir=./freetds \
    --dist-dir=. \
    --prefix=/usr/local \
    --with-openssl=yes \
    --enable-krb5 \
    --static-freetds

# Install Python dependencies and compile wheels
PYTHONS="cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313 cp314-cp314"
for i in $PYTHONS; do
    PYBIN="/opt/python/$i/bin"
    if  [ -d ${PYBIN} ] ; then
        "${PYBIN}/pip" install --upgrade pip setuptools Cython wheel
        "${PYBIN}/pip" wheel . -w .
    fi
done

# Verify the wheels and move from *-linux_* to -manylinux_*
for wheel in ./*.whl; do
    if ! auditwheel show "$wheel"; then
        echo "Skipping non-platform wheel $wheel"
    else
        auditwheel repair "$wheel" -w ./dist
    fi
done

# Create .tar.gz dist.
/opt/python/cp39-cp39/bin/python setup.py sdist

# Install the wheels that were built. Need to be able to connect to mssql and to run the pytest suite after install
# psutil 5.9.2 had a bug preventing it from being imported on some platforms.
# https://github.com/giampaolo/psutil/issues/2138
for i in $PYTHONS; do
    PYBIN="/opt/python/$i/bin"
    if  [ -d ${PYBIN} ] ; then
        "${PYBIN}/pip" install pymssql --no-index -f dist
        "${PYBIN}/pip" install 'psutil<5.9.2' pytest pytest-timeout pytest-subtests
        if [ "$MANYLINUX" != "manylinux1" ] ;  then
            "${PYBIN}/pip" install SQLAlchemy
        fi
        "${PYBIN}/pytest" -sv --durations=0 .
        "${PYBIN}/python" -c "import pymssql; print(pymssql.version_info());"
    fi
done

# Remove wheel and egg directory for next container build (i686 vs x86_x64)
rm -rf .eggs/ pymssql.egg-info/

# Cleanup FreeTDS directories
rm -rf freetds/ # misc/ include/ doc/ samples/ vms/ wins32/

echo "Done building wheels."