From 5a7a35dfcf36f9d87eba881e48a402f71d2007f8 Mon Sep 17 00:00:00 2001 From: Alex Reche Date: Tue, 4 Aug 2020 01:08:26 +0200 Subject: [PATCH 1/2] Update to OpenCV 4.4 --- opencv | 2 +- opencv_contrib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opencv b/opencv index 01b2c5a7..c3bb57af 160000 --- a/opencv +++ b/opencv @@ -1 +1 @@ -Subproject commit 01b2c5a77ca6dbef3baef24ebc0a5984579231d9 +Subproject commit c3bb57afeaf030f10939204d48d7c2a3842f4293 diff --git a/opencv_contrib b/opencv_contrib index e6f32c6a..5fae4082 160000 --- a/opencv_contrib +++ b/opencv_contrib @@ -1 +1 @@ -Subproject commit e6f32c6a69043456a806a4e802ee3ce7b7059c93 +Subproject commit 5fae4082cc493efa5cb7a7486f9e009618a5198b From a525e79fc224da685a97f88b3e66f76bc33a4bb2 Mon Sep 17 00:00:00 2001 From: Alex Reche Date: Fri, 11 Dec 2020 14:06:35 +0100 Subject: [PATCH 2/2] Merge remote-tracking branch 'Skvark/master' --- .gitignore | 1 + .travis.yml | 384 ++++++++-- LICENSE-3RD-PARTY.txt | 759 +++++++++++--------- README.md | 61 +- appveyor.yml | 392 ++++++----- cv2/__init__.py | 57 +- cv2/data/__init__.py | 2 +- docker/manylinux2014/Dockerfile_aarch64 | 73 ++ docker/manylinux2014/Dockerfile_i686 | 24 +- docker/manylinux2014/Dockerfile_x86_64 | 24 +- find_version.py | 124 ++-- multibuild | 2 +- patch_auditwheel_whitelist.py | 16 + patches/patchQtPlugins | 14 +- pyproject.toml | 11 +- setup.py | 887 ++++++++++++------------ tests/test.py | 33 +- travis_config.sh | 33 +- 18 files changed, 1730 insertions(+), 1167 deletions(-) create mode 100644 docker/manylinux2014/Dockerfile_aarch64 create mode 100644 patch_auditwheel_whitelist.py diff --git a/.gitignore b/.gitignore index 0367e1b0..15079e07 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,5 @@ target/ # Build temporary files /contrib.enabled /cv_version.py +/cv2/version.py _skbuild/ diff --git a/.travis.yml b/.travis.yml index 26b345b4..a4c8227e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,15 +103,6 @@ jobs: # default builds for MacOS #further jobs in the list will use the same stage until the next assignment - stage: final - - os: osx - language: generic - osx_image: xcode9.4 - env: - - MB_PYTHON_VERSION=3.5 - - ENABLE_CONTRIB=0 - - ENABLE_HEADLESS=0 - workspaces: - use: brew_cache - os: osx language: generic osx_image: xcode9.4 @@ -119,6 +110,7 @@ jobs: - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.13.3 workspaces: use: brew_cache - os: osx @@ -141,17 +133,18 @@ jobs: - TEST_DEPENDS=numpy==1.17.3 workspaces: use: brew_cache - - # headless builds for MacOS - os: osx language: generic osx_image: xcode9.4 env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.9 - ENABLE_CONTRIB=0 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.3 workspaces: use: brew_cache + + # headless builds for MacOS - os: osx language: generic osx_image: xcode9.4 @@ -159,6 +152,7 @@ jobs: - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.13.3 workspaces: use: brew_cache - os: osx @@ -181,17 +175,18 @@ jobs: - TEST_DEPENDS=numpy==1.17.3 workspaces: use: brew_cache - - # Contrib builds for MacOS - os: osx language: generic osx_image: xcode9.4 env: - - MB_PYTHON_VERSION=3.5 - - ENABLE_CONTRIB=1 - - ENABLE_HEADLESS=0 + - MB_PYTHON_VERSION=3.9 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.3 workspaces: use: brew_cache + + # Contrib builds for MacOS - os: osx language: generic osx_image: xcode9.4 @@ -199,6 +194,7 @@ jobs: - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.13.3 workspaces: use: brew_cache - os: osx @@ -221,17 +217,18 @@ jobs: - TEST_DEPENDS=numpy==1.17.3 workspaces: use: brew_cache - - # headless contrib builds for MacOS - os: osx language: generic osx_image: xcode9.4 env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.9 - ENABLE_CONTRIB=1 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.3 workspaces: use: brew_cache + + # headless contrib builds for MacOS - os: osx language: generic osx_image: xcode9.4 @@ -239,6 +236,7 @@ jobs: - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.13.3 workspaces: use: brew_cache - os: osx @@ -261,6 +259,16 @@ jobs: - TEST_DEPENDS=numpy==1.17.3 workspaces: use: brew_cache + - os: osx + language: generic + osx_image: xcode9.4 + env: + - MB_PYTHON_VERSION=3.9 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.3 + workspaces: + use: brew_cache # default builds for Linux - os: linux @@ -268,9 +276,10 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.13.3 cache: directories: $HOME/.ccache - os: linux @@ -278,22 +287,27 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.6 - PLAT=i686 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.13.3 - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - MB_PYTHON_VERSION=3.6 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 - - TEST_DEPENDS=numpy==1.11.3 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux @@ -301,12 +315,10 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.6 - - PLAT=i686 + - MB_PYTHON_VERSION=3.7 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 - - TEST_DEPENDS=numpy==1.11.3 - - USE_CCACHE=0 + - TEST_DEPENDS=numpy==1.14.5 cache: directories: $HOME/.ccache - os: linux @@ -315,21 +327,25 @@ jobs: services: docker env: - MB_PYTHON_VERSION=3.7 + - PLAT=i686 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 - TEST_DEPENDS=numpy==1.14.5 + - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - MB_PYTHON_VERSION=3.7 - - PLAT=i686 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=0 - - TEST_DEPENDS=numpy==1.14.5 + - TEST_DEPENDS=numpy==1.19.0 - USE_CCACHE=0 cache: directories: $HOME/.ccache @@ -357,16 +373,30 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache - - # headless builds for Linux - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.8 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=0 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.3 cache: directories: $HOME/.ccache - os: linux @@ -374,13 +404,31 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.9 - PLAT=i686 - ENABLE_CONTRIB=0 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.3 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 - USE_CCACHE=0 cache: directories: $HOME/.ccache + + # headless builds for Linux - os: linux language: generic dist: xenial @@ -389,7 +437,7 @@ jobs: - MB_PYTHON_VERSION=3.6 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=1 - - TEST_DEPENDS=numpy==1.11.3 + - TEST_DEPENDS=numpy==1.13.3 cache: directories: $HOME/.ccache - os: linux @@ -401,7 +449,22 @@ jobs: - PLAT=i686 - ENABLE_CONTRIB=0 - ENABLE_HEADLESS=1 - - TEST_DEPENDS=numpy==1.11.3 + - TEST_DEPENDS=numpy==1.13.3 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.6 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 - USE_CCACHE=0 cache: directories: $HOME/.ccache @@ -429,6 +492,21 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.7 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache - os: linux language: generic dist: xenial @@ -453,6 +531,60 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.8 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.3 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=i686 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.3 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=0 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache # contrib builds for Linux - os: linux @@ -460,7 +592,8 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.6 + - TEST_DEPENDS=numpy==1.13.3 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 cache: @@ -470,22 +603,27 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.6 - PLAT=i686 + - TEST_DEPENDS=numpy==1.13.3 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - MB_PYTHON_VERSION=3.6 - - TEST_DEPENDS=numpy==1.11.3 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux @@ -493,12 +631,10 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.6 - - PLAT=i686 - - TEST_DEPENDS=numpy==1.11.3 + - MB_PYTHON_VERSION=3.7 + - TEST_DEPENDS=numpy==1.14.5 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 - - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux @@ -507,21 +643,25 @@ jobs: services: docker env: - MB_PYTHON_VERSION=3.7 + - PLAT=i686 - TEST_DEPENDS=numpy==1.14.5 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 + - USE_CCACHE=0 cache: directories: $HOME/.ccache - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - MB_PYTHON_VERSION=3.7 - - PLAT=i686 - - TEST_DEPENDS=numpy==1.14.5 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 - USE_CCACHE=0 cache: directories: $HOME/.ccache @@ -549,17 +689,30 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache - - - # headless contrib builds for Linux - os: linux + arch: arm64 language: generic dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.8 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 - ENABLE_CONTRIB=1 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - TEST_DEPENDS=numpy==1.19.3 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=0 cache: directories: $HOME/.ccache - os: linux @@ -567,20 +720,39 @@ jobs: dist: xenial services: docker env: - - MB_PYTHON_VERSION=3.5 + - MB_PYTHON_VERSION=3.9 - PLAT=i686 + - TEST_DEPENDS=numpy==1.19.3 - ENABLE_CONTRIB=1 - - ENABLE_HEADLESS=1 + - ENABLE_HEADLESS=0 - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=0 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + + + # headless contrib builds for Linux - os: linux language: generic dist: xenial services: docker env: - MB_PYTHON_VERSION=3.6 - - TEST_DEPENDS=numpy==1.11.3 + - TEST_DEPENDS=numpy==1.13.3 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=1 cache: @@ -592,12 +764,27 @@ jobs: env: - MB_PYTHON_VERSION=3.6 - PLAT=i686 - - TEST_DEPENDS=numpy==1.11.3 + - TEST_DEPENDS=numpy==1.13.3 - ENABLE_CONTRIB=1 - ENABLE_HEADLESS=1 - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.6 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache - os: linux language: generic dist: xenial @@ -622,6 +809,21 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.7 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache - os: linux language: generic dist: xenial @@ -646,6 +848,60 @@ jobs: - USE_CCACHE=0 cache: directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.8 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - TEST_DEPENDS=numpy==1.19.3 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + cache: + directories: $HOME/.ccache + - os: linux + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=i686 + - TEST_DEPENDS=numpy==1.19.3 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache + - os: linux + arch: arm64 + language: generic + dist: xenial + services: docker + env: + - MB_PYTHON_VERSION=3.9 + - PLAT=aarch64 + - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8 + - ENABLE_CONTRIB=1 + - ENABLE_HEADLESS=1 + - TEST_DEPENDS=numpy==1.19.0 + - USE_CCACHE=0 + cache: + directories: $HOME/.ccache # The first line is printed in the folding header in Travis output before_install: | @@ -756,13 +1012,13 @@ after_success: | fi if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - pip install --user twine - pip install --user --upgrade six - if [[ $SDIST == 1 ]]; then - twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv* + pip install twine + twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv* else - twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv* + pip install --user twine + pip install --user --upgrade six + twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv* fi fi @@ -775,9 +1031,9 @@ after_success: | /usr/bin/python -m pip install --user -U -I twine if [[ $SDIST == 1 ]]; then - /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv* + /usr/bin/python -m twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv* else - /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv* + /usr/bin/python -m twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv* fi fi diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt index e5aaa258..20f4fb37 100644 --- a/LICENSE-3RD-PARTY.txt +++ b/LICENSE-3RD-PARTY.txt @@ -1,48 +1,208 @@ OpenCV library is redistributed within opencv-python package. This license applies to OpenCV binary in the directory cv2/. -By downloading, copying, installing or using the software you agree to this license. -If you do not agree to this license, do not download, install, -copy or use the software. - - License Agreement - For Open Source Computer Vision Library - (3-clause BSD License) - -Copyright (C) 2000-2020, Intel Corporation, all rights reserved. -Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. -Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved. -Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. -Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved. -Copyright (C) 2015-2016, Itseez Inc., all rights reserved. -Copyright (C) 2019-2020, Xperience AI, all rights reserved. -Third party copyrights are property of their respective owners. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the names of the copyright holders nor the names of the contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -This software is provided by the copyright holders and contributors "as is" and -any express or implied warranties, including, but not limited to, the implied -warranties of merchantability and fitness for a particular purpose are disclaimed. -In no event shall copyright holders or contributors be liable for any direct, -indirect, incidental, special, exemplary, or consequential damages -(including, but not limited to, procurement of substitute goods or services; -loss of use, data, or profits; or business interruption) however caused -and on any theory of liability, whether in contract, strict liability, -or tort (including negligence or otherwise) arising in any way out of -the use of this software, even if advised of the possibility of such damage. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. ------------------------------------------------------------------------------ libvpx is redistributed within all opencv-python Linux packages. @@ -81,8 +241,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ FFmpeg is redistributed within all opencv-python packages. -Qt 4.8.7 is redistributed within non-headless opencv-python Linux packages. -Libuuid is redistributed within all opencv-python Linux packages. Libbluray, libgnutls, libnettle, libhogweed, libintl, libmp3lame, libp11, librtmp, libsoxr and libtasn1 are redistributed within all opencv-python macOS packages. @@ -549,7 +707,7 @@ DAMAGES. END OF TERMS AND CONDITIONS ------------------------------------------------------------------------------ -Qt 5 is redistributed within non-headless opencv-python macOS packages. +Qt 5 is redistributed within non-headless opencv-python Linux and macOS packages. libgmp is redistributed within opencv-python macOS packages. libidn2 is redistributed within opencv-python macOS packages. libunistring is redistributed within opencv-python macOS packages. @@ -892,33 +1050,7 @@ This license applies to above binaries in the directory cv2/. */ ------------------------------------------------------------------------------ -libexpat is redistributed within all opencv-python Linux packages. -This license applies to libexpat binary in the directory cv2/. - -Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper -Copyright (c) 2001-2019 Expat maintainers - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ------------------------------------------------------------------------------- -libfontconfig is redistributed within all opencv-python Linux and macOS packages. +libfontconfig is redistributed within all opencv-python macOS packages. This license applies to libfontconfig binary in the directory cv2/. Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard @@ -1279,261 +1411,6 @@ This license applies to libz binary in the directory cv2/. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu ------------------------------------------------------------------------------- -libXcursor is redistributed within opencv-python Linux packages. -This license applies to libXcursor binary in the directory cv2/. - -Copyright © 2002 Keith Packard - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Keith Packard not be used in -advertising or publicity pertaining to distribution of the software without -specific, written prior permission. Keith Packard makes no -representations about the suitability of this software for any purpose. It -is provided "as is" without express or implied warranty. - -KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - ------------------------------------------------------------------------------- -libXfixes is redistributed within opencv-python Linux packages. -This license applies to libXfixes binary in the directory cv2/. - -Copyright © 2001,2003 Keith Packard - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Keith Packard not be used in -advertising or publicity pertaining to distribution of the software without -specific, written prior permission. Keith Packard makes no -representations about the suitability of this software for any purpose. It -is provided "as is" without express or implied warranty. - -KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - ------------------------------------------------------------------------------- -libXi is redistributed within opencv-python Linux packages. -This license applies to libXi binary in the directory cv2/. - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Hewlett-Packard not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -Copyright 2008 Peter Hutterer - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the author shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the author. - -Copyright © 2009 Red Hat, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - ------------------------------------------------------------------------------- -libXinerama is redistributed within opencv-python Linux packages. -This license applies to libXinerama binary in the directory cv2/. - -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - ------------------------------------------------------------------------------- -libXrandr is redistributed within opencv-python Linux packages. -This license applies to libXrandr binary in the directory cv2/. - -Copyright © 2000, Compaq Computer Corporation, -Copyright © 2002, Hewlett Packard, Inc. - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Compaq or HP not be used in advertising -or publicity pertaining to distribution of the software without specific, -written prior permission. HP makes no representations about the -suitability of this software for any purpose. It is provided "as is" -without express or implied warranty. - -HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP -BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Copyright © 2000 Compaq Computer Corporation, Inc. -Copyright © 2002 Hewlett-Packard Company, Inc. -Copyright © 2006 Intel Corporation -Copyright © 2008 Red Hat, Inc. -Copyright © 2011 Dave Airlie - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting documentation, and -that the name of the copyright holders not be used in advertising or -publicity pertaining to distribution of the software without specific, -written prior permission. The copyright holders make no representations -about the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -OF THIS SOFTWARE. - -Copyright © 2000 Compaq Computer Corporation, Inc. -Copyright © 2002 Hewlett Packard Company, Inc. -Copyright © 2006 Keith Packard - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting documentation, and -that the name of the copyright holders not be used in advertising or -publicity pertaining to distribution of the software without specific, -written prior permission. The copyright holders make no representations -about the suitability of this software for any purpose. It is provided "as -is" without express or implied warranty. - -THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -OF THIS SOFTWARE. - ------------------------------------------------------------------------------ libdav1d is redistributed within opencv-python macOS packages. This license applies to libdav1d binary in the directory cv2/. @@ -2329,3 +2206,233 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ +Libxcb utility libraries are redistributed within opencv-python non-headless Linux packages. +This license applies to libxcb related binaries in the directory cv2/. + +Copyright (C) 2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall +be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors +or their institutions shall not be used in advertising or +otherwise to promote the sale, use or other dealings in this +Software without prior written authorization from the +authors. + +------------------------------------------------------------------------------ +Libxcb-image is redistributed within opencv-python non-headless Linux packages. +This license applies to libxcb-image binary in the directory cv2/. + +Copyright © 2007-2008 Bart Massey +Copyright © 2008 Julien Danjou +Copyright © 2008 Keith Packard + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or +their institutions shall not be used in advertising or otherwise to +promote the sale, use or other dealings in this Software without +prior written authorization from the authors. + +------------------------------------------------------------------------------ +Libxcb-util is redistributed within opencv-python non-headless Linux packages. +This license applies to libxcb-util binary in the directory cv2/. + +Copyright © 2008 Bart Massey +Copyright © 2008 Ian Osgood +Copyright © 2008 Jamey Sharp +Copyright © 2008 Josh Triplett +Copyright © 2008-2009 Julien Danjou + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or +their institutions shall not be used in advertising or otherwise to +promote the sale, use or other dealings in this Software without +prior written authorization from the authors. + +------------------------------------------------------------------------------ +Libxcb-render-util is redistributed within opencv-python non-headless Linux packages. +This license applies to libxcb-render-util binary in the directory cv2/. + +Copyright © 2000 Keith Packard + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation, and that the name of Keith Packard not be used in +advertising or publicity pertaining to distribution of the software without +specific, written prior permission. Keith Packard makes no +representations about the suitability of this software for any purpose. It +is provided "as is" without express or implied warranty. + +KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +Copyright © 2006 Jamey Sharp. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. + +Copyright © 2006 Ian Osgood + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. + +------------------------------------------------------------------------------ +Libxcb-icccm is redistributed within opencv-python non-headless Linux packages. +This license applies to Libxcb-icccm binary in the directory cv2/. + +Copyright © 2008-2011 Arnaud Fontaine +Copyright © 2007-2008 Vincent Torri + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or +their institutions shall not be used in advertising or otherwise to +promote the sale, use or other dealings in this Software without +prior written authorization from the authors. + +------------------------------------------------------------------------------ +libXau is redistributed within opencv-python non-headless Linux packages. +This license applies to libXau binary in the directory cv2/. + +Copyright 1988, 1993, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. \ No newline at end of file diff --git a/README.md b/README.md index 13462507..6c6022ba 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,31 @@ ## OpenCV on Wheels -**Unofficial** pre-built OpenCV packages for Python. +**Unofficial** pre-built CPU-only OpenCV packages for Python. + +Check the manual build section if you wish to compile the bindings from source to enable additional modules such as CUDA. ### Installation and Usage 1. If you have previous/other manually installed (= not installed via ``pip``) version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts. -2. Select the correct package for your environment: +2. Make sure that your `pip` version is up-to-date (19.3 is the minimum supported version): `pip install --upgrade pip`. Check version with `pip -V`. For example Linux distributions ship usually with very old `pip` versions which cause a lot of unexpected problems especially with the `manylinux` format. +3. Select the correct package for your environment: - There are four different packages and you should **select only one of them**. Do not install multiple different packages in the same environment. There is no plugin architecture: all the packages use the same namespace (`cv2`). If you installed multiple different packages in the same environment, uninstall them all with ``pip uninstall`` and reinstall only one package. + There are four different packages (see options 1, 2, 3 and 4 below) and you should **SELECT ONLY ONE OF THEM**. Do not install multiple different packages in the same environment. There is no plugin architecture: all the packages use the same namespace (`cv2`). If you installed multiple different packages in the same environment, uninstall them all with ``pip uninstall`` and reinstall only one package. **a.** Packages for standard desktop environments (Windows, macOS, almost any GNU/Linux distribution) - - run ``pip install opencv-python`` if you need only main modules - - run ``pip install opencv-contrib-python`` if you need both main and contrib modules (check extra modules listing from [OpenCV documentation](https://docs.opencv.org/master/)) + - Option 1 - Main modules package: ``pip install opencv-python`` + - Option 2 - Full package (contains both main modules and contrib/extra modules): ``pip install opencv-contrib-python`` (check contrib/extra modules listing from [OpenCV documentation](https://docs.opencv.org/master/)) - **b.** Packages for server (headless) environments + **b.** Packages for server (headless) environments (such as Docker, cloud environments etc.), no GUI library dependencies - These packages do not contain any GUI functionality. They are smaller and suitable for more restricted environments. + These packages are smaller than the two other packages above because they do not contain any GUI functionality (not compiled with Qt / other GUI components). This means that the packages avoid a heavy dependency chain to X11 libraries and you will have for example smaller Docker images as a result. You should always use these packages if you do not use `cv2.imshow` et al. or you are using some other package (such as PyQt) than OpenCV to create your GUI. - - run ``pip install opencv-python-headless`` if you need only main modules - - run ``pip install opencv-contrib-python-headless`` if you need both main and contrib modules (check extra modules listing from [OpenCV documentation](https://docs.opencv.org/master/)) + - Option 3 - Headless main modules package: ``pip install opencv-python-headless`` + - Option 4 - Headless full package (contains both main modules and contrib/extra modules): ``pip install opencv-contrib-python-headless`` (check contrib/extra modules listing from [OpenCV documentation](https://docs.opencv.org/master/)) -3. Import the package: +4. Import the package: ``import cv2`` @@ -42,7 +45,11 @@ Frequently Asked Questions A: No, the packages are special wheel binary packages and they already contain statically built OpenCV binaries. -**Q: Pip fails with ``Could not find a version that satisfies the requirement ...``?** +**Q: Pip install fails with ``ModuleNotFoundError: No module named 'skbuild'``?** + +Since ``opencv-python`` version 4.3.0.\*, ``manylinux1`` wheels were replaced by ``manylinux2014`` wheels. If your pip is too old, it will try to use the new source distribution introduced in 4.3.0.38 to manually build OpenCV because it does not know how to install ``manylinux2014`` wheels. However, source build will also fail because of too old ``pip`` because it does not understand build dependencies in ``pyproject.toml``. To use the new ``manylinux2014`` pre-built wheels (or to build from source), your ``pip`` version must be >= 19.3. Please upgrade ``pip`` with ``pip install --upgrade pip``. + +**Q: Pip install fails with ``Could not find a version that satisfies the requirement ...``?** A: Most likely the issue is related to too old pip and can be fixed by running ``pip install --upgrade pip``. Note that the wheel (especially manylinux) format does not currently support properly ARM architecture so there are no packages for ARM based platforms in PyPI. However, ``opencv-python`` packages for Raspberry Pi can be found from https://www.piwheels.org/. @@ -73,7 +80,7 @@ A: It's easier for users to understand ``opencv-python`` than ``cv2`` and it mak ## Documentation for opencv-python [![AppVeyor CI test status (Windows)](https://img.shields.io/appveyor/ci/skvark/opencv-python.svg?maxAge=3600&label=Windows)](https://ci.appveyor.com/project/skvark/opencv-python) -[![Travis CI test status (Linux and macOS)](https://img.shields.io/travis/skvark/opencv-python.svg?maxAge=3600&label=Linux+macOS)](https://travis-ci.org/skvark/opencv-python) +[![Travis CI test status (Linux and macOS)](https://img.shields.io/travis/com/skvark/opencv-python/master?label=Linux%20%26%20macOS)](https://travis-ci.com/github/skvark/opencv-python/) The aim of this repository is to provide means to package each new [OpenCV release](https://github.com/opencv/opencv/releases) for the most used Python versions and platforms. @@ -124,16 +131,18 @@ If some dependency is not enabled in the pre-built wheels, you can also run the 1. Clone this repository: `git clone --recursive https://github.com/skvark/opencv-python.git` 2. ``cd opencv-python`` + - you can use `git` to checkout some other version of OpenCV in the `opencv` and `opencv_contrib` submodules if needed 3. Add custom Cmake flags if needed, for example: `export CMAKE_ARGS="-DSOME_FLAG=ON -DSOME_OTHER_FLAG=OFF"` (in Windows you need to set environment variables differently depending on Command Line or PowerShell) -4. Select the version which you wish to build with `ENABLE_CONTRIB` and `ENABLE_HEADLESS`: i.e. `export ENABLE_CONTRIB=1` if you wish to build `opencv-contrib-python` -5. Run ``pip wheel . --verbose``. NOTE: make sure you have the latest ``pip``, the ``pip wheel`` command replaces the old ``python setup.py bdist_wheel`` command which does not support ``pyproject.toml``. - - Optional: on Linux use the `manylinux` images as a build hosts if maximum portability is needed and run `auditwheel` for the wheel after build - - Optional: on macOS use ``delocate`` (same as ``auditwheel`` but for macOS) +4. Select the package flavor which you wish to build with `ENABLE_CONTRIB` and `ENABLE_HEADLESS`: i.e. `export ENABLE_CONTRIB=1` if you wish to build `opencv-contrib-python` +5. Run ``pip wheel . --verbose``. NOTE: make sure you have the latest ``pip`` version, the ``pip wheel`` command replaces the old ``python setup.py bdist_wheel`` command which does not support ``pyproject.toml``. + - this might take anything from 5 minutes to over 2 hours depending on your hardware 6. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish + - Optional: on Linux use some of the `manylinux` images as a build hosts if maximum portability is needed and run `auditwheel` for the wheel after build + - Optional: on macOS use ``delocate`` (same as ``auditwheel`` but for macOS) for better portability #### Source distributions -Since OpenCV version 4.3.0, also source distributions are provided in PyPI. This means that if your system is not compatible with any of the wheels in PyPI, ``pip`` will attempt to build OpenCV from sources. +Since OpenCV version 4.3.0, also source distributions are provided in PyPI. This means that if your system is not compatible with any of the wheels in PyPI, ``pip`` will attempt to build OpenCV from sources. If you need a OpenCV version which is not available in PyPI as a source distribution, please follow the manual build guidance above instead of this one. You can also force ``pip`` to build the wheels from the source distribution. Some examples: @@ -142,21 +151,19 @@ You can also force ``pip`` to build the wheels from the source distribution. Som If you need contrib modules or headless version, just change the package name (step 4 in the previous section is not needed). However, any additional CMake flags can be provided via environment variables as described in step 3 of the manual build section. If none are provided, OpenCV's CMake scripts will attempt to find and enable any suitable dependencies. Headless distributions have hard coded CMake flags which disable all possible GUI dependencies. -Please note that build tools and ``numpy`` are required for the build to succeed. On slow systems such as Raspberry Pi the full build may take several hours. On a 8-core Ryzen 7 3700X the build takes about 6 minutes. +On slow systems such as Raspberry Pi the full build may take several hours. On a 8-core Ryzen 7 3700X the build takes about 6 minutes. ### Licensing Opencv-python package (scripts in this repository) is available under MIT license. -OpenCV itself is available under [3-clause BSD License](https://github.com/opencv/opencv/blob/master/LICENSE). +OpenCV itself is available under [Apache 2](https://github.com/opencv/opencv/blob/master/LICENSE) license. Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt). All wheels ship with [FFmpeg](http://ffmpeg.org) licensed under the [LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). -Non-headless Linux wheels ship with [Qt 4.8.7](http://doc.qt.io/qt-4.8/lgpl.html) licensed under the [LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html). - -Non-headless MacOS wheels ship with [Qt 5](http://doc.qt.io/qt-5/lgpl.html) licensed under the [LGPLv3](http://www.gnu.org/licenses/lgpl-3.0.html). +Non-headless Linux and MacOS wheels ship with [Qt 5](http://doc.qt.io/qt-5/lgpl.html) licensed under the [LGPLv3](http://www.gnu.org/licenses/lgpl-3.0.html). The packages include also other binaries. Full list of licenses can be found from [LICENSE-3RD-PARTY.txt](https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt). @@ -182,20 +189,18 @@ These artifacts can't be and will not be uploaded to PyPI. ### Manylinux wheels -Linux wheels are built using [manylinux](https://github.com/pypa/python-manylinux-demo). These wheels should work out of the box for most of the distros (which use GNU C standard library) out there since they are built against an old version of glibc. +Linux wheels are built using [manylinux2014](https://github.com/pypa/manylinux). These wheels should work out of the box for most of the distros (which use GNU C standard library) out there since they are built against an old version of glibc. -The default ``manylinux`` images have been extended with some OpenCV dependencies. See [Docker folder](https://github.com/skvark/opencv-python/tree/master/docker) for more info. +The default ``manylinux2014`` images have been extended with some OpenCV dependencies. See [Docker folder](https://github.com/skvark/opencv-python/tree/master/docker) for more info. ### Supported Python versions -Python 3.x releases are provided for officially supported versions (not in EOL). - -Currently, builds for following Python versions are provided: +Python 3.x compatible pre-built wheels are provided for the officially supported Python versions (not in EOL): -- 3.5 (EOL in 2020-09-13, builds for 3.5 will not be provided after this) - 3.6 - 3.7 - 3.8 +- 3.9 ### Backward compatibility diff --git a/appveyor.yml b/appveyor.yml index 8b058c68..c79e7de4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,191 +1,201 @@ -environment: - USER: - secure: fXgF9uyy6sT0JoVOR7BoqA== - - PASS: - secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys= - - matrix: - - PYTHON: "C:/Python35" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python35-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python36" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python36-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python37" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python37-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python38" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python38-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python35" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python35-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python36" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python36-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python37" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python37-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python38" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python38-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 0 - - - PYTHON: "C:/Python35" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python35-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python36" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python36-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python37" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python37-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python38" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python38-x64" - ENABLE_CONTRIB: 0 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python35" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python35-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python36" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python36-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python37" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python37-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python38" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - - - PYTHON: "C:/Python38-x64" - ENABLE_CONTRIB: 1 - ENABLE_HEADLESS: 1 - -matrix: - fast_finish: true - -build_script: -- cmd: | - "%PYTHON%/python.exe" -m pip install --upgrade pip - "%PYTHON%/python.exe" -m pip install --upgrade setuptools - set "CI_BUILD=1" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose - -before_test: -- ps: | - - cd ${Env:APPVEYOR_BUILD_FOLDER}\tests - $env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command" - &"${Env:PYTHON}/python.exe" -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl") - if ($LastExitCode -ne 0) {throw $LastExitCode} - -test_script: -- cmd: | - - cd %APPVEYOR_BUILD_FOLDER%\tests - "%PYTHON%/python.exe" -m unittest test - -artifacts: -- path: dist\opencv*.whl - name: wheels - -deploy_script: -- ps: | - - if (${Env:APPVEYOR_REPO_TAG} -eq "true") { - cd ${Env:APPVEYOR_BUILD_FOLDER} - if (${Env:ENABLE_CONTRIB} -eq 0) { - if (${Env:ENABLE_HEADLESS} -eq 0) { - echo "This is a default build. Deployment will be done to PyPI entry opencv-python." - } - else { - echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless." - } - } - else { - if (${Env:ENABLE_HEADLESS} -eq 0) { - echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python." - } - else { - echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless." - } - } - - &"${Env:PYTHON}/python.exe" -m pip install twine - &"${Env:PYTHON}/python.exe" -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv* - } - else { - echo "Tag not set, deployment skipped." - } +environment: + USER: + secure: fXgF9uyy6sT0JoVOR7BoqA== + + PASS: + secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys= + + matrix: + - PYTHON: "C:\\Python36" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python36-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python37" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python37-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python38" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python38-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python39" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python39-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python36" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python36-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python37" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python37-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python38" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python38-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python39" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python39-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 0 + + - PYTHON: "C:\\Python36" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python36-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python37" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python37-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python38" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python38-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python39" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python39-x64" + ENABLE_CONTRIB: 0 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python36" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python36-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python37" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python37-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python38" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python38-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python39" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + + - PYTHON: "C:\\Python39-x64" + ENABLE_CONTRIB: 1 + ENABLE_HEADLESS: 1 + +matrix: + fast_finish: true + +install: + - ps: | + if (-not (Test-Path $env:PYTHON)) { + curl -o install_python.ps1 https://raw.githubusercontent.com/matthew-brett/multibuild/devel/install_python.ps1 + .\install_python.ps1 + } + - ps: if (-not (Test-Path $env:PYTHON)) { throw "No $env:PYTHON" } + - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + - python --version + +build_script: +- cmd: | + "%PYTHON%\\python.exe" -m pip install --upgrade pip + "%PYTHON%\\python.exe" -m pip install --upgrade setuptools + set "CI_BUILD=1" && "%PYTHON%\\python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose + +before_test: +- ps: | + + cd ${Env:APPVEYOR_BUILD_FOLDER}\tests + $env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command" + &"${Env:PYTHON}\\python.exe" -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl") + if ($LastExitCode -ne 0) {throw $LastExitCode} + +test_script: +- cmd: | + + cd %APPVEYOR_BUILD_FOLDER%\tests + "%PYTHON%\\python.exe" -m unittest test + +artifacts: +- path: dist\opencv*.whl + name: wheels + +deploy_script: +- ps: | + + if (${Env:APPVEYOR_REPO_TAG} -eq "true") { + cd ${Env:APPVEYOR_BUILD_FOLDER} + if (${Env:ENABLE_CONTRIB} -eq 0) { + if (${Env:ENABLE_HEADLESS} -eq 0) { + echo "This is a default build. Deployment will be done to PyPI entry opencv-python." + } + else { + echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless." + } + } + else { + if (${Env:ENABLE_HEADLESS} -eq 0) { + echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python." + } + else { + echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless." + } + } + + &"${Env:PYTHON}\\python.exe" -m pip install twine + &"${Env:PYTHON}\\python.exe" -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv* + } + else { + echo "Tag not set, deployment skipped." + } diff --git a/cv2/__init__.py b/cv2/__init__.py index b901c204..d665b75c 100644 --- a/cv2/__init__.py +++ b/cv2/__init__.py @@ -1,24 +1,33 @@ -import importlib -import os -import sys - -from .cv2 import * -from .data import * - -# wildcard import above does not import "private" variables like __version__ -# this makes them available -globals().update(importlib.import_module('cv2.cv2').__dict__) - -is_ci_build = False - -try: - from .version import ci_build - is_ci_build = ci_build -except: - pass - -# the Qt plugin is included currently only in the pre-built wheels -if sys.platform == 'darwin' and is_ci_build: - os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join( - os.path.dirname(os.path.abspath(__file__)), 'qt', 'plugins' - ) +import importlib +import os +import sys + +from .cv2 import * +from .data import * + +# wildcard import above does not import "private" variables like __version__ +# this makes them available +globals().update(importlib.import_module("cv2.cv2").__dict__) + +ci_and_not_headless = False + +try: + from .version import ci_build, headless + + ci_and_not_headless = ci_build and not headless +except: + pass + +# the Qt plugin is included currently only in the pre-built wheels +if ( + sys.platform == "darwin" or sys.platform.startswith("linux") +) and ci_and_not_headless: + os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "qt", "plugins" + ) + +# Qt will throw warning on Linux if fonts are not found +if sys.platform.startswith("linux") and ci_and_not_headless: + os.environ["QT_QPA_FONTDIR"] = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "qt", "fonts" + ) diff --git a/cv2/data/__init__.py b/cv2/data/__init__.py index 12c818d9..1cad2750 100644 --- a/cv2/data/__init__.py +++ b/cv2/data/__init__.py @@ -1,3 +1,3 @@ import os -haarcascades = os.path.join(os.path.dirname(__file__), '') +haarcascades = os.path.join(os.path.dirname(__file__), "") diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64 new file mode 100644 index 00000000..e8920770 --- /dev/null +++ b/docker/manylinux2014/Dockerfile_aarch64 @@ -0,0 +1,73 @@ +FROM quay.io/pypa/manylinux2014_aarch64:latest + +RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y + +RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.tar.xz && \ + tar -xf qt-everywhere-src-5.15.0.tar.xz && \ + cd qt-everywhere* && \ + export MAKEFLAGS=-j$(nproc) && \ + ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ + make && \ + make install && \ + cd .. && \ + rm -rf qt-everywhere-src-5.15.0 && \ + rm qt-everywhere-src-5.15.0.tar.xz + +ENV QTDIR /opt/Qt5.15.0 +ENV PATH "$QTDIR/bin:$PATH" + +RUN mkdir ~/ffmpeg_sources && \ + cd ~/ffmpeg_sources && \ + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \ + tar -xf OpenSSL_1_1_1g.tar.gz && \ + cd openssl-OpenSSL_1_1_1g && \ + ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + # skip installing documentation + make install_sw && \ + rm -rf ~/openssl_build + +RUN cd ~/ffmpeg_sources && \ + curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.14.01/nasm-2.14.01.tar.bz2 && \ + tar -xf nasm-2.14.01.tar.bz2 && cd nasm-2.14.01 && ./autogen.sh && \ + ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install + +RUN cd ~/ffmpeg_sources && \ + curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \ + tar -xf yasm-1.3.0.tar.gz && \ + cd yasm-1.3.0 && \ + ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install + +RUN cd ~/ffmpeg_sources && \ + git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ + cd libvpx && \ + ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install + +RUN cd ~/ffmpeg_sources && \ + curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \ + tar -xf ffmpeg-snapshot.tar.bz2 && \ + cd ffmpeg && \ + PATH=~/bin:$PATH && \ + PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install && \ + echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ + ldconfig && \ + rm -rf ~/ffmpeg_sources + +RUN curl -O -L https://github.com/ccache/ccache/releases/download/v3.7.9/ccache-3.7.9.tar.gz && \ + tar -xf ccache-3.7.9.tar.gz && \ + cd ccache-3.7.9 && \ + linux32 ./configure && \ + make -j$(getconf _NPROCESSORS_ONLN) && \ + make install + +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig +ENV LDFLAGS -L/root/ffmpeg_build/lib +ENV PATH "$HOME/bin:$PATH" diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686 index c50a5018..39fc1560 100644 --- a/docker/manylinux2014/Dockerfile_i686 +++ b/docker/manylinux2014/Dockerfile_i686 @@ -1,15 +1,29 @@ FROM quay.io/pypa/manylinux2014_i686:latest -RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y +RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y + +RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.tar.xz && \ + tar -xf qt-everywhere-src-5.15.0.tar.xz && \ + cd qt-everywhere* && \ + export MAKEFLAGS=-j$(nproc) && \ + ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ + make && \ + make install && \ + cd .. && \ + rm -rf qt-everywhere-src-5.15.0 && \ + rm qt-everywhere-src-5.15.0.tar.xz + +ENV QTDIR /opt/Qt5.15.0 +ENV PATH "$QTDIR/bin:$PATH" RUN mkdir ~/ffmpeg_sources && \ cd ~/ffmpeg_sources && \ - curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \ - tar -xf OpenSSL_1_1_1c.tar.gz && \ - cd openssl-OpenSSL_1_1_1c && \ + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \ + tar -xf OpenSSL_1_1_1g.tar.gz && \ + cd openssl-OpenSSL_1_1_1g && \ # in i686, ./config detects x64 in i686 container without linux32 # when run from "docker build" - linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \ + linux32 ./config --prefix="$HOME/ffmpeg_build" no-pinshared shared zlib && \ make -j$(getconf _NPROCESSORS_ONLN) && \ #skip installing documentation make install_sw && \ diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64 index df7e106e..010120ca 100644 --- a/docker/manylinux2014/Dockerfile_x86_64 +++ b/docker/manylinux2014/Dockerfile_x86_64 @@ -1,13 +1,27 @@ FROM quay.io/pypa/manylinux2014_x86_64:latest -RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y +RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel freetype-devel -y + +RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.tar.xz && \ + tar -xf qt-everywhere-src-5.15.0.tar.xz && \ + cd qt-everywhere* && \ + export MAKEFLAGS=-j$(nproc) && \ + ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ + make && \ + make install && \ + cd .. && \ + rm -rf qt-everywhere-src-5.15.0 && \ + rm qt-everywhere-src-5.15.0.tar.xz + +ENV QTDIR /opt/Qt5.15.0 +ENV PATH "$QTDIR/bin:$PATH" RUN mkdir ~/ffmpeg_sources && \ cd ~/ffmpeg_sources && \ - curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \ - tar -xf OpenSSL_1_1_1c.tar.gz && \ - cd openssl-OpenSSL_1_1_1c && \ - ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \ + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \ + tar -xf OpenSSL_1_1_1g.tar.gz && \ + cd openssl-OpenSSL_1_1_1g && \ + ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \ make -j$(getconf _NPROCESSORS_ONLN) && \ # skip installing documentation make install_sw && \ diff --git a/find_version.py b/find_version.py index 76d9f86d..6c676b23 100644 --- a/find_version.py +++ b/find_version.py @@ -1,56 +1,68 @@ -import sys -import os -import subprocess - -if __name__ == "__main__": - contrib = sys.argv[1] - headless = sys.argv[2] - ci_build = sys.argv[3] - - opencv_version = "" - # dig out the version from OpenCV sources - version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp" - - with open(version_file_path, 'r') as f: - for line in f: - words = line.split() - - if "CV_VERSION_MAJOR" in words: - opencv_version += words[2] - opencv_version += "." - - if "CV_VERSION_MINOR" in words: - opencv_version += words[2] - opencv_version += "." - - if "CV_VERSION_REVISION" in words: - opencv_version += words[2] - break - - # used in local dev releases - git_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).splitlines()[0].decode() - # this outputs the annotated tag if we are exactly on a tag, otherwise --g - try: - tag = subprocess.check_output(['git', 'describe', '--tags'], stderr = subprocess.STDOUT).splitlines()[0].decode().split('-') - except subprocess.CalledProcessError as e: - # no tags reachable (e.g. on a topic branch in a fork), see - # https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything - if e.output.rstrip() == b"fatal: No names found, cannot describe anything.": - tag=[] - else: - print(e.output); raise - - if len(tag) == 1: - # tag identifies the build and should be a sequential revision number - version = tag[0] - opencv_version += ".{}".format(version) - else: - # local version identifier, not to be published on PyPI - version = git_hash - opencv_version += "+{}".format(version) - - with open('cv2/version.py', 'w') as f: - f.write("opencv_version = \"{}\"\n".format(opencv_version)) - f.write("contrib = {}\n".format(contrib)) - f.write("headless = {}\n".format(headless)) - f.write("ci_build = {}".format(ci_build)) +import sys +import os +import subprocess + +if __name__ == "__main__": + contrib = sys.argv[1] + headless = sys.argv[2] + ci_build = sys.argv[3] + + opencv_version = "" + # dig out the version from OpenCV sources + version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp" + + with open(version_file_path, "r") as f: + for line in f: + words = line.split() + + if "CV_VERSION_MAJOR" in words: + opencv_version += words[2] + opencv_version += "." + + if "CV_VERSION_MINOR" in words: + opencv_version += words[2] + opencv_version += "." + + if "CV_VERSION_REVISION" in words: + opencv_version += words[2] + break + + # used in local dev releases + git_hash = ( + subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) + .splitlines()[0] + .decode() + ) + # this outputs the annotated tag if we are exactly on a tag, otherwise --g + try: + tag = ( + subprocess.check_output( + ["git", "describe", "--tags"], stderr=subprocess.STDOUT + ) + .splitlines()[0] + .decode() + .split("-") + ) + except subprocess.CalledProcessError as e: + # no tags reachable (e.g. on a topic branch in a fork), see + # https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything + if e.output.rstrip() == b"fatal: No names found, cannot describe anything.": + tag = [] + else: + print(e.output) + raise + + if len(tag) == 1: + # tag identifies the build and should be a sequential revision number + version = tag[0] + opencv_version += ".{}".format(version) + else: + # local version identifier, not to be published on PyPI + version = git_hash + opencv_version += "+{}".format(version) + + with open("cv2/version.py", "w") as f: + f.write('opencv_version = "{}"\n'.format(opencv_version)) + f.write("contrib = {}\n".format(contrib)) + f.write("headless = {}\n".format(headless)) + f.write("ci_build = {}".format(ci_build)) diff --git a/multibuild b/multibuild index c2890dc8..8882150d 160000 --- a/multibuild +++ b/multibuild @@ -1 +1 @@ -Subproject commit c2890dc8dc93f99b0eadd76f87aa181f6aea42da +Subproject commit 8882150df6529658700b66bec124dfb77eefca26 diff --git a/patch_auditwheel_whitelist.py b/patch_auditwheel_whitelist.py new file mode 100644 index 00000000..d0cbf5b2 --- /dev/null +++ b/patch_auditwheel_whitelist.py @@ -0,0 +1,16 @@ +from os.path import join, dirname, abspath +import json + +from auditwheel import policy + +policies = None + +with open(join(dirname(abspath(policy.__file__)), "policy.json")) as f: + policies = json.load(f) + +for p in policies: + if p["name"] == "manylinux2014": + p["lib_whitelist"].append("libxcb.so.1") + +with open(join(dirname(abspath(policy.__file__)), "policy.json"), "w") as f: + f.write(json.dumps(policies)) diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins index c69ef795..03560f17 100644 --- a/patches/patchQtPlugins +++ b/patches/patchQtPlugins @@ -1,12 +1,18 @@ diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt -index 8ccad4d03a..0d5e2a79e9 100644 +index 4c0b3880fc..dffa0a4caa 100644 --- a/opencv/CMakeLists.txt +++ b/opencv/CMakeLists.txt -@@ -1164,6 +1164,7 @@ if(WITH_QT OR HAVE_QT) +@@ -1187,6 +1187,13 @@ if(WITH_QT OR HAVE_QT) if(HAVE_QT5) status(" QT:" "YES (ver ${Qt5Core_VERSION_STRING})") status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO) -+ install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt) ++ if(APPLE) ++ install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt) ++ endif() ++ if(UNIX AND NOT APPLE) ++ install(DIRECTORY /opt/Qt5.15.0/plugins DESTINATION lib/qt) ++ install(DIRECTORY /usr/share/fonts DESTINATION lib/qt) ++ endif() elseif(HAVE_QT) status(" QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})") - status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO) \ No newline at end of file + status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO) diff --git a/pyproject.toml b/pyproject.toml index 7522b5ef..d7c5527d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,9 @@ [build-system] requires = [ "setuptools", "wheel", "scikit-build", "cmake", "pip", - "numpy==1.11.3; python_version=='3.5'", - "numpy==1.13.3; python_version=='3.6'", - "numpy==1.14.5; python_version=='3.7'", - "numpy==1.17.3; python_version>='3.8'" -] \ No newline at end of file + "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64'", + "numpy==1.19.3; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'", + "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64'", + "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64'", + "numpy==1.19.3; python_version>='3.9' and platform_machine != 'aarch64'" +] diff --git a/setup.py b/setup.py index 323efaab..a4f9f729 100644 --- a/setup.py +++ b/setup.py @@ -1,430 +1,457 @@ -import io -import os -import os.path -import sys -import runpy -import subprocess -import re -import sysconfig -import skbuild -from skbuild import cmaker - - -def main(): - os.chdir(os.path.dirname(os.path.abspath(__file__))) - - CI_BUILD = os.environ.get("CI_BUILD", "False") - is_CI_build = True if CI_BUILD == "1" else False - cmake_source_dir = "opencv" - minimum_supported_numpy = "1.13.1" - build_contrib = get_build_env_var_by_name("contrib") - build_headless = get_build_env_var_by_name("headless") - build_java = 'ON' if get_build_env_var_by_name("java") else 'OFF' - - if sys.version_info[:2] >= (3, 6): - minimum_supported_numpy = "1.13.3" - if sys.version_info[:2] >= (3, 7): - minimum_supported_numpy = "1.14.5" - if sys.version_info[:2] >= (3, 8): - minimum_supported_numpy = "1.17.3" - - numpy_version = "numpy>=%s" % minimum_supported_numpy - - python_version = cmaker.CMaker.get_python_version() - python_lib_path = cmaker.CMaker.get_python_library(python_version).replace( - "\\", "/" - ) - python_include_dir = cmaker.CMaker.get_python_include_dir(python_version).replace( - "\\", "/" - ) - - if os.path.exists(".git"): - import pip._internal.vcs.git as git - - g = git.Git() # NOTE: pip API's are internal, this has to be refactored - - g.run_command(["submodule", "sync"]) - g.run_command( - ["submodule", "update", "--init", "--recursive", cmake_source_dir] - ) - - if build_contrib: - g.run_command( - ["submodule", "update", "--init", "--recursive", "opencv_contrib"] - ) - - package_version, build_contrib, build_headless = get_and_set_info( - build_contrib, build_headless, is_CI_build - ) - - # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode - x64 = sys.maxsize > 2 ** 32 - - package_name = "opencv-python" - - if build_contrib and not build_headless: - package_name = "opencv-contrib-python" - - if build_contrib and build_headless: - package_name = "opencv-contrib-python-headless" - - if build_headless and not build_contrib: - package_name = "opencv-python-headless" - - long_description = io.open("README.md", encoding="utf-8").read() - - packages = ["cv2", "cv2.data"] - - package_data = { - "cv2": ["*%s" % sysconfig.get_config_vars().get("SO"), "version.py"] - + (["*.dll"] if os.name == "nt" else []) - + ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"], - "cv2.data": ["*.xml"], - } - - # Files from CMake output to copy to package. - # Path regexes with forward slashes relative to CMake install dir. - rearrange_cmake_output_data = { - "cv2": ( - [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if x64 else "")] - if os.name == "nt" - else [] - ) - + - # In Windows, in python/X.Y//; in Linux, in just python/X.Y/. - # Naming conventions vary so widely between versions and OSes - # had to give up on checking them. - [ - "python/cv2[^/]*%(ext)s" - % {"ext": re.escape(sysconfig.get_config_var("EXT_SUFFIX"))} - ], - "cv2.data": [ # OPENCV_OTHER_INSTALL_PATH - ("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml" - ], - } - - # Files in sourcetree outside package dir that should be copied to package. - # Raw paths relative to sourcetree root. - files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]} - - ci_cmake_generator = ( - ["-G", "Visual Studio 14" + (" Win64" if x64 else "")] - if os.name == "nt" - else ["-G", "Unix Makefiles"] - ) - - cmake_args = ( - (ci_cmake_generator if is_CI_build else []) - + [ - # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3 - "-DPYTHON3_EXECUTABLE=%s" % sys.executable, - "-DPYTHON3_INCLUDE_DIR=%s" % python_include_dir, - "-DPYTHON3_LIBRARY=%s" % python_lib_path, - "-DBUILD_opencv_python3=ON", - "-DBUILD_opencv_python2=OFF", - # Disable the Java build by default as it is not needed - "-DBUILD_opencv_java=%s" % build_java, - # When off, adds __init__.py and a few more helper .py's. We use our own helper files with a different structure. - "-DOPENCV_SKIP_PYTHON_LOADER=ON", - # Relative dir to install the built module to in the build tree. - # The default is generated from sysconfig, we'd rather have a constant for simplicity - "-DOPENCV_PYTHON3_INSTALL_PATH=python", - # Otherwise, opencv scripts would want to install `.pyd' right into site-packages, - # and skbuild bails out on seeing that - "-DINSTALL_CREATE_DISTRIB=ON", - # See opencv/CMakeLists.txt for options and defaults - "-DBUILD_opencv_apps=OFF", - "-DBUILD_SHARED_LIBS=OFF", - "-DBUILD_TESTS=OFF", - "-DBUILD_PERF_TESTS=OFF", - "-DBUILD_DOCS=OFF", - ] - + ( - ["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] - if build_contrib - else [] - ) - ) - - if build_headless: - # it seems that cocoa cannot be disabled so on macOS the package is not truly headless - cmake_args.append("-DWITH_WIN32UI=OFF") - cmake_args.append("-DWITH_QT=OFF") - cmake_args.append("-DWITH_GTK=OFF") - if is_CI_build: - cmake_args.append( - "-DWITH_MSMF=OFF" - ) # see: https://github.com/skvark/opencv-python/issues/263 - - if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv: - subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True) - - # OS-specific components during CI builds - if is_CI_build: - if sys.platform.startswith("linux") and not build_headless: - cmake_args.append("-DWITH_QT=4") - - if sys.platform == "darwin" and not build_headless: - if "bdist_wheel" in sys.argv: - cmake_args.append("-DWITH_QT=5") - rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [ - (r"lib/qt/plugins/platforms/libqcocoa\.dylib") - ] - subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True) - - if sys.platform.startswith("linux"): - cmake_args.append("-DWITH_V4L=ON") - cmake_args.append("-DWITH_LAPACK=ON") - cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF") - - # https://github.com/scikit-build/scikit-build/issues/479 - if "CMAKE_ARGS" in os.environ: - import shlex - - cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"])) - del shlex - - # works via side effect - RearrangeCMakeOutput( - rearrange_cmake_output_data, files_outside_package_dir, package_data.keys() - ) - - skbuild.setup( - name=package_name, - version=package_version, - url="https://github.com/skvark/opencv-python", - license="MIT", - description="Wrapper package for OpenCV python bindings.", - long_description=long_description, - long_description_content_type="text/markdown", - packages=packages, - package_data=package_data, - maintainer="Olli-Pekka Heinisuo", - ext_modules=EmptyListWithLength(), - install_requires=numpy_version, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: C++", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Image Recognition", - "Topic :: Software Development", - ], - cmake_args=cmake_args, - cmake_source_dir=cmake_source_dir, - ) - - -class RearrangeCMakeOutput(object): - """ - Patch SKBuild logic to only take files related to the Python package - and construct a file hierarchy that SKBuild expects (see below) - """ - - _setuptools_wrap = None - - # Have to wrap a function reference, or it's converted - # into an instance method on attr assignment - import argparse - - wraps = argparse.Namespace(_classify_installed_files=None) - del argparse - - package_paths_re = None - packages = None - files_outside_package = None - - def __init__(self, package_paths_re, files_outside_package, packages): - cls = self.__class__ - assert not cls.wraps._classify_installed_files, "Singleton object" - import skbuild.setuptools_wrap - - cls._setuptools_wrap = skbuild.setuptools_wrap - cls.wraps._classify_installed_files = ( - cls._setuptools_wrap._classify_installed_files - ) - cls._setuptools_wrap._classify_installed_files = ( - self._classify_installed_files_override - ) - - cls.package_paths_re = package_paths_re - cls.files_outside_package = files_outside_package - cls.packages = packages - - def __del__(self): - cls = self.__class__ - cls._setuptools_wrap._classify_installed_files = ( - cls.wraps._classify_installed_files - ) - cls.wraps._classify_installed_files = None - cls._setuptools_wrap = None - - def _classify_installed_files_override( - self, - install_paths, - package_data, - package_prefixes, - py_modules, - new_py_modules, - scripts, - new_scripts, - data_files, - cmake_source_dir, - cmake_install_reldir, - ): - """ - From all CMake output, we're only interested in a few files - and must place them into CMake install dir according - to Python conventions for SKBuild to find them: - package\ - file - subpackage\ - etc. - """ - - cls = self.__class__ - - # 'relpath'/'reldir' = relative to CMAKE_INSTALL_DIR/cmake_install_dir - # 'path'/'dir' = relative to sourcetree root - cmake_install_dir = os.path.join( - cls._setuptools_wrap.CMAKE_INSTALL_DIR(), cmake_install_reldir - ) - install_relpaths = [ - os.path.relpath(p, cmake_install_dir) for p in install_paths - ] - fslash_install_relpaths = [ - p.replace(os.path.sep, "/") for p in install_relpaths - ] - relpaths_zip = list(zip(fslash_install_relpaths, install_relpaths)) - del install_relpaths, fslash_install_relpaths - - final_install_relpaths = [] - - print("Copying files from CMake output") - - for package_name, relpaths_re in cls.package_paths_re.items(): - package_dest_reldir = package_name.replace(".", os.path.sep) - for relpath_re in relpaths_re: - found = False - r = re.compile(relpath_re + "$") - for fslash_relpath, relpath in relpaths_zip: - m = r.match(fslash_relpath) - if not m: - continue - found = True - new_install_relpath = os.path.join( - package_dest_reldir, os.path.basename(relpath) - ) - cls._setuptools_wrap._copy_file( - os.path.join(cmake_install_dir, relpath), - os.path.join(cmake_install_dir, new_install_relpath), - hide_listing=False, - ) - final_install_relpaths.append(new_install_relpath) - del m, fslash_relpath, new_install_relpath - else: - if not found: - raise Exception("Not found: '%s'" % relpath_re) - del r, found - - del relpaths_zip - - print("Copying files from non-default sourcetree locations") - - for package_name, paths in cls.files_outside_package.items(): - package_dest_reldir = package_name.replace(".", os.path.sep) - for path in paths: - new_install_relpath = os.path.join( - package_dest_reldir, - # Don't yet have a need to copy - # to subdirectories of package dir - os.path.basename(path), - ) - cls._setuptools_wrap._copy_file( - path, - os.path.join(cmake_install_dir, new_install_relpath), - hide_listing=False, - ) - final_install_relpaths.append(new_install_relpath) - - final_install_paths = [ - os.path.join(cmake_install_dir, p) for p in final_install_relpaths - ] - - return (cls.wraps._classify_installed_files)( - final_install_paths, - package_data, - package_prefixes, - py_modules, - new_py_modules, - scripts, - new_scripts, - data_files, - # To get around a check that prepends source dir to paths and breaks package detection code. - cmake_source_dir="", - cmake_install_dir=cmake_install_reldir, - ) - - -def get_and_set_info(contrib, headless, ci_build): - # cv2/version.py should be generated by running find_version.py - version = {} - here = os.path.abspath(os.path.dirname(__file__)) - version_file = os.path.join(here, "cv2", "version.py") - - # generate a fresh version.py always when Git repository exists - # (in sdists the version.py file already exists) - if os.path.exists(".git"): - old_args = sys.argv.copy() - sys.argv = ["", str(contrib), str(headless), str(ci_build)] - runpy.run_path("find_version.py", run_name="__main__") - sys.argv = old_args - - with open(version_file) as fp: - exec(fp.read(), version) - - return version["opencv_version"], version["contrib"], version["headless"] - - -def get_build_env_var_by_name(flag_name): - flag_set = False - - try: - flag_set = bool(int(os.getenv("ENABLE_" + flag_name.upper(), None))) - except Exception: - pass - - if not flag_set: - try: - flag_set = bool(int(open(flag_name + ".enabled").read(1))) - except Exception: - pass - - return flag_set - - -# This creates a list which is empty but returns a length of 1. -# Should make the wheel a binary distribution and platlib compliant. -class EmptyListWithLength(list): - def __len__(self): - return 1 - - -if __name__ == "__main__": - main() +import io +import os +import os.path +import sys +import runpy +import subprocess +import re +import sysconfig +import platform +import skbuild +from skbuild import cmaker + + +def main(): + os.chdir(os.path.dirname(os.path.abspath(__file__))) + + CI_BUILD = os.environ.get("CI_BUILD", "False") + is_CI_build = True if CI_BUILD == "1" else False + cmake_source_dir = "opencv" + minimum_supported_numpy = "1.13.3" + build_contrib = get_build_env_var_by_name("contrib") + build_headless = get_build_env_var_by_name("headless") + build_java = "ON" if get_build_env_var_by_name("java") else "OFF" + + if sys.version_info[:2] >= (3, 6): + minimum_supported_numpy = "1.13.3" + if sys.version_info[:2] >= (3, 7): + minimum_supported_numpy = "1.14.5" + if sys.version_info[:2] >= (3, 8): + minimum_supported_numpy = "1.17.3" + if sys.version_info[:2] >= (3, 9): + minimum_supported_numpy = "1.19.3" + + # arm64 is a special case + if sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64": + minimum_supported_numpy = "1.19.3" + + numpy_version = "numpy>=%s" % minimum_supported_numpy + + python_version = cmaker.CMaker.get_python_version() + python_lib_path = cmaker.CMaker.get_python_library(python_version).replace( + "\\", "/" + ) + python_include_dir = cmaker.CMaker.get_python_include_dir(python_version).replace( + "\\", "/" + ) + + if os.path.exists(".git"): + import pip._internal.vcs.git as git + + g = git.Git() # NOTE: pip API's are internal, this has to be refactored + + g.run_command(["submodule", "sync"]) + g.run_command( + ["submodule", "update", "--init", "--recursive", cmake_source_dir] + ) + + if build_contrib: + g.run_command( + ["submodule", "update", "--init", "--recursive", "opencv_contrib"] + ) + + package_version, build_contrib, build_headless = get_and_set_info( + build_contrib, build_headless, is_CI_build + ) + + # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode + x64 = sys.maxsize > 2 ** 32 + + package_name = "opencv-python" + + if build_contrib and not build_headless: + package_name = "opencv-contrib-python" + + if build_contrib and build_headless: + package_name = "opencv-contrib-python-headless" + + if build_headless and not build_contrib: + package_name = "opencv-python-headless" + + long_description = io.open("README.md", encoding="utf-8").read() + + packages = ["cv2", "cv2.data"] + + package_data = { + "cv2": ["*%s" % sysconfig.get_config_vars().get("SO"), "version.py"] + + (["*.dll"] if os.name == "nt" else []) + + ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"], + "cv2.data": ["*.xml"], + } + + # Files from CMake output to copy to package. + # Path regexes with forward slashes relative to CMake install dir. + rearrange_cmake_output_data = { + "cv2": ( + [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if x64 else "")] + if os.name == "nt" + else [] + ) + + + # In Windows, in python/X.Y//; in Linux, in just python/X.Y/. + # Naming conventions vary so widely between versions and OSes + # had to give up on checking them. + [ + "python/cv2[^/]*%(ext)s" + % {"ext": re.escape(sysconfig.get_config_var("EXT_SUFFIX"))} + ], + "cv2.data": [ # OPENCV_OTHER_INSTALL_PATH + ("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml" + ], + } + + # Files in sourcetree outside package dir that should be copied to package. + # Raw paths relative to sourcetree root. + files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]} + + ci_cmake_generator = ( + ["-G", "Visual Studio 14" + (" Win64" if x64 else "")] + if os.name == "nt" + else ["-G", "Unix Makefiles"] + ) + + cmake_args = ( + (ci_cmake_generator if is_CI_build else []) + + [ + # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3 + "-DPYTHON3_EXECUTABLE=%s" % sys.executable, + "-DPYTHON3_INCLUDE_DIR=%s" % python_include_dir, + "-DPYTHON3_LIBRARY=%s" % python_lib_path, + "-DBUILD_opencv_python3=ON", + "-DBUILD_opencv_python2=OFF", + # Disable the Java build by default as it is not needed + "-DBUILD_opencv_java=%s" % build_java, + # When off, adds __init__.py and a few more helper .py's. We use our own helper files with a different structure. + "-DOPENCV_SKIP_PYTHON_LOADER=ON", + # Relative dir to install the built module to in the build tree. + # The default is generated from sysconfig, we'd rather have a constant for simplicity + "-DOPENCV_PYTHON3_INSTALL_PATH=python", + # Otherwise, opencv scripts would want to install `.pyd' right into site-packages, + # and skbuild bails out on seeing that + "-DINSTALL_CREATE_DISTRIB=ON", + # See opencv/CMakeLists.txt for options and defaults + "-DBUILD_opencv_apps=OFF", + "-DBUILD_SHARED_LIBS=OFF", + "-DBUILD_TESTS=OFF", + "-DBUILD_PERF_TESTS=OFF", + "-DBUILD_DOCS=OFF", + ] + + ( + ["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] + if build_contrib + else [] + ) + ) + + if build_headless: + # it seems that cocoa cannot be disabled so on macOS the package is not truly headless + cmake_args.append("-DWITH_WIN32UI=OFF") + cmake_args.append("-DWITH_QT=OFF") + cmake_args.append("-DWITH_GTK=OFF") + if is_CI_build: + cmake_args.append( + "-DWITH_MSMF=OFF" + ) # see: https://github.com/skvark/opencv-python/issues/263 + + if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv: + subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True) + + # OS-specific components during CI builds + if is_CI_build: + + if ( + not build_headless + and "bdist_wheel" in sys.argv + and (sys.platform == "darwin" or sys.platform.startswith("linux")) + ): + cmake_args.append("-DWITH_QT=5") + subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True) + + if sys.platform.startswith("linux"): + rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [ + (r"lib/qt/plugins/platforms/libqxcb\.so") + ] + + # add fonts for Qt5 + fonts = [] + for file in os.listdir("/usr/share/fonts/dejavu"): + if file.endswith(".ttf"): + fonts.append( + (r"lib/qt/fonts/dejavu/%s\.ttf" % file.split(".")[0]) + ) + + rearrange_cmake_output_data["cv2.qt.fonts"] = fonts + + if sys.platform == "darwin": + rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [ + (r"lib/qt/plugins/platforms/libqcocoa\.dylib") + ] + + if sys.platform.startswith("linux"): + cmake_args.append("-DWITH_V4L=ON") + cmake_args.append("-DWITH_LAPACK=ON") + cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF") + + # https://github.com/scikit-build/scikit-build/issues/479 + if "CMAKE_ARGS" in os.environ: + import shlex + + cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"])) + del shlex + + # works via side effect + RearrangeCMakeOutput( + rearrange_cmake_output_data, files_outside_package_dir, package_data.keys() + ) + + skbuild.setup( + name=package_name, + version=package_version, + url="https://github.com/skvark/opencv-python", + license="MIT", + description="Wrapper package for OpenCV python bindings.", + long_description=long_description, + long_description_content_type="text/markdown", + packages=packages, + package_data=package_data, + maintainer="Olli-Pekka Heinisuo", + ext_modules=EmptyListWithLength(), + install_requires=numpy_version, + python_requires=">=3.6", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: C++", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Image Recognition", + "Topic :: Software Development", + ], + cmake_args=cmake_args, + cmake_source_dir=cmake_source_dir, + ) + + +class RearrangeCMakeOutput(object): + """ + Patch SKBuild logic to only take files related to the Python package + and construct a file hierarchy that SKBuild expects (see below) + """ + + _setuptools_wrap = None + + # Have to wrap a function reference, or it's converted + # into an instance method on attr assignment + import argparse + + wraps = argparse.Namespace(_classify_installed_files=None) + del argparse + + package_paths_re = None + packages = None + files_outside_package = None + + def __init__(self, package_paths_re, files_outside_package, packages): + cls = self.__class__ + assert not cls.wraps._classify_installed_files, "Singleton object" + import skbuild.setuptools_wrap + + cls._setuptools_wrap = skbuild.setuptools_wrap + cls.wraps._classify_installed_files = ( + cls._setuptools_wrap._classify_installed_files + ) + cls._setuptools_wrap._classify_installed_files = ( + self._classify_installed_files_override + ) + + cls.package_paths_re = package_paths_re + cls.files_outside_package = files_outside_package + cls.packages = packages + + def __del__(self): + cls = self.__class__ + cls._setuptools_wrap._classify_installed_files = ( + cls.wraps._classify_installed_files + ) + cls.wraps._classify_installed_files = None + cls._setuptools_wrap = None + + def _classify_installed_files_override( + self, + install_paths, + package_data, + package_prefixes, + py_modules, + new_py_modules, + scripts, + new_scripts, + data_files, + cmake_source_dir, + cmake_install_reldir, + ): + """ + From all CMake output, we're only interested in a few files + and must place them into CMake install dir according + to Python conventions for SKBuild to find them: + package\ + file + subpackage\ + etc. + """ + + cls = self.__class__ + + # 'relpath'/'reldir' = relative to CMAKE_INSTALL_DIR/cmake_install_dir + # 'path'/'dir' = relative to sourcetree root + cmake_install_dir = os.path.join( + cls._setuptools_wrap.CMAKE_INSTALL_DIR(), cmake_install_reldir + ) + install_relpaths = [ + os.path.relpath(p, cmake_install_dir) for p in install_paths + ] + fslash_install_relpaths = [ + p.replace(os.path.sep, "/") for p in install_relpaths + ] + relpaths_zip = list(zip(fslash_install_relpaths, install_relpaths)) + del install_relpaths, fslash_install_relpaths + + final_install_relpaths = [] + + print("Copying files from CMake output") + + for package_name, relpaths_re in cls.package_paths_re.items(): + package_dest_reldir = package_name.replace(".", os.path.sep) + for relpath_re in relpaths_re: + found = False + r = re.compile(relpath_re + "$") + for fslash_relpath, relpath in relpaths_zip: + m = r.match(fslash_relpath) + if not m: + continue + found = True + new_install_relpath = os.path.join( + package_dest_reldir, os.path.basename(relpath) + ) + cls._setuptools_wrap._copy_file( + os.path.join(cmake_install_dir, relpath), + os.path.join(cmake_install_dir, new_install_relpath), + hide_listing=False, + ) + final_install_relpaths.append(new_install_relpath) + del m, fslash_relpath, new_install_relpath + else: + if not found: + raise Exception("Not found: '%s'" % relpath_re) + del r, found + + del relpaths_zip + + print("Copying files from non-default sourcetree locations") + + for package_name, paths in cls.files_outside_package.items(): + package_dest_reldir = package_name.replace(".", os.path.sep) + for path in paths: + new_install_relpath = os.path.join( + package_dest_reldir, + # Don't yet have a need to copy + # to subdirectories of package dir + os.path.basename(path), + ) + cls._setuptools_wrap._copy_file( + path, + os.path.join(cmake_install_dir, new_install_relpath), + hide_listing=False, + ) + final_install_relpaths.append(new_install_relpath) + + final_install_paths = [ + os.path.join(cmake_install_dir, p) for p in final_install_relpaths + ] + + return (cls.wraps._classify_installed_files)( + final_install_paths, + package_data, + package_prefixes, + py_modules, + new_py_modules, + scripts, + new_scripts, + data_files, + # To get around a check that prepends source dir to paths and breaks package detection code. + cmake_source_dir="", + cmake_install_dir=cmake_install_reldir, + ) + + +def get_and_set_info(contrib, headless, ci_build): + # cv2/version.py should be generated by running find_version.py + version = {} + here = os.path.abspath(os.path.dirname(__file__)) + version_file = os.path.join(here, "cv2", "version.py") + + # generate a fresh version.py always when Git repository exists + # (in sdists the version.py file already exists) + if os.path.exists(".git"): + old_args = sys.argv.copy() + sys.argv = ["", str(contrib), str(headless), str(ci_build)] + runpy.run_path("find_version.py", run_name="__main__") + sys.argv = old_args + + with open(version_file) as fp: + exec(fp.read(), version) + + return version["opencv_version"], version["contrib"], version["headless"] + + +def get_build_env_var_by_name(flag_name): + flag_set = False + + try: + flag_set = bool(int(os.getenv("ENABLE_" + flag_name.upper(), None))) + except Exception: + pass + + if not flag_set: + try: + flag_set = bool(int(open(flag_name + ".enabled").read(1))) + except Exception: + pass + + return flag_set + + +# This creates a list which is empty but returns a length of 1. +# Should make the wheel a binary distribution and platlib compliant. +class EmptyListWithLength(list): + def __len__(self): + return 1 + + +if __name__ == "__main__": + main() diff --git a/tests/test.py b/tests/test.py index e520814f..6411ff39 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,16 +1,17 @@ -import unittest -import sys - - -class OpenCVTest(unittest.TestCase): - """ Simple functionality tests. """ - - def test_import(self): - """ Test that the cv2 module can be imported. """ - import cv2 - - def test_video_capture(self): - - import cv2 - cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4") - self.assertTrue(cap.isOpened()) +import unittest +import sys + + +class OpenCVTest(unittest.TestCase): + """ Simple functionality tests. """ + + def test_import(self): + """ Test that the cv2 module can be imported. """ + import cv2 + + def test_video_capture(self): + + import cv2 + + cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4") + self.assertTrue(cap.isOpened()) diff --git a/travis_config.sh b/travis_config.sh index 9e114b46..910e365f 100644 --- a/travis_config.sh +++ b/travis_config.sh @@ -14,8 +14,15 @@ function bdist_wheel_cmd { # copied from multibuild's common_utils.sh # add osx deployment target so it doesnt default to 10.6 local abs_wheelhouse=$1 - CI_BUILD=1 pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS + CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS cp dist/*.whl $abs_wheelhouse + if [ -z "$IS_OSX" ]; then + TOOLS_PATH=/opt/_internal/tools + /opt/python/cp37-cp37m/bin/python -m venv $TOOLS_PATH + source $TOOLS_PATH/bin/activate + python patch_auditwheel_whitelist.py + deactivate + fi if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi } @@ -24,6 +31,7 @@ if [ -n "$IS_OSX" ]; then export MAKEFLAGS="-j$(sysctl -n hw.ncpu)" else echo " > Linux environment " + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.15.0/lib export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)" fi @@ -88,7 +96,8 @@ function pre_build { echo "Running for OSX" local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1 - export USER=travis + export HOMEBREW_NO_AUTO_UPDATE=1 + #after the cache stage, all bottles and Homebrew metadata should be already cached locally if [ -n "$CACHE_STAGE" ]; then brew update @@ -96,21 +105,23 @@ function pre_build { brew_add_local_bottles fi - echo 'Installing qt5' - if [ -n "$CACHE_STAGE" ]; then - brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; } - else - brew install qt5 - export PATH="/usr/local/opt/qt/bin:$PATH" - fi - echo 'Installing FFmpeg' if [ -n "$CACHE_STAGE" ]; then brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; } else brew unlink python@2 - brew install -vd ffmpeg_opencv + brew install ffmpeg_opencv + fi + + echo 'Installing qt5' + + if [ -n "$CACHE_STAGE" ]; then + echo "Qt5 has bottle, no caching needed" + else + brew switch qt 5.13.2 + brew pin qt + export PATH="/usr/local/opt/qt/bin:$PATH" fi if [ -n "$CACHE_STAGE" ]; then