Skip to content

Commit

Permalink
Build & deploy windows wheels to PyPi via TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimura committed Oct 5, 2020
1 parent 31543b2 commit d06ae99
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 34 deletions.
42 changes: 21 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ dist: focal

jobs:
include:
- name: Ubuntu-python2-make
- name: Linux
stage: make
services: docker
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh 2
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build_linux.sh
workspaces:
create:
name: wheels2
paths:
- wheelhouse
- name: Ubuntu-python3-make
stage: make
services: docker
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh 3
workspaces:
create:
name: wheels3
paths:
- wheelhouse
- dist
- name: macOS-python2-make
name: linux
paths: wheelhouse
- name: macOS-python2
stage: make
os: osx
env: PYTHON=2.7
compiler: clang
install: pyenv install -s 3.7-dev
script: ./make_osx.sh
script: ./build_osx.sh
- name: macOS-python3
stage: make
os: osx
env: PYTHON=3.7
compiler: clang
install: pyenv install -s 3.7-dev
script: ./make_osx.sh
script: ./build_osx.sh
- name: Windows
stage: make
os: windows
language: sh
script: ./build_win.sh
workspaces:
create:
name: windows
paths: C:/wheelhouse
- name: deploy pypi
stage: deploy
services: docker
workspaces:
use:
- wheels3
- wheels2
script: docker run --rm -e PYPI_USER -e PYPI_PASS -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/pypi-upload.sh
- linux
- windows
script:
- mv C:/wheelhouse/* wheelhouse/
- docker run --rm -e PYPI_USER -e PYPI_PASS -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/pypi_upload.sh

stages:
- make
Expand Down
8 changes: 3 additions & 5 deletions build-wheels.sh → build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@

#Usage:
#git clone --recursive https://github.com/Fluorescence-Tools/LabelLib.git
#docker run --rm -v `pwd`/LabelLib:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh [2|3]
#docker run --rm -v `pwd`/LabelLib:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh

set -e

VERSION_PREFIX=$1 # Could be `2` for python 2.*, `3` for python 3.x, `35` for python 3.5, etc; leave empy for all versions

DEFAULT_BIN=/opt/python/cp37-cp37m/bin
"${DEFAULT_BIN}/pip" install cmake
ln -s /opt/_internal/*/bin/cmake /usr/bin/cmake

#create the source package
git submodule update --init
${DEFAULT_BIN}/python3 setup.py sdist
${DEFAULT_BIN}/python3 setup.py sdist -d wheelhouse/

# Compile wheels
for PYBIN in /opt/python/cp${VERSION_PREFIX}*/bin; do
for PYBIN in /opt/python/cp*/bin; do
"${PYBIN}/pip" install numpy
"${PYBIN}/pip" wheel ./ -w wheelhouse_tmp/
done
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions build_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
PY_VERSION_LIST='3.5.4 3.6.8 3.7.9 ""'
mkdir C:/wheelhouse
for PY_VERSION in $PY_VERSION_LIST; do
choco install python --version=$PY_VERSION -y
export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
pip install wheel
python setup.py bdist_wheel -d C:/wheelhouse
choco uninstall python -y
choco uninstall python3 -y
done
2 changes: 1 addition & 1 deletion pypi-upload.sh → pypi_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ password = $PYPI_PASS
EOF

"${DEFAULT_BIN}/pip" install twine
"${DEFAULT_BIN}/twine" upload ./wheelhouse/LabelLib-*.whl ./dist/LabelLib-*.tar.gz
"${DEFAULT_BIN}/twine" upload ./wheelhouse/LabelLib-*.whl ./wheelhouse/LabelLib-*.tar.gz
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ def build_extension(self, ext):


def gitVersionString():
hard_version="2018.12.14"
try:
out = check_output(['git', 'show', '-s', '--format=%cd', '--date=short'])
out = out.decode().replace('-','.').strip()
if out != hard_version:
print("WARNING: git-based version ({}) "
"does not match the default version ({})!".format(out,hard_version))
out = check_output(['git', 'show', '-s', '--format=%cd', '--date=short']).decode()
out = out.replace('-','.').strip()
tag_version = check_output(['git', 'describe', '--tags']).decode()
if out != tag_version:
print("WARNING: date-based version ({}) "
"does not match the tag ({})!".format(out,tag_version))
return out
except CalledProcessError:
return hard_version
#sys.exit(1)
return "unknown"


setup(
Expand Down

0 comments on commit d06ae99

Please sign in to comment.