From 8e17a1091ad319e034d0aa5645b34ebebb6ef87b Mon Sep 17 00:00:00 2001 From: Michael Zietz Date: Thu, 1 Aug 2019 09:45:06 -0400 Subject: [PATCH] Add Travis compilation and PyPI upload * Only deploy on tagged commits Merges https://github.com/hetio/xswap/pull/17 --- .gitignore | 1 + .travis.yml | 98 ++++++++++++++++++++++++++++++++-------------- ci/build-wheels.sh | 11 ++++++ 3 files changed, 81 insertions(+), 29 deletions(-) create mode 100755 ci/build-wheels.sh diff --git a/.gitignore b/.gitignore index 2766289..1a1eb15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +dist/ .vscode/ __pycache__/ .pytest_cache/ diff --git a/.travis.yml b/.travis.yml index 7d9d9e2..bcee46e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,71 @@ -dist: xenial -language: python -python: - - 3.5 - - 3.6 - - 3.7 -install: - - pip install -r tests-require.txt -addons: - apt: - packages: - - pkg-config - - python3-dev +setup_and_test: &setup_and_test + stage: test + language: python + addons: + apt: + packages: + - pkg-config + - python3-dev + before_install: + - pip install -r tests-require.txt + install: + - pkg-config --cflags --libs python3 + - python setup.py build + - pip install . + script: + - pytest tests/ + - > + g++ tests/test_bitset.cpp xswap/src/xswap.h xswap/src/bitset.cpp + xswap/lib/roaring.c -o tests/test_bitset.o -std=c++11 + `pkg-config --cflags --libs python3` + - ./tests/test_bitset.o + - > + g++ tests/test_roaring.cpp xswap/src/xswap.h xswap/src/bitset.cpp + xswap/lib/roaring.c -o tests/test_roaring.o -std=c++11 + `pkg-config --cflags --libs python3` + - ./tests/test_roaring.o + +build_and_upload: &build_and_upload + stage: deploy + sudo: required + if: tag IS present + services: + - docker + install: + - docker pull $DOCKER_IMAGE + script: + - docker run --rm -e PLAT=$PLAT -v `pwd`:/io $DOCKER_IMAGE /io/ci/build-wheels.sh + - /opt/python/3.6/bin/pip install twine + - /opt/python/3.6/bin/python -m twine upload -u zietzm -p $PYPI_PASSWORD --repository-url https://upload.pypi.org/legacy/ --skip-existing wheelhouse/* + compiler: - g++ -script: - - pkg-config --cflags --libs python3 - - python setup.py build - - pip install . - - pytest tests/ - - > - g++ tests/test_bitset.cpp xswap/src/xswap.h xswap/src/bitset.cpp - xswap/lib/roaring.c -o tests/test_bitset.o -std=c++11 - `pkg-config --cflags --libs python3` - - ./tests/test_bitset.o - - > - g++ tests/test_roaring.cpp xswap/src/xswap.h xswap/src/bitset.cpp - xswap/lib/roaring.c -o tests/test_roaring.o -std=c++11 - `pkg-config --cflags --libs python3` - - ./tests/test_roaring.o - - cat tests/permutation_stats.txt +matrix: + include: + - <<: *setup_and_test + name: "Test 3.5 on Ubuntu" + dist: xenial + python: 3.5 + - <<: *setup_and_test + name: "Test 3.6 on Ubuntu" + dist: xenial + python: 3.6 + - <<: *setup_and_test + name: "Test 3.7 on Ubuntu" + dist: xenial + python: 3.7 + - <<: *build_and_upload + name: "Build manylinux1_x86_64" + env: + - DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 + - PLAT=manylinux1_x86_64 + - <<: *build_and_upload + name: "Build manylinux1_i686" + env: + - DOCKER_IMAGE=quay.io/pypa/manylinux1_i686 + - PLAT=manylinux1_i686 + - <<: *build_and_upload + name: "Build manylinux2010_x86_64" + env: + - DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 + - PLAT=manylinux2010_x86_64 diff --git a/ci/build-wheels.sh b/ci/build-wheels.sh new file mode 100755 index 0000000..7c902d0 --- /dev/null +++ b/ci/build-wheels.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Compile wheels +/opt/python/cp35-cp35m/bin/pip wheel /io/ -w wheelhouse/ +/opt/python/cp36-cp36m/bin/pip wheel /io/ -w wheelhouse/ +/opt/python/cp37-cp37m/bin/pip wheel /io/ -w wheelhouse/ + +# Bundle external shared libraries into the wheels +for whl in wheelhouse/**.whl; do + auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/ +done