/
.travis.yml
71 lines (64 loc) · 2.62 KB
/
.travis.yml
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
# Our .travis.yml is a slightly modified version of:
# https://github.com/joerick/cibuildwheel#example-setup
language: python
jobs:
include:
# perform a linux build
- services: docker
env:
- BUILD_SOURCE_DISTRIBUTION="true"
- services: docker
# and a mac build
- os: osx
# PyPy 7.3.2 needs macOS >= 10.14
osx_image: xcode10.2
language: shell
# and a windows build
- os: windows
language: shell
before_install:
- choco install python --version 3.8.0
- export PATH="/c/Python38:/c/Python38/Scripts:$PATH"
# make sure it's on PATH as 'python3'
- ln -s /c/Python38/python.exe /c/Python38/python3.exe
env:
global:
# Skip building Python 2.7 and PyPy (jit)
- CIBW_SKIP="cp27-* pp*"
# TWINE_PASSWORD is set to a PyPI API token in Travis settings
- TWINE_USERNAME=__token__
install:
- python3 -m pip install --upgrade setuptools cython numpy pytest cibuildwheel==1.6.4
script:
- |
if [ "$BUILD_SOURCE_DISTRIBUTION" = "true" ]
then
python3 setup.py install
pytest
pushd ..
python3 -c "import primesieve;print(primesieve.n_primes(10))"
popd
python3 setup.py sdist
export UPLOAD_FILES=dist/*.tar.gz
else
# For the CIBW environment variables we need to use python instead of python3.
# This way we use the CIBW python version.
export CIBW_BEFORE_BUILD="python -m pip install --upgrade cython numpy"
export CIBW_TEST_REQUIRES="pytest numpy"
export CIBW_TEST_COMMAND='pytest {project} && python -c "import primesieve;print(primesieve.n_primes(10))"'
python3 -m cibuildwheel --output-dir wheelhouse
export UPLOAD_FILES=wheelhouse/*.whl
fi
# Unfortunately failures in after_success currently do not cause the
# build to fail, see https://github.com/travis-ci/travis-ci/issues/758.
# I think we could switch to "deploy:" to get the desired behavior.
after_success:
# Because of a bug in Travis we have to pin keyring here,
# see: https://github.com/kimwalisch/primesieve-python/issues/44.
# Try removing this workaround in 2022 (remove "keyring==21.4.0").
- python3 -m pip install twine keyring==21.4.0
# All commits are uploaded to https://test.pypi.org in order to
# ensure that releases will be uploaded to PyPI without any issues.
- python3 -m twine upload -p $TEST_TOKEN --repository-url https://test.pypi.org/legacy/ --skip-existing --verbose $UPLOAD_FILES;
# If the release was tagged, upload to PyPI.
- if [[ $TRAVIS_TAG ]]; then python3 -m twine upload -p $PYPI_TOKEN --skip-existing --verbose $UPLOAD_FILES; fi