8000 Build working for linux and OSX by c-martinez · Pull Request #10 · opencv/opencv-python · GitHub
[go: up one dir, main page]

Skip to content

Build working for linux and OSX #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Testing...
  • Loading branch information
c-martinez committed Aug 4, 2016
commit 867190dc2954f1125a43dde56f39d4530b865aef
150 changes: 87 additions & 63 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
env:
global:
- REPO_DIR=your-project
# Commit from your-project that you want to build
- BUILD_COMMIT=v0.1.0
- REPO_DIR=opencv
# Commit from opencv that you want to build
- BUILD_COMMIT=master
# pip dependencies to _build_ your project
- BUILD_DEPENDS="Cython numpy"
# pip dependencies to _test_ your project. Include any dependencies
Expand All @@ -28,65 +28,88 @@ sudo: required
dist: trusty
services: docker

exclude:
# Exclude the default Python 3.5 build
- python: 3.5
include:
- os: linux
env:
- MB_PYTHON_VERSION=2.6
- os: linux
env:
- MB_PYTHON_VERSION=2.6
- PLAT=i686
- os: linux
env: MB_PYTHON_VERSION=2.7
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- PLAT=i686
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=3.3
- os: linux
env:
- MB_PYTHON_VERSION=3.3
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.4
- os: linux
env:
- MB_PYTHON_VERSION=3.4
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- PLAT=i686
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=2.7
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.4
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.5
matrix:
include:
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686

actual-matrix:
include:
- os: linux
env:
- MB_PYTHON_VERSION=2.6
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=2.6
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=3.3
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=3.3
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.4
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=3.4
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
- PLAT=i686
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=2.7
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.4
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.5

before_install:
- source multibuild/common_utils.sh
Expand All @@ -96,7 +119,8 @@ before_install:
install:
# Maybe get and clean and patch source
- clean_code $REPO_DIR $BUILD_COMMIT
- build_wheel $REPO_DIR $PLAT
- travis_wait 120 build_wheel $REPO_DIR $PLAT
# - build_wheel $REPO_DIR $PLAT

script:
- install_run $PLAT
Expand Down
14 changes: 11 additions & 3 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
# Test for OSX with [ -n "$IS_OSX" ]

function pre_build {
echo "Starting pre-build"

if [ -n "$IS_OSX" ]; then
echo "Don't know how to build for OSX yet..."
# source travis/build-wheels-osx.sh
else
source travis/build-wheels.sh
echo "Running for linux"
source /io/travis/build-wheels.sh
fi
}

function run_tests {
# Runs tests on installed distribution from an empty directory
python --version
python -c 'import sys; import yourpackage; sys.exit(yourpackage.test())'
# python --version
# python -c 'import sys; import yourpackage; sys.exit(yourpackage.test())'
echo "Run tests..."
echo $PWD
ls -lh
source /io/travis/test-wheels.sh
}
9 changes: 9 additions & 0 deletions travis/build-wheels-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
pip install numpy
brew install cmake pkg-config
brew install jpeg libpng libtiff openexr
brew install eigen tbb

cd opencv
mkdir build
cd build
58 changes: 35 additions & 23 deletions travis/build-wheels.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,79 @@
#!/bin/bash
set +e
echo 'Begin build-wheel...'
/opt/_internal/cpython-3.5.1/bin/pip3.5 install --upgrade git+git://github.com/pypa/auditwheel

export $PYTHON_VERSION=${MB_PYTHON_VERSION/./}
export PYTHON_VERSION=${PYTHON_VERSION/./}

echo 'PYTHON_VERSION: '$PYTHON_VERSION

for PYBIN in /opt/python/cp$PYTHON_VERSION*/bin; do
$PYBIN/python find_version.py
echo 'PWD : '$PWD
echo 'PYBIN: '$PYBIN

$PYBIN/python ./find_version.py
$PYBIN/pip install -r requirements.txt

# Begin build
echo 'Begin build'
cd opencv
mkdir build
if [[ $MB_PYTHON_VERSION == 2* ]]; then
if [[ $PYTHON_VERSION == 2* ]]; then
echo 'Config for Py2'
cmake28 -H"." -B"build" -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python3=OFF -DBUILD_opencv_java=OFF -DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF \
-DPYTHON2INTERP_FOUND=ON -DPYTHON2LIBS_FOUND=ON \
-DPYTHON2_EXECUTABLE=$PYBIN/python \
-DPYTHON2_VERSION_STRING=$($PYBIN/python -c "from platform import python_version; print python_version()") \
-DPYTHON2_INCLUDE_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON2_PACKAGES_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-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()))") \
-DPYTHON2_NUMPY_VERSION=$($PYBIN/python -c "import numpy; print(numpy.version.version)")
(cd build; make -j5 opencv_python2)
fi

if [[ $MB_PYTHON_VERSION == 3* ]]; then
if [[ $PYTHON_VERSION == 3* ]]; then
echo 'Config for Py3'
cmake28 -H"." -B"build" -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF \
-DPYTHON3INTERP_FOUND=ON -DPYTHON3LIBS_FOUND=ON \
-DPYTHON3_EXECUTABLE=$PYBIN/python \
-DPYTHON3_VERSION_STRING=$($PYBIN/python -c "from platform import python_version; print python_version()") \
-DPYTHON3_INCLUDE_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON3_PACKAGES_PATH=$($PYBIN/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-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()))") \
-DPYTHON3_NUMPY_VERSION=$($PYBIN/python -c "import numpy; print(numpy.version.version)")
fi

if [[ $PYTHON_VERSION == 2* ]]; then
echo 'Build for Py2'
(cd build; make -j5 opencv_python2)
fi

if [[ $PYTHON_VERSION == 3* ]]; then
echo 'Build for Py3'
(cd build; make -j5 opencv_python3)
fi


# Moving back to opencv-python
cd ..

if [[ $MB_PYTHON_VERSION == 2* ]]; then
if [[ $PYTHON_VERSION == 2* ]]; then
echo 'Copying *.so for Py2'
cp opencv/build/lib/cv2.so cv2/
fi

if [[ $MB_PYTHON_VERSION == 3* ]]; then
if [[ $PYTHON_VERSION == 3* ]]; then
echo 'Copying *.so for Py3'
cp opencv/build/lib/python3/*.so cv2/
fi

# Build wheel
$PYBIN/pip wheel . -w tmpwheels/
echo 'Build wheel'
$PYBIN/pip wheel . -w /io/wheelhouse/

# Cleanup
echo 'Cleanup'
rm -fr opencv/build
rm cv2/*.so
done

# Bundle external shared libraries into the wheels
for whl in tmpwheels/opencv*.whl; do
auditwheel repair $whl -w /io/wheelhouse/
done
rm -fr tmpwheels/

cd tests
# Install packages and test
for PYBIN in /opt/python/cp$PYTHON_VERSION*/bin/; do
$PYBIN/pip install opencv-python --no-index -f /io/wheelhouse
$PYBIN/python -m unittest test
done
10 changes: 10 additions & 0 deletions travis/test-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

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

cd /io/tests/

#Test package
$PYTHON -m unittest test
0