Skip to content

Commit f75a101

Browse files
c-martinezskvark
authored andcommitted
Build working for linux and OSX (opencv#10)
* Build on Travis CI using manylinux * Fix appveyor (maybe) * Update following suggestions from opencv #6774 * Testing... * Testing... * Testing OSX build * Testing OSX build
1 parent 450fe45 commit f75a101

File tree

6 files changed

+110
-45
lines changed

6 files changed

+110
-45
lines changed

.travis.yml

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,14 @@ services: docker
3030

3131
matrix:
3232
include:
33-
- os: linux
34-
env:
35-
- MB_PYTHON_VERSION=2.7
36-
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
37-
- os: linux
33+
- os: osx
34+
language: generic
3835
env:
3936
- MB_PYTHON_VERSION=2.7
40-
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
41-
- PLAT=i686
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
37+
- os: osx
38+
language: generic
5039
env:
51-
- MB_PYTHON_VERSION=2.6
52-
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
53-
- PLAT=i686
40+
- MB_PYTHON_VERSION=3.4
5441
- os: linux
5542
env:
5643
- MB_PYTHON_VERSION=2.7
@@ -98,18 +85,6 @@ actual-matrix:
9885
- MB_PYTHON_VERSION=3.5
9986
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
10087
- 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
11388

11489
before_install:
11590
- source multibuild/common_utils.sh
@@ -120,7 +95,6 @@ install:
12095
# Maybe get and clean and patch source
12196
- clean_code $REPO_DIR $BUILD_COMMIT
12297
- travis_wait 120 build_wheel $REPO_DIR $PLAT
123-
# - build_wheel $REPO_DIR $PLAT
12498

12599
script:
126100
- install_run $PLAT

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
environment:
1+
environment:
22
USER:
33
secure: fXgF9uyy6sT0JoVOR7BoqA==
44

@@ -109,4 +109,3 @@ artifacts:
109109

110110
deploy_script:
111111
- if "%APPVEYOR_REPO_TAG%"=="true" (twine -u %USER% -p %PASS% -r pypitest dist/*) else (echo "Tag not set, deployment skipped.")
112-

config.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
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+
function build_wheel {
7+
# Custom build_wheel function for OSX
8+
# Run using '.' instead of '$REPO_DIR' to build from
9+
# opencv-python instead of opencv
10+
build_pip_wheel . $@
11+
}
12+
else
13+
echo " > Linux environment "
14+
fi
315

416
function pre_build {
517
echo "Starting pre-build"
618

19+
set +e
720
if [ -n "$IS_OSX" ]; then
8-
echo "Don't know how to build for OSX yet..."
9-
# source travis/build-wheels-osx.sh
21+
echo "Running for OSX"
22+
source travis/build-wheels-osx.sh
1023
else
1124
echo "Running for linux"
1225
source /io/travis/build-wheels.sh
@@ -17,8 +30,19 @@ function run_tests {
1730
# Runs tests on installed distribution from an empty directory
1831
# python --version
1932
# python -c 'import sys; import yourpackage; sys.exit(yourpackage.test())'
33+
set +e
2034
echo "Run tests..."
2135
echo $PWD
2236
ls -lh
23-
source /io/travis/test-wheels.sh
37+
38+
if [ -n "$IS_OSX" ]; then
39+
echo "Dont know how to test for OSX yet..."
40+
cd ../tests/
41+
source ../travis/test-wheels.sh
42+
else
43+
echo "Running for linux"
44+
apt-get -y install libglib2.0-0
45+
cd /io/tests/
46+
source /io/travis/test-wheels.sh
47+
fi
2448
}

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def is_pure(self):
4444
distclass=BinaryDistribution,
4545
packages=['cv2'],
4646
package_data=package_data,
47-
maintainer="Olli-Pekka Heinisuo",
48-
include_package_data=True,
47+
maintainer="Olli-Pekka Heinisuo",
48+
include_package_data=True,
4949
install_requires="numpy==%s" % numpy_version,
5050
classifiers=[
5151
'Development Status :: 5 - Production/Stable',
@@ -66,4 +66,4 @@ def is_pure(self):
6666
'Topic :: Scientific/Engineering :: Image Recognition',
6767
'Topic :: Software Development',
6868
]
69-
)
69+
)

travis/build-wheels-osx.sh

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,79 @@
11
#!/bin/bash
2-
pip install numpy
2+
set +e
3+
echo 'Begin build-wheel OSX ...'
4+
5+
export PYTHON_VERSION=${MB_PYTHON_VERSION/./}
6+
echo 'MB_PYTHON_VERSION: 'MB_PYTHON_VERSION
7+
echo 'PYTHON_VERSION: '$PYTHON_VERSION
8+
9+
echo 'PIP and brew installs'
10+
311
brew install cmake pkg-config
412
brew install jpeg libpng libtiff openexr
513
brew install eigen tbb
614

15+
if [[ $PYTHON_VERSION == 3* ]]; then
16+
brew install python3
17+
pip3 install numpy
18+
fi
19+
20+
if [[ $PYTHON_VERSION == 2* ]]; then
21+
pip install numpy
22+
fi
23+
24+
echo 'Begin our build'
25+
ls -lh
26+
27+
python ./find_version.py
28+
pip install -r requirements.txt
29+
30+
echo 'Config make'
31+
732
cd opencv
833
mkdir build
934
cd build
35+
36+
if [[ $PYTHON_VERSION == 2* ]]; then
37+
echo 'Config for Py2'
38+
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
39+
-D BUILD_opencv_python3=OFF -D BUILD_opencv_java=OFF -D BUILD_SHARED_LIBS=OFF \
40+
-D PYTHON2_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
41+
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/bin \
42+
-D PYTHON2_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \
43+
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF \
44+
-D BUILD_EXAMPLES=OFF ..
45+
fi
46+
47+
if [[ $PYTHON_VERSION == 3* ]]; then
48+
echo 'Config for Py3'
49+
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
50+
-D BUILD_opencv_python2=OFF -D BUILD_opencv_java=OFF -D BUILD_SHARED_LIBS=OFF \
51+
-D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
52+
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/bin \
53+
-D PYTHON3_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
54+
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF \
55+
-D BUILD_EXAMPLES=OFF ..
56+
fi
57+
58+
echo 'Begin build'
59+
make -j4
60+
61+
# Moving back to opencv-python
62+
cd ../..
63+
64+
if [[ $PYTHON_VERSION == 2* ]]; then
65+
echo 'Copying *.so for Py2'
66+
cp opencv/build/lib/cv2.so cv2/
67+
fi
68+
69+
if [[ $PYTHON_VERSION == 3* ]]; then
70+
echo 'Copying *.so for Py3'
71+
cp opencv/build/lib/python3/*.so cv2/
72+
fi
73+
74+
echo 'Build wheel'
75+
# pip wheel . -w ./wheelhouse/
76+
77+
echo 'Cleanup'
78+
# rm -fr opencv/build
79+
# rm cv2/*.so

travis/test-wheels.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/bin/bash
22

33
PYTHON=python$PYTHON_VERSION
4-
echo "Starting tests..."
5-
apt-get -y install libglib2.0-0
64

7-
cd /io/tests/
5+
echo "Starting tests..."
86

97
#Test package
108
$PYTHON -m unittest test

0 commit comments

Comments
 (0)