Skip to content

Commit a6be64f

Browse files
committed
Use Travis CI to produce wheels for Linux and macOS (#12)
1 parent 613cac1 commit a6be64f

File tree

6 files changed

+183
-8
lines changed

6 files changed

+183
-8
lines changed

.ci/build-manylinux-wheels.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
PYTHON_VERSIONS="cp35-cp35m"
6+
7+
# Compile wheels
8+
for PYTHON_VERSION in ${PYTHON_VERSIONS}; do
9+
PYTHON="/opt/python/${PYTHON_VERSION}/bin/python"
10+
PIP="/opt/python/${PYTHON_VERSION}/bin/pip"
11+
${PIP} install --upgrade pip wheel
12+
${PIP} install --upgrade setuptools
13+
${PIP} install -r /io/.ci/requirements.txt
14+
make -C /io/ PYTHON="${PYTHON}"
15+
${PIP} wheel /io/ -w /io/dist/
16+
done
17+
18+
# Bundle external shared libraries into the wheels.
19+
for whl in /io/dist/*.whl; do
20+
auditwheel repair $whl -w /io/dist/
21+
rm /io/dist/*-linux_*.whl
22+
done
23+
24+
# Grab docker host, where Postgres should be running.
25+
export PGHOST=$(ip route | awk '/default/ { print $3 }' | uniq)
26+
export PGUSER="postgres"
27+
28+
for PYTHON_VERSION in ${PYTHON_VERSIONS}; do
29+
PYTHON="/opt/python/${PYTHON_VERSION}/bin/python"
30+
PIP="/opt/python/${PYTHON_VERSION}/bin/pip"
31+
${PIP} install ${PYMODULE} --no-index -f file:///io/dist
32+
rm -rf /io/tests/__pycache__
33+
make -C /io/ PYTHON="${PYTHON}" test
34+
rm -rf /io/tests/__pycache__
35+
done

.ci/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cython>=0.24
2+
uvloop>=0.5.0
3+
twine

.ci/travis-before-install.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
4+
# Allow docker guests to connect to the database
5+
sudo service postgresql stop 9.4
6+
echo "listen_addresses = '*'" | \
7+
sudo tee --append /etc/postgresql/9.4/main/postgresql.conf
8+
echo "host all all 172.17.0.0/16 trust" | \
9+
sudo tee --append /etc/postgresql/9.4/main/pg_hba.conf
10+
sudo service postgresql start 9.4
11+
fi

.ci/travis-build-and-upload.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
6+
if [ -z "${TRAVIS_TAG}" ]; then
7+
# Not a release
8+
exit 0
9+
fi
10+
11+
12+
pushd $(dirname $0) > /dev/null
13+
_root=$(dirname $(pwd -P))
14+
popd > /dev/null
15+
16+
17+
_upload_wheels() {
18+
set +x
19+
echo python -m twine upload \
20+
--username "${PYPI_USER}" --password "<secret>" \
21+
"${_root}/dist"/*.whl
22+
python -m twine upload \
23+
--username "${PYPI_USER}" --password "${PYPI_PASSWD}" \
24+
"${_root}/dist"/*.whl
25+
26+
set -x
27+
sudo rm -rf "${_root}/dist"/*.whl
28+
}
29+
30+
31+
# Release build
32+
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
33+
docker pull quay.io/pypa/manylinux1_x86_64
34+
docker run --rm \
35+
-v "${_root}":/io \
36+
quay.io/pypa/manylinux1_x86_64 \
37+
/io/.ci/build-manylinux-wheels.sh
38+
39+
_upload_wheels
40+
41+
docker pull quay.io/pypa/manylinux1_i686
42+
docker run --rm \
43+
-v "${_root}":/io \
44+
quay.io/pypa/manylinux1_i686 linux32 \
45+
/io/.ci/build-manylinux-wheels.sh
46+
47+
_upload_wheels
48+
49+
elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
50+
eval "$(pyenv init -)"
51+
pyenv local ${PYTHON_VERSION}
52+
53+
make -C "${_root}"
54+
pip wheel "${_root}" -w "${_root}/dist/"
55+
56+
pip install ${PYMODULE} --no-index -f "file:///${_root}/dist"
57+
pushd / >/dev/null
58+
make -C "${_root}" test
59+
popd >/dev/null
60+
61+
_upload_wheels
62+
63+
else
64+
echo "Cannot build on ${TRAVIS_OS_NAME}."
65+
fi

.ci/travis-install.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
6+
brew update
7+
8+
brew outdated postgresql || brew upgrade postgresql
9+
10+
brew outdated pyenv || brew upgrade pyenv
11+
eval "$(pyenv init -)"
12+
pyenv versions
13+
14+
if ! (pyenv versions | grep "${PYTHON_VERSION}$"); then
15+
pyenv install ${PYTHON_VERSION}
16+
fi
17+
pyenv local ${PYTHON_VERSION}
18+
fi
19+
20+
pip install --upgrade pip wheel
21+
pip install --upgrade setuptools
22+
pip install -r .ci/requirements.txt

.travis.yml

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,60 @@
1-
language: python
1+
language: generic
22

3-
os:
4-
- linux
3+
sudo: required
54

65
services:
76
- postgresql
7+
- docker
88

99
addons:
10-
postgresql: "9.4"
10+
postgresql: '9.4'
1111

12-
python:
13-
- 3.5
12+
env:
13+
global:
14+
- PYMODULE=asyncpg
15+
- PYPI_USER=magicstack-ci
16+
- secure: "XEUUpzRZeesmMUfImKbCJm1D1LmWXkCW6ywtquuLEp6vRboH+URW8XtOhPehj47kn+/D4LpS9DR7GTBQ2DJR6kb07uqMu4b3WhTj8gewc8T5A0bxbdkkxHDfUCw7RF+EYLoN+n8xdqgBHImLLeuY/iRf+/IUJxGBARC4OZkejXhqJktNkXNO7aDcFfl9jcU0s1azaGbgeaShSAnnQPcdnJQ5tn7qHPPjTMWWly09A0K6CGqFK9bXUlD/hLGyC6NjOc8zMhv6vt4rI/zkjtSf219t4svivTjZsWWP6LMoWNWvwbOVfr8MThU4449lfplTWkmvEP6cQAJrvLjBOKOfwvV1MhqCMLGUMxeagYq7bHwSKQQ7t+r4a3jX94go+3Y1AQ0z9Yun+UW4qxrmHeIR5tLh2cePQylkIiTaWePZNPsVl3xF9HJtWcVgNgij4r+EU6WC9EqlV4DJyISjsptSa69CLBieWrzPYNxCPr6cTXYKKu6svRj3uho2q+c3Iavzjt4e5VEgppeduXIrvqMsaAa/E+j7b3QmC0HfZ4k8U5J2evtell5gh70Vf20A9LsOF06m+I0mSDwrpGasSFCNrWH4n3cUDTlGzc93Zqw5eAmg0yYxLKWk1sHNLOB3hNn+NLSIkS6Drcrsya+Fp5k93I4qDIXvC9n7ODLMirAJ76o="
17+
18+
matrix:
19+
include:
20+
- os: osx
21+
osx_image: beta-xcode6.1 # OS X 10.9
22+
# Travis macOS env does not support Python yet,
23+
# so we have to set things up manually in install.sh.
24+
env: PYTHON_VERSION=3.5.2
25+
PIP_USER=1
26+
27+
- os: linux
28+
dist: trusty
29+
language: python
30+
python: "3.5"
31+
services: [postgresql, docker]
32+
33+
cache:
34+
directories:
35+
- $HOME/.cache/pip
36+
37+
before_install:
38+
- .ci/travis-before-install.sh
1439

1540
install:
16-
- "pip install cython"
17-
- "pip install uvloop"
41+
- .ci/travis-install.sh
1842

1943
script:
44+
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then eval "$(pyenv init -)"; fi
2045
- make && make test
2146
- make debug && make test
47+
48+
before_deploy:
49+
- .ci/travis-build-and-upload.sh
50+
51+
deploy:
52+
skip_cleanup: true
53+
provider: pypi
54+
user: magicstack-ci
55+
password:
56+
secure: r8q6OnKwfMO3/obfBDLIjVHrk9VGwcKCrFAUefTvbVVO1oBxpT0gPbASorxgU27h5u2o6L0qp9YUitSyRJBfN4C7BM4aAzVp3FEVvC6KzUYxcxZguveq3Lc+6cBo+AFXE3Kuz7Zxmw3yNqIPkdHJrkKqdANLDVjrSs87uiPuK8s7oH7pxmVTq40ymdkA1Da5QsY6dONDohIJ3Z6HLlKEFzNYiFDY7NK+vDq/+U5UZZZlZb6MAQ07R4RvFoFnH0PNDnyJd6qGOJaJ1W1ge87lOOsdhsUeUiC1BuUGtlRPkwsNBdygJ5RDotn9O6gnvSdtra/d9z5Jpju8Vhbad2b3dKU32ZYnApmZuVGx9O/fQ9yaYc5KkJdjhAIHghfOL7UKOw9+IDzOcg8Glx7+uQ7vbwgY0TulJDCH2dWfwYXMfRdmzxOZlcTGVg1wtHB7s3bEvksG/N4YTn6YCqSPvJ4nbUQiZ0Ji4VCx8SX6S+vkEvVTUPPncmEBIoGAvmMtXBHs93FovwCFbNTugiDOeKB+rWnve9Hj45Ou6lmWNlIyWJss0k9waGmXltomYLKShMAZ5uqe+Oyk4889E2KFaGt34qEuXHAybpxXbjXJewVcMExBkHdRdRr0kVu7OO/7JVJ2kCkp2wRe9QKe0eBgCPs2eUIxKFVCOoDD1HMQ/ytbWIM=
57+
distributions: sdist
58+
on:
59+
tags: true
60+
all_branches: true

0 commit comments

Comments
 (0)