Skip to content

Commit cf4fea1

Browse files
committed
Testing OSX build
1 parent d45d413 commit cf4fea1

File tree

5 files changed

+210
-92
lines changed

5 files changed

+210
-92
lines changed

.travis.yml

Lines changed: 89 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
env:
22
global:
3-
- REPO_DIR=your-project
4-
# Commit from your-project that you want to build
5-
- BUILD_COMMIT=v0.1.0
3+
- REPO_DIR=opencv
4+
# Commit from opencv that you want to build
5+
- BUILD_COMMIT=master
66
# pip dependencies to _build_ your project
77
- BUILD_DEPENDS="Cython numpy"
88
# pip dependencies to _test_ your project. Include any dependencies
@@ -28,65 +28,88 @@ sudo: required
2828
dist: trusty
2929
services: docker
3030

31-
exclude:
32-
# Exclude the default Python 3.5 build
33-
- python: 3.5
34-
include:
35-
- os: linux
36-
env:
37-
- MB_PYTHON_VERSION=2.6
38-
- os: linux
39-
env:
40-
- MB_PYTHON_VERSION=2.6
41-
- PLAT=i686
42-
- os: linux
43-
env: MB_PYTHON_VERSION=2.7
44-
- os: linux
45-
env:
46-
- MB_PYTHON_VERSION=2.7
47-
- UNICODE_WIDTH=16
48-
- os: linux
49-
env:
50-
- MB_PYTHON_VERSION=2.7
51-
- PLAT=i686
52-
- os: linux
53-
env:
54-
- MB_PYTHON_VERSION=2.7
55-
- PLAT=i686
56-
- UNICODE_WIDTH=16
57-
- os: linux
58-
env:
59-
- MB_PYTHON_VERSION=3.3
60-
- os: linux
61-
env:
62-
- MB_PYTHON_VERSION=3.3
63-
- PLAT=i686
64-
- os: linux
65-
env:
66-
- MB_PYTHON_VERSION=3.4
67-
- os: linux
68-
env:
69-
- MB_PYTHON_VERSION=3.4
70-
- PLAT=i686
71-
- os: linux
72-
env:
73-
- MB_PYTHON_VERSION=3.5
74-
- os: linux
75-
env:
76-
- MB_PYTHON_VERSION=3.5
77-
- PLAT=i686
78-
- os: osx
79-
language: generic
80-
env:
81-
- MB_PYTHON_VERSION=2.7
82-
- os: osx
83-
language: generic
84-
env:
85-
- MB_PYTHON_VERSION=3.4
86-
- os: osx
87-
language: generic
88-
env:
89-
- MB_PYTHON_VERSION=3.5
31+
matrix:
32+
include:
33+
- os: osx
34+
language: generic
35+
env:
36+
- MB_PYTHON_VERSION=2.7
37+
- os: osx
38+
language: generic
39+
env:
40+
- MB_PYTHON_VERSION=3.4
41+
42+
43+
actual-matrix:
44+
include:
45+
- os: linux
46+
env:
47+
- MB_PYTHON_VERSION=2.6
48+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
49+
- os: linux
50+
env:
51+
- MB_PYTHON_VERSION=2.6
52+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
53+
- PLAT=i686
54+
- os: linux
55+
env:
56+
- MB_PYTHON_VERSION=2.7
57+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
58+
- os: linux
59+
env:
60+
- MB_PYTHON_VERSION=2.7
61+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
62+
- UNICODE_WIDTH=16
63+
- os: linux
64+
env:
65+
- MB_PYTHON_VERSION=2.7
66+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
67+
- PLAT=i686
68+
- os: linux
69+
env:
70+
- MB_PYTHON_VERSION=2.7
71+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
72+
- PLAT=i686
73+
- UNICODE_WIDTH=16
74+
- os: linux
75+
env:
76+
- MB_PYTHON_VERSION=3.3
77+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
78+
- os: linux
79+
env:
80+
- MB_PYTHON_VERSION=3.3
81+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
82+
- PLAT=i686
83+
- os: linux
84+
env:
85+
- MB_PYTHON_VERSION=3.4
86+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
87+
- os: linux
88+
env:
89+
- MB_PYTHON_VERSION=3.4
90+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
91+
- PLAT=i686
92+
- os: linux
93+
env:
94+
- MB_PYTHON_VERSION=3.5
95+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
96+
- os: linux
97+
env:
98+
- MB_PYTHON_VERSION=3.5
99+
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
100+
- PLAT=i686
101+
- os: osx
102+
language: generic
103+
env:
104+
- MB_PYTHON_VERSION=2.7
105+
- os: osx
106+
language: generic
107+
env:
108+
- MB_PYTHON_VERSION=3.4
109+
- os: osx
110+
language: generic
111+
env:
112+
- MB_PYTHON_VERSION=3.5
90113

91114
before_install:
92115
- source multibuild/common_utils.sh
@@ -96,7 +119,10 @@ before_install:
96119
install:
97120
# Maybe get and clean and patch source
98121
- clean_code $REPO_DIR $BUILD_COMMIT
99-
- build_wheel $REPO_DIR $PLAT
122+
# Run build_wheel using '.' instead of '$REPO_DIR' to build from
123+
# opencv-python instead of opencv
124+
- travis_wait 120 build_wheel . $PLAT
125+
# - build_wheel . $PLAT
100126

101127
script:
102128
- install_run $PLAT

config.sh

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
# Define custom utilities
2-
# Test for OSX with [ -n "$IS_OSX" ]
1+
#!/bin/bash
2+
set +e
3+
echo "=== Loading config.sh === "
4+
if [ -n "$IS_OSX" ]; then
5+
echo " > OSX environment "
6+
else
7+
echo " > Linux environment "
8+
fi
39

410
function pre_build {
11+
echo "Starting pre-build"
12+
13+
set +e
514
if [ -n "$IS_OSX" ]; then
6-
echo "Don't know how to build for OSX yet..."
15+
echo "Running for OSX"
16+
source travis/build-wheels-osx.sh
717
else
8-
source travis/build-wheels.sh
18+
echo "Running for linux"
19+
source /io/travis/build-wheels.sh
920
fi
1021
}
1122

1223
function run_tests {
1324
# Runs tests on installed distribution from an empty directory
14-
python --version
15-
python -c 'import sys; import yourpackage; sys.exit(yourpackage.test())'
25+
# python --version
26+
# python -c 'import sys; import yourpackage; sys.exit(yourpackage.test())'
27+
set +e
28+
echo "Run tests..."
29+
echo $PWD
30+
ls -lh
31+
32+
if [ -n "$IS_OSX" ]; then
33+
echo "Dont know how to test for OSX yet..."
34+
source ../travis/test-wheels.sh
35+
else
36+
echo "Running for linux"
37+
source /io/travis/test-wheels.sh
38+
fi
1639
}

travis/build-wheels-osx.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set +e
4+
echo 'Begin build-wheel OSX ...'
5+
6+
echo 'PIP and brew installs'
7+
8+
pip install numpy
9+
brew install cmake pkg-config
10+
brew install jpeg libpng libtiff openexr
11+
brew install eigen tbb
12+
13+
echo 'Begin our build'
14+
ls -lh
15+
16+
python ./find_version.py
17+
pip install -r requirements.txt
18+
19+
echo 'Config make'
20+
21+
cd opencv
22+
mkdir build
23+
cd build
24+
25+
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
26+
-D BUILD_opencv_python3=OFF -D BUILD_opencv_java=OFF -D BUILD_SHARED_LIBS=OFF \
27+
-D PYTHON2_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
28+
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/bin \
29+
-D PYTHON2_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \
30+
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF \
31+
-D BUILD_EXAMPLES=OFF ..
32+
33+
echo 'Begin build'
34+
make -j4
35+
36+
# Moving back to opencv-python
37+
cd ../..
38+
39+
echo 'Copying *.so for Py2'
40+
cp opencv/build/lib/cv2.so cv2/
41+
42+
echo 'Build wheel'
43+
# pip wheel . -w ./wheelhouse/
44+
45+
echo 'Cleanup'
46+
# rm -fr opencv/build
47+
# rm cv2/*.so

travis/build-wheels.sh

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,79 @@
11
#!/bin/bash
2+
set +e
3+
echo 'Begin build-wheel...'
24
/opt/_internal/cpython-3.5.1/bin/pip3.5 install --upgrade git+git://github.com/pypa/auditwheel
35

4-
export $PYTHON_VERSION=${MB_PYTHON_VERSION/./}
6+
export PYTHON_VERSION=${PYTHON_VERSION/./}
7+
8+
echo 'PYTHON_VERSION: '$PYTHON_VERSION
59

610
for PYBIN in /opt/python/cp$PYTHON_VERSION*/bin; do
7-
$PYBIN/python find_version.py
11+
echo 'PWD : '$PWD
12+
echo 'PYBIN: '$PYBIN
13+
14+
$PYBIN/python ./find_version.py
815
$PYBIN/pip install -r requirements.txt
916

1017
# Begin build
18+
echo 'Begin build'
1119
cd opencv
1220
mkdir build
13-
if [[ $MB_PYTHON_VERSION == 2* ]]; then
21+
if [[ $PYTHON_VERSION == 2* ]]; then
22+
echo 'Config for Py2'
1423
cmake28 -H"." -B"build" -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python3=OFF -DBUILD_opencv_java=OFF -DBUILD_SHARED_LIBS=OFF \
15-
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
24+
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF \
1625
-DPYTHON2INTERP_FOUND=ON -DPYTHON2LIBS_FOUND=ON \
1726
-DPYTHON2_EXECUTABLE=$PYBIN/python \
1827
-DPYTHON2_VERSION_STRING=$($PYBIN/python -c "from platform import python_version; print python_version()") \
1928
-DPYTHON2_INCLUDE_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
2029
-DPYTHON2_PACKAGES_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
2130
-DPYTHON2_NUMPY_INCLUDE_DIRS=$($PYBIN/python -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))") \
2231
-DPYTHON2_NUMPY_VERSION=$($PYBIN/python -c "import numpy; print(numpy.version.version)")
23-
(cd build; make -j5 opencv_python2)
2432
fi
2533

26-
if [[ $MB_PYTHON_VERSION == 3* ]]; then
34+
if [[ $PYTHON_VERSION == 3* ]]; then
35+
echo 'Config for Py3'
2736
cmake28 -H"." -B"build" -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DBUILD_SHARED_LIBS=OFF \
28-
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
37+
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF \
2938
-DPYTHON3INTERP_FOUND=ON -DPYTHON3LIBS_FOUND=ON \
3039
-DPYTHON3_EXECUTABLE=$PYBIN/python \
3140
-DPYTHON3_VERSION_STRING=$($PYBIN/python -c "from platform import python_version; print python_version()") \
3241
-DPYTHON3_INCLUDE_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
3342
-DPYTHON3_PACKAGES_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
3443
-DPYTHON3_NUMPY_INCLUDE_DIRS=$($PYBIN/python -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))") \
3544
-DPYTHON3_NUMPY_VERSION=$($PYBIN/python -c "import numpy; print(numpy.version.version)")
45+
fi
46+
47+
if [[ $PYTHON_VERSION == 2* ]]; then
48+
echo 'Build for Py2'
49+
(cd build; make -j5 opencv_python2)
50+
fi
51+
52+
if [[ $PYTHON_VERSION == 3* ]]; then
53+
echo 'Build for Py3'
3654
(cd build; make -j5 opencv_python3)
3755
fi
56+
57+
58+
# Moving back to opencv-python
3859
cd ..
3960

40-
if [[ $MB_PYTHON_VERSION == 2* ]]; then
61+
if [[ $PYTHON_VERSION == 2* ]]; then
62+
echo 'Copying *.so for Py2'
4163
cp opencv/build/lib/cv2.so cv2/
4264
fi
4365

44-
if [[ $MB_PYTHON_VERSION == 3* ]]; then
66+
if [[ $PYTHON_VERSION == 3* ]]; then
67+
echo 'Copying *.so for Py3'
4568
cp opencv/build/lib/python3/*.so cv2/
4669
fi
4770

4871
# Build wheel
49-
$PYBIN/pip wheel . -w tmpwheels/
72+
echo 'Build wheel'
73+
$PYBIN/pip wheel . -w /io/wheelhouse/
5074

5175
# Cleanup
76+
echo 'Cleanup'
5277
rm -fr opencv/build
5378
rm cv2/*.so
5479
done
55-
56-
# Bundle external shared libraries into the wheels
57-
for whl in tmpwheels/opencv*.whl; do
58-
auditwheel repair $whl -w /io/wheelhouse/
59-
done
60-
rm -fr tmpwheels/
61-
62-
cd tests
63-
# Install packages and test
64-
for PYBIN in /opt/python/cp$PYTHON_VERSION*/bin/; do
65-
$PYBIN/pip install opencv-python --no-index -f /io/wheelhouse
66-
$PYBIN/python -m unittest test
67-
done

travis/test-wheels.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
PYTHON=python$PYTHON_VERSION
4+
echo "Starting tests..."
5+
apt-get -y install libglib2.0-0
6+
7+
cd /io/tests/
8+
9+
#Test package
10+
$PYTHON -m unittest test

0 commit comments

Comments
 (0)