Skip to content

Commit 61f4dab

Browse files
authored
Fix manylinux1 Python 3.3 and 3.4 builds and add Travis testing. (#9)
Fix "undefined symbol: clock_gettime" on Linux. Test on OSX and Linux in Travis. Test manylinux1 builds in Travis.
1 parent e05d3ba commit 61f4dab

File tree

4 files changed

+121
-1
lines changed

4 files changed

+121
-1
lines changed

.travis.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
language: python
2+
3+
os:
4+
- linux
5+
6+
python:
7+
- 2.6
8+
- 2.7
9+
- 3.3
10+
- 3.4
11+
- 3.5
12+
- 3.6
13+
14+
matrix:
15+
include:
16+
# Travis does not support Python versions on OSX:
17+
# https://github.com/travis-ci/travis-ci/issues/2312
18+
- language: generic
19+
os: osx
20+
# Set the Python version to display it in the Travis UI.
21+
python: 2.7
22+
- language: generic
23+
os: osx
24+
# Set the Python version to display it in the Travis UI.
25+
python: 3.6
26+
before_install:
27+
- if ! command -v python3; then
28+
brew update;
29+
brew install python3;
30+
virtualenv env -p python3;
31+
source env/bin/activate;
32+
fi
33+
# Test manylinux1 64 and 32 bit wheels.
34+
- sudo: required
35+
os: linux
36+
language: generic
37+
services:
38+
- docker
39+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
40+
- sudo: required
41+
os: linux
42+
language: generic
43+
services:
44+
- docker
45+
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
46+
PRE_CMD=linux32
47+
48+
install:
49+
- if [ -n "$DOCKER_IMAGE" ]; then
50+
docker pull "$DOCKER_IMAGE";
51+
fi
52+
53+
script:
54+
- if [ -n "$DOCKER_IMAGE" ]; then
55+
docker run --rm -v "$(pwd)":/io "$DOCKER_IMAGE" $PRE_CMD /io/build-wheels.sh /io;
56+
else
57+
python setup.py test;
58+
fi

build-wheels.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 1 ]; then
4+
echo "$0 requires one argument: <BSONJS_SOURCE_DIRECTORY>"
5+
echo "For example: $0 /user/home/git/python-bsonjs"
6+
exit 1
7+
fi
8+
9+
set -e -x
10+
11+
BSONJS_SOURCE_DIRECTORY="$1"
12+
cd "$BSONJS_SOURCE_DIRECTORY"
13+
14+
ls -la
15+
16+
# Compile wheels
17+
for PYBIN in /opt/python/*/bin; do
18+
"${PYBIN}/python" setup.py bdist_wheel
19+
# https://github.com/pypa/manylinux/issues/49
20+
rm -rf build
21+
done
22+
23+
# Audit wheels and write multilinux1 tag
24+
for whl in dist/*.whl; do
25+
auditwheel repair "$whl" -w dist
26+
done
27+
28+
# Install packages and test
29+
for PYBIN in /opt/python/*/bin; do
30+
"${PYBIN}/pip" install python-bsonjs --no-index -f dist
31+
# The tests require PyMongo.
32+
"${PYBIN}/pip" install 'pymongo>=3.4' unittest2
33+
for TEST_FILE in "${BSONJS_SOURCE_DIRECTORY}"/test/test_*.py; do
34+
"${PYBIN}/python" "$TEST_FILE" -v
35+
done
36+
done
37+
38+
ls -lah dist

docker-build.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 0 ]; then
4+
echo "$0 takes no arguments"
5+
exit 1
6+
fi
7+
8+
set -e -x
9+
10+
11+
DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
12+
docker pull "$DOCKER_IMAGE"
13+
docker run --rm -v `pwd`:/io "$DOCKER_IMAGE" /io/build-wheels.sh /io
14+
15+
DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
16+
docker pull "$DOCKER_IMAGE"
17+
docker run --rm -v `pwd`:/io "$DOCKER_IMAGE" linux32 /io/build-wheels.sh /io

setup.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
else:
4242
test_suite = "test"
4343

44+
libraries = []
45+
if sys.platform == "win32":
46+
libraries.append("ws2_32")
47+
elif sys.platform != "darwin":
48+
# librt may be needed for clock_gettime()
49+
libraries.append("rt")
50+
4451
setup(
4552
name="python-bsonjs",
4653
version="0.2.0.dev0",
@@ -79,7 +86,7 @@
7986
"libbson/src/jsonsl",
8087
"libbson/src/bson"],
8188
define_macros=[("BSON_COMPILATION", 1)],
82-
libraries=["ws2_32"] if sys.platform == "win32" else []
89+
libraries=libraries
8390
)
8491
]
8592
)

0 commit comments

Comments
 (0)