Skip to content

Commit d06ae99

Browse files
committed
Build & deploy windows wheels to PyPi via TravisCI
1 parent 31543b2 commit d06ae99

File tree

6 files changed

+45
-34
lines changed

6 files changed

+45
-34
lines changed

.travis.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@ dist: focal
44

55
jobs:
66
include:
7-
- name: Ubuntu-python2-make
7+
- name: Linux
88
stage: make
99
services: docker
10-
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh 2
10+
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build_linux.sh
1111
workspaces:
1212
create:
13-
name: wheels2
14-
paths:
15-
- wheelhouse
16-
- name: Ubuntu-python3-make
17-
stage: make
18-
services: docker
19-
script: docker run --rm -v ${TRAVIS_BUILD_DIR}:/io:rw -w="/io" quay.io/pypa/manylinux1_x86_64 /io/build-wheels.sh 3
20-
workspaces:
21-
create:
22-
name: wheels3
23-
paths:
24-
- wheelhouse
25-
- dist
26-
- name: macOS-python2-make
13+
name: linux
14+
paths: wheelhouse
15+
- name: macOS-python2
2716
stage: make
2817
os: osx
2918
env: PYTHON=2.7
3019
compiler: clang
3120
install: pyenv install -s 3.7-dev
32-
script: ./make_osx.sh
21+
script: ./build_osx.sh
3322
- name: macOS-python3
3423
stage: make
3524
os: osx
3625
env: PYTHON=3.7
3726
compiler: clang
3827
install: pyenv install -s 3.7-dev
39-
script: ./make_osx.sh
28+
script: ./build_osx.sh
29+
- name: Windows
30+
stage: make
31+
os: windows
32+
language: sh
33+
script: ./build_win.sh
34+
workspaces:
35+
create:
36+
name: windows
37+
paths: C:/wheelhouse
4038
- name: deploy pypi
4139
stage: deploy
4240
services: docker
4341
workspaces:
4442
use:
45-
- wheels3
46-
- wheels2
47-
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
43+
- linux
44+
- windows
45+
script:
46+
- mv C:/wheelhouse/* wheelhouse/
47+
- 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
4848

4949
stages:
5050
- make

build-wheels.sh renamed to build_linux.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@
44

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

99
set -e
1010

11-
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
12-
1311
DEFAULT_BIN=/opt/python/cp37-cp37m/bin
1412
"${DEFAULT_BIN}/pip" install cmake
1513
ln -s /opt/_internal/*/bin/cmake /usr/bin/cmake
1614

1715
#create the source package
1816
git submodule update --init
19-
${DEFAULT_BIN}/python3 setup.py sdist
17+
${DEFAULT_BIN}/python3 setup.py sdist -d wheelhouse/
2018

2119
# Compile wheels
22-
for PYBIN in /opt/python/cp${VERSION_PREFIX}*/bin; do
20+
for PYBIN in /opt/python/cp*/bin; do
2321
"${PYBIN}/pip" install numpy
2422
"${PYBIN}/pip" wheel ./ -w wheelhouse_tmp/
2523
done
File renamed without changes.

build_win.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
PY_VERSION_LIST='3.5.4 3.6.8 3.7.9 ""'
4+
mkdir C:/wheelhouse
5+
for PY_VERSION in $PY_VERSION_LIST; do
6+
choco install python --version=$PY_VERSION -y
7+
export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
8+
pip install wheel
9+
python setup.py bdist_wheel -d C:/wheelhouse
10+
choco uninstall python -y
11+
choco uninstall python3 -y
12+
done

pypi-upload.sh renamed to pypi_upload.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ password = $PYPI_PASS
2626
EOF
2727

2828
"${DEFAULT_BIN}/pip" install twine
29-
"${DEFAULT_BIN}/twine" upload ./wheelhouse/LabelLib-*.whl ./dist/LabelLib-*.tar.gz
29+
"${DEFAULT_BIN}/twine" upload ./wheelhouse/LabelLib-*.whl ./wheelhouse/LabelLib-*.tar.gz

setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ def build_extension(self, ext):
5858

5959

6060
def gitVersionString():
61-
hard_version="2018.12.14"
6261
try:
63-
out = check_output(['git', 'show', '-s', '--format=%cd', '--date=short'])
64-
out = out.decode().replace('-','.').strip()
65-
if out != hard_version:
66-
print("WARNING: git-based version ({}) "
67-
"does not match the default version ({})!".format(out,hard_version))
62+
out = check_output(['git', 'show', '-s', '--format=%cd', '--date=short']).decode()
63+
out = out.replace('-','.').strip()
64+
tag_version = check_output(['git', 'describe', '--tags']).decode()
65+
if out != tag_version:
66+
print("WARNING: date-based version ({}) "
67+
"does not match the tag ({})!".format(out,tag_version))
6868
return out
6969
except CalledProcessError:
70-
return hard_version
70+
#sys.exit(1)
71+
return "unknown"
7172

7273

7374
setup(

0 commit comments

Comments
 (0)