From 091603176ecb979090f10f1f91883710c0c4bb3a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 5 Sep 2019 17:32:51 +0300
Subject: [PATCH 001/345] opencv 3.4.6

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index 8f1356c3..33b765d7 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 8f1356c3c5b16721349582db461a2051653059e8
+Subproject commit 33b765d7979fd8a6038026aa44f6ff1a9c082b7b
diff --git a/opencv_contrib b/opencv_contrib
index 7292df62..f26c9836 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 7292df62624ded8af8035231435dfd17c93e1a80
+Subproject commit f26c98365da6af93cb5e49397b571190fca7bb55

From 3c8cf39d6cf44aca31220ced65f76778a20fae54 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 8 Jan 2019 19:12:16 +0200
Subject: [PATCH 002/345] try to disable __STRICT_ANSI__ on 32-bit linux

---
 setup.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/setup.py b/setup.py
index 423a0ef2..4f484bef 100644
--- a/setup.py
+++ b/setup.py
@@ -146,6 +146,8 @@ def main():
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with
                                               # devtoolset-2 GCC 4.8.2 or vanilla GCC 4.9.4
                                               # see https://github.com/skvark/opencv-python/issues/138
+    if sys.platform.startswith('linux') and not x64:
+        cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
 
     # ABI config variables are introduced in PEP 425
     if sys.version_info[:2] < (3, 2):

From 29ddb368d4fb8b9178f8b7079b5f7bcc844713b4 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 25 Jan 2019 20:17:50 +0200
Subject: [PATCH 003/345] ignore py2.7 deprecation warning

---
 appveyor.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/appveyor.yml b/appveyor.yml
index 19645421..3e755db9 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -179,6 +179,7 @@ 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 (ls "../dist/opencv_*.whl")
     if ($LastExitCode -ne 0) {throw $LastExitCode}
 

From 22efb62f8f5d99cec05b94b62f4bd0ed2e9a3724 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 26 Jan 2019 13:28:17 +0200
Subject: [PATCH 004/345] update travis xcode 8 to 8.3

---
 .travis.yml | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a6fb537d..7e775d04 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,7 +33,7 @@ cache:
     - $HOME/local_bottle_metadata
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
-    
+
 matrix:
   fast_finish: true
   include:
@@ -41,7 +41,7 @@ matrix:
     # default builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -49,7 +49,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
@@ -57,7 +57,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -65,7 +65,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -73,7 +73,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -84,7 +84,7 @@ matrix:
     # headless builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -92,7 +92,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
@@ -100,7 +100,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -108,7 +108,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -116,7 +116,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -127,7 +127,7 @@ matrix:
     # Contrib builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -135,7 +135,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
@@ -143,7 +143,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -151,7 +151,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -159,7 +159,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -170,7 +170,7 @@ matrix:
     # headless contrib builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -178,7 +178,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
@@ -186,7 +186,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -194,7 +194,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -202,7 +202,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -618,7 +618,7 @@ before_install: |
     source multibuild_customize.sh
     echo $ENABLE_CONTRIB > contrib.enabled
     echo $ENABLE_HEADLESS > headless.enabled
-    
+
     if [ -n "$IS_OSX" ]; then
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
@@ -629,10 +629,10 @@ before_install: |
                     cd $(dirname '\''{}'\'')
                     git clean -fxd
                     git status' \;
-                    
+
         brew_cache_cleanup
     fi
-    
+
     before_install
     # Not interested in travis internal scripts' output
     set +x
@@ -653,7 +653,7 @@ script: |
     #otherwise, Travis logic terminates prematurely
     #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
-    
+
     test "$rc" -eq 0
 
 before_cache: |
@@ -667,10 +667,10 @@ before_cache: |
         fi
 
         brew_cache_cleanup
-        
+
     fi
     set +x
-    
+
 after_success: |
     # Upload wheels to pypi if requested
     if [ -n "$TRAVIS_TAG" ]; then

From 52ab1f004aa0e3ef3017908039b23773df91f00d Mon Sep 17 00:00:00 2001
From: Christian Vallentin <vallentinsource@gmail.com>
Date: Thu, 31 Jan 2019 15:33:41 +0100
Subject: [PATCH 005/345] Fixed typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 0264fa43..32e5687b 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
 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:
 
-    There are four different packages and you should **select only one of them**. Do not install multiple different packages in the same enviroment. 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 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)
 

From 27c23744185c6b95217ae64aba874d77743c4a0b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 17 Feb 2019 21:51:31 +0200
Subject: [PATCH 006/345] Revert "update travis xcode 8 to 8.3"

This reverts commit 5288ba5fa2603975d1ee36544b11c2a45b7adc1e.
---
 .travis.yml | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7e775d04..a6fb537d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,7 +33,7 @@ cache:
     - $HOME/local_bottle_metadata
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
-
+    
 matrix:
   fast_finish: true
   include:
@@ -41,7 +41,7 @@ matrix:
     # default builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -49,7 +49,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
@@ -57,7 +57,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -65,7 +65,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -73,7 +73,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -84,7 +84,7 @@ matrix:
     # headless builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -92,7 +92,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
@@ -100,7 +100,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -108,7 +108,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -116,7 +116,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -127,7 +127,7 @@ matrix:
     # Contrib builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -135,7 +135,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
@@ -143,7 +143,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -151,7 +151,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -159,7 +159,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -170,7 +170,7 @@ matrix:
     # headless contrib builds for MacOS
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -178,7 +178,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
@@ -186,7 +186,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -194,7 +194,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -202,7 +202,7 @@ matrix:
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       language: generic
-      osx_image: xcode8.3
+      osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -618,7 +618,7 @@ before_install: |
     source multibuild_customize.sh
     echo $ENABLE_CONTRIB > contrib.enabled
     echo $ENABLE_HEADLESS > headless.enabled
-
+    
     if [ -n "$IS_OSX" ]; then
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
@@ -629,10 +629,10 @@ before_install: |
                     cd $(dirname '\''{}'\'')
                     git clean -fxd
                     git status' \;
-
+                    
         brew_cache_cleanup
     fi
-
+    
     before_install
     # Not interested in travis internal scripts' output
     set +x
@@ -653,7 +653,7 @@ script: |
     #otherwise, Travis logic terminates prematurely
     #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
-
+    
     test "$rc" -eq 0
 
 before_cache: |
@@ -667,10 +667,10 @@ before_cache: |
         fi
 
         brew_cache_cleanup
-
+        
     fi
     set +x
-
+    
 after_success: |
     # Upload wheels to pypi if requested
     if [ -n "$TRAVIS_TAG" ]; then

From 356a968aa95a6f6038e6af38504cfe51c525f708 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 17 Feb 2019 22:16:54 +0200
Subject: [PATCH 007/345] remove --merge

---
 config.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/config.sh b/config.sh
index 3bdacd2f..94eaf051 100644
--- a/config.sh
+++ b/config.sh
@@ -29,24 +29,24 @@ fi
 if [ -n "$IS_OSX" ]; then
 
     source travis_osx_brew_cache.sh
-    
+
     BREW_SLOW_BUILIDING_PACKAGES=$(printf '%s\n' \
         "x265 20"  \
         "cmake 15" \
         "ffmpeg_opencv 10" \
     )
-    
+
     #Contrib adds significantly to project's build time
     if [ "$ENABLE_CONTRIB" -eq 1 ]; then
         BREW_TIME_LIMIT=$((BREW_TIME_LIMIT - 10*60))
     fi
-    
+
     function generate_ffmpeg_formula {
         local FF="ffmpeg"
         local LFF="ffmpeg_opencv"
         local FF_FORMULA; FF_FORMULA=$(brew formula "$FF")
         local LFF_FORMULA; LFF_FORMULA="$(dirname "$FF_FORMULA")/${LFF}.rb"
-        
+
         local REGENERATE
         if [ -f "$LFF_FORMULA" ]; then
             local UPSTREAM_VERSION VERSION
@@ -82,7 +82,7 @@ if (/^\s*depends_on "(x264|x265|xvid)"$/) {$_=""; next;}
             )
         fi
     }
-        
+
 fi
 
 function pre_build {
@@ -91,8 +91,8 @@ function pre_build {
 
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
-    
-    brew update --merge
+
+    brew update
     brew_add_local_bottles
 
     # Don't query analytical info online on `brew info`,

From 10be7e56c0712bb3cc22e3d52766a3f4c1dca3ca Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 19 Feb 2019 19:33:17 +0200
Subject: [PATCH 008/345] Revert "remove --merge"

This reverts commit 0e788e25f4a205832dac6c09dccc9180acd29b73.
---
 config.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/config.sh b/config.sh
index 94eaf051..3bdacd2f 100644
--- a/config.sh
+++ b/config.sh
@@ -29,24 +29,24 @@ fi
 if [ -n "$IS_OSX" ]; then
 
     source travis_osx_brew_cache.sh
-
+    
     BREW_SLOW_BUILIDING_PACKAGES=$(printf '%s\n' \
         "x265 20"  \
         "cmake 15" \
         "ffmpeg_opencv 10" \
     )
-
+    
     #Contrib adds significantly to project's build time
     if [ "$ENABLE_CONTRIB" -eq 1 ]; then
         BREW_TIME_LIMIT=$((BREW_TIME_LIMIT - 10*60))
     fi
-
+    
     function generate_ffmpeg_formula {
         local FF="ffmpeg"
         local LFF="ffmpeg_opencv"
         local FF_FORMULA; FF_FORMULA=$(brew formula "$FF")
         local LFF_FORMULA; LFF_FORMULA="$(dirname "$FF_FORMULA")/${LFF}.rb"
-
+        
         local REGENERATE
         if [ -f "$LFF_FORMULA" ]; then
             local UPSTREAM_VERSION VERSION
@@ -82,7 +82,7 @@ if (/^\s*depends_on "(x264|x265|xvid)"$/) {$_=""; next;}
             )
         fi
     }
-
+        
 fi
 
 function pre_build {
@@ -91,8 +91,8 @@ function pre_build {
 
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
-
-    brew update
+    
+    brew update --merge
     brew_add_local_bottles
 
     # Don't query analytical info online on `brew info`,

From e78ecbddff746f59d15305469f70447ce910fdb3 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 19 Feb 2019 19:56:42 +0200
Subject: [PATCH 009/345] try --force

---
 config.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/config.sh b/config.sh
index 3bdacd2f..fee87537 100644
--- a/config.sh
+++ b/config.sh
@@ -29,24 +29,24 @@ fi
 if [ -n "$IS_OSX" ]; then
 
     source travis_osx_brew_cache.sh
-    
+
     BREW_SLOW_BUILIDING_PACKAGES=$(printf '%s\n' \
         "x265 20"  \
         "cmake 15" \
         "ffmpeg_opencv 10" \
     )
-    
+
     #Contrib adds significantly to project's build time
     if [ "$ENABLE_CONTRIB" -eq 1 ]; then
         BREW_TIME_LIMIT=$((BREW_TIME_LIMIT - 10*60))
     fi
-    
+
     function generate_ffmpeg_formula {
         local FF="ffmpeg"
         local LFF="ffmpeg_opencv"
         local FF_FORMULA; FF_FORMULA=$(brew formula "$FF")
         local LFF_FORMULA; LFF_FORMULA="$(dirname "$FF_FORMULA")/${LFF}.rb"
-        
+
         local REGENERATE
         if [ -f "$LFF_FORMULA" ]; then
             local UPSTREAM_VERSION VERSION
@@ -82,7 +82,7 @@ if (/^\s*depends_on "(x264|x265|xvid)"$/) {$_=""; next;}
             )
         fi
     }
-        
+
 fi
 
 function pre_build {
@@ -91,8 +91,8 @@ function pre_build {
 
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
-    
-    brew update --merge
+
+    brew update --force
     brew_add_local_bottles
 
     # Don't query analytical info online on `brew info`,

From c824854d72034a1863a49a72af73988c05cc5e4b Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 23 Mar 2019 20:53:41 +0300
Subject: [PATCH 010/345] Remove redundant language:generic

---
 .travis.yml | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a6fb537d..16b6025f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,7 +40,6 @@ matrix:
 
     # default builds for MacOS
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
@@ -48,7 +47,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
@@ -56,7 +54,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
@@ -64,7 +61,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
@@ -72,7 +68,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
@@ -83,7 +78,6 @@ matrix:
 
     # headless builds for MacOS
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
@@ -91,7 +85,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
@@ -99,7 +92,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
@@ -107,7 +99,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
@@ -115,7 +106,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
@@ -126,7 +116,6 @@ matrix:
 
     # Contrib builds for MacOS
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
@@ -134,7 +123,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
@@ -142,7 +130,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
@@ -150,7 +137,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
@@ -158,7 +144,6 @@ matrix:
         - ENABLE_HEADLESS=0
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
@@ -169,7 +154,6 @@ matrix:
 
     # headless contrib builds for MacOS
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=2.7
@@ -177,7 +161,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
@@ -185,7 +168,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
@@ -193,7 +175,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
@@ -201,7 +182,6 @@ matrix:
         - ENABLE_HEADLESS=1
         - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
-      language: generic
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7

From 008134fed4b9f778d8689763e42246c5de65f20b Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Fri, 22 Mar 2019 00:44:02 +0300
Subject: [PATCH 011/345] Move CMAKE_OSX_DEPLOYMENT_TARGET to setup.py

---
 .travis.yml | 20 --------------------
 setup.py    |  1 +
 2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 16b6025f..5945c9d5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,35 +45,30 @@ matrix:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
         - TEST_DEPENDS=numpy==1.14.5
 
     # headless builds for MacOS
@@ -83,35 +78,30 @@ matrix:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
         - TEST_DEPENDS=numpy==1.14.5
 
     # Contrib builds for MacOS
@@ -121,35 +111,30 @@ matrix:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
         - TEST_DEPENDS=numpy==1.14.5
 
     # headless contrib builds for MacOS
@@ -159,35 +144,30 @@ matrix:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
     - os: osx
       osx_image: xcode8
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
         - TEST_DEPENDS=numpy==1.14.5
 
     # default builds for Linux
diff --git a/setup.py b/setup.py
index 4f484bef..108cdc43 100644
--- a/setup.py
+++ b/setup.py
@@ -141,6 +141,7 @@ def main():
         cmake_args.append("-DWITH_LAPACK=OFF")  # Some OSX LAPACK fns are incompatible, see
                                                 # https://github.com/skvark/opencv-python/issues/21
         cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
+        cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7")
 
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with

From 059fea0437e12e6673523b9cc352dd012a4f526f Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Fri, 22 Mar 2019 01:16:35 +0300
Subject: [PATCH 012/345] * No need for both OPENCV_PYTHON{2,3}_INSTALL_PATH in
 cmake args * Add explanation to more obscure cmake args

---
 setup.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 108cdc43..fa70f5a3 100644
--- a/setup.py
+++ b/setup.py
@@ -102,12 +102,16 @@ def main():
         # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
         "-DPYTHON%d_EXECUTABLE=%s" % (sys.version_info[0], sys.executable),
         "-DBUILD_opencv_python%d=ON" % sys.version_info[0],
+        
+        # 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",
-        "-DOPENCV_PYTHON2_INSTALL_PATH=python",
-        "-DOPENCV_PYTHON3_INSTALL_PATH=python",
+        # 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_PYTHON%d_INSTALL_PATH=python" % sys.version_info[0],
         # 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",

From 1b6fa44f5d305e7b71d114841cfcc09647030047 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 21 Mar 2019 16:43:05 +0300
Subject: [PATCH 013/345] Upgrade to Xcode 8.3

---
 .travis.yml | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5945c9d5..e7e9a5f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,38 +33,38 @@ cache:
     - $HOME/local_bottle_metadata
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
-    
+
 matrix:
   fast_finish: true
   include:
 
     # default builds for MacOS
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -73,31 +73,31 @@ matrix:
 
     # headless builds for MacOS
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -106,31 +106,31 @@ matrix:
 
     # Contrib builds for MacOS
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -139,31 +139,31 @@ matrix:
 
     # headless contrib builds for MacOS
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
     - os: osx
-      osx_image: xcode8
+      osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -578,7 +578,7 @@ before_install: |
     source multibuild_customize.sh
     echo $ENABLE_CONTRIB > contrib.enabled
     echo $ENABLE_HEADLESS > headless.enabled
-    
+
     if [ -n "$IS_OSX" ]; then
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
@@ -589,10 +589,10 @@ before_install: |
                     cd $(dirname '\''{}'\'')
                     git clean -fxd
                     git status' \;
-                    
+
         brew_cache_cleanup
     fi
-    
+
     before_install
     # Not interested in travis internal scripts' output
     set +x
@@ -613,7 +613,7 @@ script: |
     #otherwise, Travis logic terminates prematurely
     #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
-    
+
     test "$rc" -eq 0
 
 before_cache: |
@@ -627,10 +627,10 @@ before_cache: |
         fi
 
         brew_cache_cleanup
-        
+
     fi
     set +x
-    
+
 after_success: |
     # Upload wheels to pypi if requested
     if [ -n "$TRAVIS_TAG" ]; then

From 10c7cfa6fb470b258b0b229bcba03a7824cdcf3b Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Tue, 19 Mar 2019 15:41:56 +0300
Subject: [PATCH 014/345] Diagnostics for a `find -exec git clean` failure

---
 .travis.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index e7e9a5f0..130df767 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -586,9 +586,10 @@ before_install: |
         fi
         find "$TAPS" -type d -name .git -exec \
                 bash -xec '
-                    cd $(dirname '\''{}'\'')
-                    git clean -fxd
-                    git status' \;
+                    cd $(dirname '\''{}'\'') || echo "status: $?"
+                    git clean -fxd || echo "status: $?"
+                    sleep 1 || echo "status: $?"
+                    git status || echo "status: $?"' \; || echo "status: $?"
 
         brew_cache_cleanup
     fi

From e7a5b665c4af2ec0ba4bf801d890bce04bb43fc1 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Tue, 19 Mar 2019 12:51:03 +0300
Subject: [PATCH 015/345] Fix/improve travis_osx_brew_cache & caching logic

* fix built bottle & metadata cleanup when bottle is missing
* -e mode for before_cache step
* faster finish when already the latest version
---
 .travis.yml              |  4 ++--
 travis_osx_brew_cache.sh | 15 +++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 130df767..8772517e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -619,7 +619,7 @@ script: |
 
 before_cache: |
     # Cleanup dirs to be cached
-    set -x
+    set -e; set -x
     if [ -n "$IS_OSX" ]; then
 
         # When Taps is cached, this dir causes "Error: file exists" on `brew update`
@@ -630,7 +630,7 @@ before_cache: |
         brew_cache_cleanup
 
     fi
-    set +x
+    set +x; set +e
 
 after_success: |
     # Upload wheels to pypi if requested
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 47d37326..8d2401b2 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -41,6 +41,12 @@ function brew_install_and_cache_within_time_limit {
 
     local BUILD_FROM_SOURCE INCLUDE_BUILD
     
+    if brew list --versions "$PACKAGE" && ! (brew outdated | grep -qx "$PACKAGE"); then
+        echo "Already installed and the latest version: $PACKAGE"
+        return 0
+    fi
+
+    
     _brew_is_bottle_available "$PACKAGE" || BUILD_FROM_SOURCE=1
     [ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
 
@@ -152,7 +158,7 @@ function brew_add_local_bottles {
                 )
             fi
             
-            if [ -n "$BOTTLE" ]; then rm "$BOTTLE"; fi
+            if [ -n "$BOTTLE" -a -n "$BOTTLE_EXISTS" ]; then rm "$BOTTLE"; fi
             rm -f "$BOTTLE_LINK"
             rm "$JSON"
             
@@ -295,17 +301,14 @@ function _brew_is_bottle_available {
 
 function _brew_install_and_cache {
     # Install bottle or make and cache bottle.
-    # assumes that deps were already installed.
+    # assumes that deps were already installed
+    # and not already the latest version
     
     local PACKAGE;PACKAGE="${1:?}"
     local USE_BOTTLE;USE_BOTTLE="${2:?}"
     local VERB
     
     if brew list --versions "$PACKAGE"; then
-        if ! (brew outdated | grep -qx "$PACKAGE"); then
-            echo "Already the latest version: $PACKAGE"
-            return 0
-        fi
         VERB=upgrade
     else
         VERB=install

From 5916c66207a8eb50d074f70793aa509e0e7bda07 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Tue, 19 Mar 2019 13:10:38 +0300
Subject: [PATCH 016/345] Update caching logic to support new Homebrew in OSX
 10.12

* disable auto `brew cleanup`
* support formulae with disabled bottles
* install alongside to avoid "runtime dependents" update
  https://discourse.brew.sh/t/can-i-install-a-new-version-without-having-to-upgrade-runtime-dependents/4443
---
 config.sh                |  4 +--
 travis_osx_brew_cache.sh | 59 ++++++++++++++++++++++++++++------------
 2 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/config.sh b/config.sh
index fee87537..ead68645 100644
--- a/config.sh
+++ b/config.sh
@@ -92,14 +92,14 @@ function pre_build {
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
 
-    brew update --force
+    brew update
     brew_add_local_bottles
 
     # Don't query analytical info online on `brew info`,
     #  this takes several seconds and we don't need it
     # see https://docs.brew.sh/Manpage , "info formula" section
     export HOMEBREW_NO_GITHUB_API=1
-
+    
     echo 'Installing QT4'
     brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
     brew tap --list-pinned | grep -qxF cartr/qt4 || brew tap-pin cartr/qt4
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 8d2401b2..c62a6235 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -24,6 +24,11 @@ BREW_TIME_LIMIT=$((30*60))
 BREW_TIME_HARD_LIMIT=$((40*60))
 
 
+# Auto cleanup can delete locally-built bottles
+# when the caching logic isn't prepared for that
+export HOMEBREW_NO_INSTALL_CLEANUP=1
+
+
 
 #Public functions
 
@@ -34,12 +39,12 @@ function brew_install_and_cache_within_time_limit {
     # Exit with status 2 on any other error.
     ( eval "$_BREW_ERREXIT"
     
-    local PACKAGE; PACKAGE="${1:?}" || return 2
-    local TIME_LIMIT;TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || return 2
-    local TIME_HARD_LIMIT;TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || return 2
-    local TIME_START;TIME_START=${4:-$BREW_TIME_START} || return 2
+    local PACKAGE; PACKAGE="${1:?}" || exit 2
+    local TIME_LIMIT;TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || exit 2
+    local TIME_HARD_LIMIT;TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || exit 2
+    local TIME_START;TIME_START=${4:-$BREW_TIME_START} || exit 2
 
-    local BUILD_FROM_SOURCE INCLUDE_BUILD
+    local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
     
     if brew list --versions "$PACKAGE" && ! (brew outdated | grep -qx "$PACKAGE"); then
         echo "Already installed and the latest version: $PACKAGE"
@@ -47,21 +52,21 @@ function brew_install_and_cache_within_time_limit {
     fi
 
     
-    _brew_is_bottle_available "$PACKAGE" || BUILD_FROM_SOURCE=1
+    _brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
     [ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
 
     # Whitespace is illegal in package names so converting all whitespace into single spaces due to no quotes is okay.
-    DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || return 2
+    DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || exit 2
     for dep in $DEPS; do
         #TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
         #While we don't know that yet, we can make better use of Travis-given time with a laxer limit
         #We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
-        brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || return $?
+        brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || exit $?
     done
 
-    _brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || return $?
-    _brew_install_and_cache "$PACKAGE" "$([[ -z "$INCLUDE_BUILD" ]] && echo 1 || echo 0)" || return 2
-    _brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || return $?
+    _brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || exit $?
+    _brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || exit 2
+    _brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || exit $?
     ) \
     || if test $? -eq 1; then brew_go_bootstrap_mode; return 1; else return 2; fi      #must run this in current process
 }
@@ -288,8 +293,22 @@ function _brew_parse_package_info {
 function _brew_is_bottle_available {
 
     local PACKAGE;PACKAGE="${1:?}"
-    
-    local INFO="$(brew info "$PACKAGE" | head -n 1)"
+    local VAR_KEG_ONLY="$2"
+
+    local INFO;INFO="$(brew info "$PACKAGE" | head -n 1)"
+    if [ -n "$VAR_KEG_ONLY" ]; then
+        if grep -qwF '[keg-only]' <<<"$INFO"; then
+            eval "${VAR_KEG_ONLY}=1"
+        else
+            eval "${VAR_KEG_ONLY}=0"
+        fi
+    fi
+
+    if grep -qxEe '[[:space:]]*bottle :unneeded' $(brew formula "$PACKAGE"); then
+        echo "Bottle disabled: $PACKAGE"
+        return 0
+    fi
+
     if grep -qwF '(bottled)' <<<"$INFO"; then
         echo "Bottle available: $INFO"
         return 0
@@ -306,10 +325,16 @@ function _brew_install_and_cache {
     
     local PACKAGE;PACKAGE="${1:?}"
     local USE_BOTTLE;USE_BOTTLE="${2:?}"
+    local KEG_ONLY;KEG_ONLY="${3:?}"
     local VERB
     
-    if brew list --versions "$PACKAGE"; then
-        VERB=upgrade
+    if brew list --versions "$PACKAGE" >/dev/null; then
+        # Install alongside the old version to avoid to have to update "runtime dependents"
+        # https://discourse.brew.sh/t/can-i-install-a-new-version-without-having-to-upgrade-runtime-dependents/4443
+        VERB="install --force"
+        if [ "$KEG_ONLY" -eq 0 ]; then
+            brew unlink "$PACKAGE"
+        fi
     else
         VERB=install
     fi
@@ -328,8 +353,8 @@ function _brew_install_and_cache {
         # doesn't seem to be a documented way to get file names
         local BOTTLE; BOTTLE=$(grep -Ee '^./' <<<"$OUT")
         #proper procedure as per https://discourse.brew.sh/t/how-are-bottle-and-postinstall-related-is-it-safe-to-run-bottle-after-postinstall/3410/4
-        brew uninstall "$PACKAGE"
-        brew install "$BOTTLE"
+        brew uninstall --ignore-dependencies "$PACKAGE"
+        brew $VERB "$BOTTLE"
         
         local JSON; JSON=$(sed -E 's/bottle(.[[:digit:]]+)?\.tar\.gz$/bottle.json/' <<<"$BOTTLE")
         

From 6af897d7dfa15be1abf8fa489a66180215e3579e Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 21 Mar 2019 12:33:04 +0300
Subject: [PATCH 017/345] Install macpython late to avoid conflict with
 Homebrew python upgrade

---
 .travis.yml              |  2 --
 config.sh                | 12 +++++++++---
 travis_osx_brew_cache.sh |  2 ++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8772517e..632af248 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -594,7 +594,6 @@ before_install: |
         brew_cache_cleanup
     fi
 
-    before_install
     # Not interested in travis internal scripts' output
     set +x
 
@@ -602,7 +601,6 @@ install: |
     # Build and package
     set -x
     build_wheel $REPO_DIR $PLAT
-    if [ -n "$USE_CCACHE" ]; then ccache --show-stats; fi
     set +x
 
 script: |
diff --git a/config.sh b/config.sh
index ead68645..22d16066 100644
--- a/config.sh
+++ b/config.sh
@@ -16,6 +16,7 @@ function bdist_wheel_cmd {
     local abs_wheelhouse=$1
     python setup.py bdist_wheel $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
+    if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache --show-stats; fi
 }
 
 if [ -n "$IS_OSX" ]; then
@@ -99,7 +100,7 @@ function pre_build {
     #  this takes several seconds and we don't need it
     # see https://docs.brew.sh/Manpage , "info formula" section
     export HOMEBREW_NO_GITHUB_API=1
-    
+
     echo 'Installing QT4'
     brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
     brew tap --list-pinned | grep -qxF cartr/qt4 || brew tap-pin cartr/qt4
@@ -108,8 +109,13 @@ function pre_build {
     echo 'Installing FFmpeg'
 
     generate_ffmpeg_formula
-    brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
-
+    local IS_BOTTLE_AVAILABLE; _brew_is_bottle_available ffmpeg_opencv && IS_BOTTLE_AVAILABLE=1 || IS_BOTTLE_AVAILABLE=0
+    _brew_install_and_cache ffmpeg_opencv "$IS_BOTTLE_AVAILABLE"
+    #brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
+    
+    # Have to install macpython late to avoid conflict with Homebrew Python update
+    before_install
+    
   else
     echo "Running for linux"
   fi
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index c62a6235..261e1d00 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -215,6 +215,8 @@ function brew_go_bootstrap_mode {
 # Terminate the build but ensure saving the cache
 
     echo "Going into cache bootstrap mode"
+    
+    BREW_BOOTSTRAP_MODE=1
         
     #Can't just `exit` because that would terminate the build without saving the cache
     #Have to replace further actions with no-ops

From 6e8f51643217805af7cee13cbc148b5356b2284a Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 21 Mar 2019 22:11:08 +0300
Subject: [PATCH 018/345] OSX custom ffmpeg formula: disable GPLed frei0r,
 librubberband

---
 config.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/config.sh b/config.sh
index 22d16066..59c40ee3 100644
--- a/config.sh
+++ b/config.sh
@@ -70,8 +70,8 @@ if [ -n "$IS_OSX" ]; then
                 if (!$found_blank && /^$/) {$_.="conflicts_with \"ffmpeg\"\n\n"; $found_blank=1; next;}
                 if (!$bottle_block && /^\s*bottle do$/) { $bottle_block=1; next; }
                 if ($bottle_block) { if (/^\s*end\s*$/) { $bottle_block=0} elsif (/^\s*sha256\s/) {$_=""} next; }
-if (/^\s*depends_on "(x264|x265|xvid)"$/) {$_=""; next;}
-                if (/^\s*--enable-(gpl|libx264|libx265|libxvid)$/) {$_=""; next;}
+if (/^\s*depends_on "(x264|x265|xvid|frei0r|rubberband)"$/) {$_=""; next;}
+                if (/^\s*--enable-(gpl|libx264|libx265|libxvid|frei0r|librubberband)$/) {$_=""; next;}
                 ' <"$FF_FORMULA" >"$LFF_FORMULA"
             diff -u "$FF_FORMULA" "$LFF_FORMULA" || test $? -le 1
 

From cbfa320e02d0c0545244bd053d05e964cb7dfc32 Mon Sep 17 00:00:00 2001
From: Admin <admin@Mac-Admin.local>
Date: Fri, 22 Mar 2019 02:34:10 +0300
Subject: [PATCH 019/345] Adapt setup.py hook for skbuild 0.9.0

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index fa70f5a3..a6494914 100644
--- a/setup.py
+++ b/setup.py
@@ -268,7 +268,7 @@ def _classify_installed_files_override(self, install_paths,
 
         # '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_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]

From b9350e7d17d96fdcb3dfe36cded2a51412a5f7e2 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Fri, 22 Mar 2019 23:04:51 +0300
Subject: [PATCH 020/345] Reduce the amount of trace output

* Reduce the number of command lines executed in most used functions
* List existing versions only when installing
---
 travis_osx_brew_cache.sh | 51 ++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 261e1d00..69dbf729 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -1,12 +1,5 @@
 # Library to cache downloaded and locally-built Homebrew bottles in Travis OSX build.
 
-_BREW_ERREXIT='
-set -e -o pipefail
-trap '\''{ sleep 3;    #if we terminale too abruptly, Travis will lose some log output
-        exit 2;     #The trap isn''t called in the parent function, so can''t use `return` here.
-                    #`exit` will terminate the entire build but it seems we have no choice.
-}'\'' ERR
-set -E'
 
 #Should be in Travis' cache
 BREW_LOCAL_BOTTLE_METADATA="$HOME/local_bottle_metadata"
@@ -37,16 +30,17 @@ function brew_install_and_cache_within_time_limit {
     # use bottle if available, build and cache bottle if not.
     # Terminate and exit with status 1 if this takes too long.
     # Exit with status 2 on any other error.
-    ( eval "$_BREW_ERREXIT"
-    
-    local PACKAGE; PACKAGE="${1:?}" || exit 2
-    local TIME_LIMIT;TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || exit 2
-    local TIME_HARD_LIMIT;TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || exit 2
-    local TIME_START;TIME_START=${4:-$BREW_TIME_START} || exit 2
+    ( set -eE -o pipefail; trap '{ sleep 3; exit 2; }' ERR
+
+    local PACKAGE TIME_LIMIT TIME_HARD_LIMIT TIME_START
+    PACKAGE="${1:?}" || exit 2
+    TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || exit 2
+    TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || exit 2
+    TIME_START=${4:-$BREW_TIME_START} || exit 2
 
     local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
     
-    if brew list --versions "$PACKAGE" && ! (brew outdated | grep -qx "$PACKAGE"); then
+    if brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE"); then
         echo "Already installed and the latest version: $PACKAGE"
         return 0
     fi
@@ -266,8 +260,9 @@ function _brew_parse_package_info {
     # Get and parse `brew info --json` about a package
     # and save data into specified variables
     
-    local PACKAGE; PACKAGE="${1:?}"; shift
-    local OS_CODENAME;OS_CODENAME="${1:?}"; shift
+    local PACKAGE OS_CODENAME
+    PACKAGE="${1:?}"; shift
+    OS_CODENAME="${1:?}"; shift
 
     local JSON_DATA; JSON_DATA=$(python2.7 -c 'if True:
     import sys, json, subprocess; j=json.loads(subprocess.check_output(("brew","info","--json=v1",sys.argv[1])))
@@ -325,12 +320,13 @@ function _brew_install_and_cache {
     # assumes that deps were already installed
     # and not already the latest version
     
-    local PACKAGE;PACKAGE="${1:?}"
-    local USE_BOTTLE;USE_BOTTLE="${2:?}"
-    local KEG_ONLY;KEG_ONLY="${3:?}"
+    local PACKAGE USE_BOTTLE KEG_ONLY
+    PACKAGE="${1:?}"
+    USE_BOTTLE="${2:?}"
+    KEG_ONLY="${3:?}"
     local VERB
     
-    if brew list --versions "$PACKAGE" >/dev/null; then
+    if brew list --versions "$PACKAGE"; then
         # Install alongside the old version to avoid to have to update "runtime dependents"
         # https://discourse.brew.sh/t/can-i-install-a-new-version-without-having-to-upgrade-runtime-dependents/4443
         VERB="install --force"
@@ -382,10 +378,11 @@ function _brew_check_elapsed_build_time {
     # If time limit has been reached,
     # arrange for further build to be skipped and return 1
 
-    local TIME_START;TIME_START="${1:?}"
-    local TIME_LIMIT;TIME_LIMIT="${2:?}"
+    local TIME_START TIME_LIMIT ELAPSED_TIME
+    TIME_START="${1:?}"
+    TIME_LIMIT="${2:?}"
     
-    local ELAPSED_TIME;ELAPSED_TIME=$(($(date +%s) - $TIME_START))
+    ELAPSED_TIME=$(($(date +%s) - $TIME_START))
     echo "Elapsed time: "$(($ELAPSED_TIME/60))"m (${ELAPSED_TIME}s)"
     
     if [[ "$ELAPSED_TIME" -gt $TIME_LIMIT ]]; then 
@@ -400,10 +397,12 @@ function _brew_check_slow_building_ahead {
     #If the package's projected build completion is higher than hard limit,
     # skip it and arrange for further build to be skipped and return 1
     
-    local PACKAGE="${1:?}"
-    local TIME_START="${2:?}"
-    local TIME_HARD_LIMIT="${3:?}"
+    local PACKAGE TIME_START TIME_HARD_LIMIT
+    PACKAGE="${1:?}"
+    TIME_START="${2:?}"
+    TIME_HARD_LIMIT="${3:?}"
     
+    local PROJECTED_BUILD_TIME 
     PROJECTED_BUILD_TIME=$(echo "$BREW_SLOW_BUILIDING_PACKAGES" | awk '$1=="'"$PACKAGE"'"{print $2}')
     [ -z "$PROJECTED_BUILD_TIME" ] && return 0 || true
     

From 7af6a3545e4497fc6ad148cea232dd5ff04a192a Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 23 Mar 2019 02:08:15 +0300
Subject: [PATCH 021/345] Use 2 stages for MacOS builds

* Add a dedicated stage to each OSX build to download/build brew packages
* Remove bottle building logic and the corresponding trace output from the project build stage
---
 .travis.yml              | 128 +++++++++++++++++++++++++++++++++------
 config.sh                |  35 +++++++----
 travis_osx_brew_cache.sh |   6 +-
 3 files changed, 135 insertions(+), 34 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 632af248..07febd6e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -34,144 +34,232 @@ cache:
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
 
+# Add more cache stages (s2 etc) and corresponding OSX jobs like s1
+# if brew builds start to take longer than one Travis time limit
+stages:
+  - s1
+  - final
+    
 matrix:
   fast_finish: true
   include:
 
     # default builds for MacOS
-    - os: osx
+    - &osx-10
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-10
+      stage: s1
+    - &osx-30
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-30
+      stage: s1
+    - &osx-40
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-40
+      stage: s1
+    - &osx-50
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-50
+      stage: s1
+    - &osx-60
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
+      stage: final
+    - <<: *osx-60
+      stage: s1
 
     # headless builds for MacOS
-    - os: osx
+    - &osx-70
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-70
+      stage: s1
+    - &osx-80
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-80
+      stage: s1
+    - &osx-90
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-90
+      stage: s1
+    - &osx-100
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-100
+      stage: s1
+    - &osx-110
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
+      stage: final
+    - <<: *osx-110
+      stage: s1
 
     # Contrib builds for MacOS
-    - os: osx
+    - &osx-120
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-120
+      stage: s1
+    - &osx-130
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-130
+      stage: s1
+    - &osx-140
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-140
+      stage: s1
+    - &osx-150
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-    - os: osx
+      stage: final
+    - <<: *osx-150
+      stage: s1
+    - &osx-160
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
+      stage: final
+    - <<: *osx-160
+      stage: s1
 
     # headless contrib builds for MacOS
-    - os: osx
+    - &osx-170
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-170
+      stage: s1
+    - &osx-180
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-180
+      stage: s1
+    - &osx-190
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-190
+      stage: s1
+    - &osx-200
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-    - os: osx
+      stage: final
+    - <<: *osx-200
+      stage: s1
+    - &osx-210
+      os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
+      stage: final
+    - <<: *osx-210
+      stage: s1
 
     # default builds for Linux
     - os: linux
+      # the following jobs will use the same stage name by default
+      stage: s1
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
diff --git a/config.sh b/config.sh
index 59c40ee3..16a5ad68 100644
--- a/config.sh
+++ b/config.sh
@@ -37,11 +37,6 @@ if [ -n "$IS_OSX" ]; then
         "ffmpeg_opencv 10" \
     )
 
-    #Contrib adds significantly to project's build time
-    if [ "$ENABLE_CONTRIB" -eq 1 ]; then
-        BREW_TIME_LIMIT=$((BREW_TIME_LIMIT - 10*60))
-    fi
-
     function generate_ffmpeg_formula {
         local FF="ffmpeg"
         local LFF="ffmpeg_opencv"
@@ -92,9 +87,14 @@ function pre_build {
 
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
+    
+    local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
-    brew update
-    brew_add_local_bottles
+    #after the cache stage, all bottles and Homebrew metadata should be already cached locally
+    if [ -n "$CACHE_STAGE" ]; then
+        brew update
+        brew_add_local_bottles
+    fi
 
     # Don't query analytical info online on `brew info`,
     #  this takes several seconds and we don't need it
@@ -104,14 +104,25 @@ function pre_build {
     echo 'Installing QT4'
     brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
     brew tap --list-pinned | grep -qxF cartr/qt4 || brew tap-pin cartr/qt4
-    brew_install_and_cache_within_time_limit qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
+    if [ -n "$CACHE_STAGE" ]; then
+        brew_install_and_cache_within_time_limit qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
+    else
+        brew install qt@4
+    fi
 
     echo 'Installing FFmpeg'
 
-    generate_ffmpeg_formula
-    local IS_BOTTLE_AVAILABLE; _brew_is_bottle_available ffmpeg_opencv && IS_BOTTLE_AVAILABLE=1 || IS_BOTTLE_AVAILABLE=0
-    _brew_install_and_cache ffmpeg_opencv "$IS_BOTTLE_AVAILABLE"
-    #brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
+    if [ -n "$CACHE_STAGE" ]; then
+        generate_ffmpeg_formula
+        brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
+    else
+        brew install ffmpeg_opencv
+    fi
+
+    if [ -n "$CACHE_STAGE" ]; then
+        brew_go_bootstrap_mode 0
+        return 0
+    fi
     
     # Have to install macpython late to avoid conflict with Homebrew Python update
     before_install
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 69dbf729..3eba10f6 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -10,7 +10,8 @@ BREW_TIME_START=$(($TRAVIS_TIMER_START_TIME/10**9))
 
 # If after a package is built, elapsed time is more than this many seconds, fail the build but save Travis cache
 # The cutoff moment should leave enough time till Travis' job time limit to process the main project.
-BREW_TIME_LIMIT=$((30*60))
+#  Since we have moved deps into a separate stage, we don't need to leave time for the project any more
+BREW_TIME_LIMIT=$((38*60))
 # If a slow-building package is about to be built and the projected build end moment is beyond this many seconds,
 # skip that build, fail the Travis job and save Travis cache.
 # This cutoff should leave enough time for before_cache and cache save.
@@ -207,6 +208,7 @@ function brew_cache_cleanup {
 function brew_go_bootstrap_mode {
 # Can be overridden
 # Terminate the build but ensure saving the cache
+    local EXIT_CODE=${1:-1}
 
     echo "Going into cache bootstrap mode"
     
@@ -223,7 +225,7 @@ function brew_go_bootstrap_mode {
         
         # Travis runs user scripts via `eval` i.e. in the same shell process.
         # So have to unset errexit in order to get to cache save stage
-        set +e; return 1
+        set +e; return '"$EXIT_CODE"'
     }'    
 }
 

From 2c8282f816a125cb7f2f6918f69dd37ec36a6fcf Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 23 Mar 2019 22:16:33 +0300
Subject: [PATCH 022/345] Further increase time limits for the cache jobs

---
 travis_osx_brew_cache.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 3eba10f6..87de4c78 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -11,11 +11,11 @@ BREW_TIME_START=$(($TRAVIS_TIMER_START_TIME/10**9))
 # If after a package is built, elapsed time is more than this many seconds, fail the build but save Travis cache
 # The cutoff moment should leave enough time till Travis' job time limit to process the main project.
 #  Since we have moved deps into a separate stage, we don't need to leave time for the project any more
-BREW_TIME_LIMIT=$((38*60))
+BREW_TIME_LIMIT=$((42*60))
 # If a slow-building package is about to be built and the projected build end moment is beyond this many seconds,
 # skip that build, fail the Travis job and save Travis cache.
 # This cutoff should leave enough time for before_cache and cache save.
-BREW_TIME_HARD_LIMIT=$((40*60))
+BREW_TIME_HARD_LIMIT=$((43*60))
 
 
 # Auto cleanup can delete locally-built bottles

From 81e4987e05536977c808093e740607ea7d4d8ffa Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 23 Mar 2019 22:17:44 +0300
Subject: [PATCH 023/345] x265 is not among the custom formula dependencies

---
 config.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config.sh b/config.sh
index 16a5ad68..c6aae3db 100644
--- a/config.sh
+++ b/config.sh
@@ -32,7 +32,6 @@ if [ -n "$IS_OSX" ]; then
     source travis_osx_brew_cache.sh
 
     BREW_SLOW_BUILIDING_PACKAGES=$(printf '%s\n' \
-        "x265 20"  \
         "cmake 15" \
         "ffmpeg_opencv 10" \
     )

From 02ab5572128ea5e35b254641906fa899c1da1e0e Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 23 Mar 2019 22:20:33 +0300
Subject: [PATCH 024/345] HOMEBREW_NO_GITHUB_API is more relevant to the lib
 rather than main logic

---
 config.sh                | 5 -----
 travis_osx_brew_cache.sh | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/config.sh b/config.sh
index c6aae3db..c31def77 100644
--- a/config.sh
+++ b/config.sh
@@ -95,11 +95,6 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    # Don't query analytical info online on `brew info`,
-    #  this takes several seconds and we don't need it
-    # see https://docs.brew.sh/Manpage , "info formula" section
-    export HOMEBREW_NO_GITHUB_API=1
-
     echo 'Installing QT4'
     brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
     brew tap --list-pinned | grep -qxF cartr/qt4 || brew tap-pin cartr/qt4
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 87de4c78..43625c41 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -22,6 +22,12 @@ BREW_TIME_HARD_LIMIT=$((43*60))
 # when the caching logic isn't prepared for that
 export HOMEBREW_NO_INSTALL_CLEANUP=1
 
+# Don't query analytical info online on `brew info`,
+#  this takes several seconds and we don't need it
+# see https://docs.brew.sh/Manpage , "info formula" section
+export HOMEBREW_NO_GITHUB_API=1
+
+
 
 
 #Public functions

From ae953ca3c1ce08b9787bbdec3b55cf1cb020a412 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 5 Apr 2019 19:43:01 +0300
Subject: [PATCH 025/345] update README

---
 README.md | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/README.md b/README.md
index 32e5687b..a8556f98 100644
--- a/README.md
+++ b/README.md
@@ -50,12 +50,20 @@ A: Most likely the issue is related to too old pip and can be fixed by running `
 
 A: If the import fails on Windows, make sure you have [Visual C++ redistributable 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145) installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, [Universal C Runtime](https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows) might be also required.
 
+Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also [Windows Media Feature Pack](https://support.microsoft.com/en-us/help/3145500/media-feature-pack-list-for-windows-n-editions).
+
 If the above does not help, check if you are using Anaconda. Old Anaconda versions have a bug which causes the error, see [this issue](https://github.com/skvark/opencv-python/issues/36) for a manual fix.
 
+If you still encounter the error after you have checked all the previous solutions, download [Dependencies](https://github.com/lucasg/Dependencies) and open the ``cv2.pyd`` (located usually at ``C:\Users\username\AppData\Local\Programs\Python\PythonXX\Lib\site-packages\cv2``) file with it to debug missing DLL issues.
+
 **Q: I have some other import errors?**
 
 A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
 
+**Q: Why the packages do not include non-free algorithms?**
+
+A: Non-free algorithms such as SIFT and SURF are not included in these packages because they are patented and therefore cannot be distributed as built binaries. See this issue for more info: https://github.com/skvark/opencv-python/issues/126
+
 **Q: Why the package and import are different (opencv-python vs. cv2)?**
 
 A: It's easier for users to understand ``opencv-python`` than ``cv2`` and it makes it easier to find the package with search engines. `cv2` (old interface in old OpenCV versions was named as `cv`) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet. Changing the import name or behaviour would be also confusing to experienced users who are accustomed to the ``import cv2``.

From 3025220a9724ed7cb9ec6079dbaa24d67e6029d5 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 8 Apr 2019 18:43:59 +0300
Subject: [PATCH 026/345] add --user flag to pip install

---
 .travis.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 07febd6e..22822de6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,7 +39,7 @@ cache:
 stages:
   - s1
   - final
-    
+
 matrix:
   fast_finish: true
   include:
@@ -722,10 +722,10 @@ after_success: |
     # Upload wheels to pypi if requested
     if [ -n "$TRAVIS_TAG" ]; then
         set -x
-        pip install twine
+        pip install --user twine
 
         if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-          pip install --upgrade pyOpenSSL
+          pip install --user --upgrade pyOpenSSL
         fi
 
         if [[ $ENABLE_CONTRIB == 0 ]]; then

From 9aa34f7d3b28ffb5aba380d72586cb44b9bab0c2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 8 Apr 2019 19:02:02 +0300
Subject: [PATCH 027/345] upgrade six...

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 22822de6..c63fdbbb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -723,6 +723,7 @@ after_success: |
     if [ -n "$TRAVIS_TAG" ]; then
         set -x
         pip install --user twine
+        pip install --user --upgrade six
 
         if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
           pip install --user --upgrade pyOpenSSL

From 2fa617300642390f2ee4011e0ce177dcfba9c003 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 8 Apr 2019 19:33:26 +0300
Subject: [PATCH 028/345] update README

---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index a8556f98..10229096 100644
--- a/README.md
+++ b/README.md
@@ -144,7 +144,9 @@ The default ``manylinux`` images have been extended with some OpenCV dependencie
 
 ### Supported Python versions
 
-Python 2.7 is the only supported version in 2.x series. Python 3.x releases follow Numpy releases. For example Python 3.3 is no longer supported by Numpy so support for it has been dropped in ``opencv-python``, too.
+Python 2.7 is the only supported version in 2.x series. Python 2.7 support will be dropped in the end of 2019.
+
+Python 3.x releases follow Numpy releases. For example Python 3.3 is no longer supported by Numpy so support for it has been dropped in ``opencv-python``, too.
 
 Currently, builds for following Python versions are provided:
 

From 630df31b430e1b7b06d07e15204978d73323f7bc Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 8 Apr 2019 23:26:50 +0300
Subject: [PATCH 029/345] fix macOS deployment phase

---
 .travis.yml | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c63fdbbb..34d989f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -722,11 +722,15 @@ after_success: |
     # Upload wheels to pypi if requested
     if [ -n "$TRAVIS_TAG" ]; then
         set -x
-        pip install --user twine
-        pip install --user --upgrade six
+
+        if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+          pip install --user twine
+          pip install --user --upgrade six
+        fi
 
         if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-          pip install --user --upgrade pyOpenSSL
+          pip install twine
+          pip install --upgrade pyOpenSSL
         fi
 
         if [[ $ENABLE_CONTRIB == 0 ]]; then

From 54cbe08ad584b279f1cd250ca286d2de819ef7b5 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 00:35:34 +0300
Subject: [PATCH 030/345] Fix values of mismatch detection variables carrying
 over to the next iteration

Happened in https://travis-ci.org/skvark/opencv-python/builds/518836739 S1 jobs
---
 travis_osx_brew_cache.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 43625c41..6a270678 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -106,8 +106,8 @@ function brew_add_local_bottles {
         local FORMULA_HAS_BOTTLE; [ -n "$FORMULA_BOTTLE_HASH" ] && FORMULA_HAS_BOTTLE=1 || true
         
 
-        local BOTTLE_LINK BOTTLE; BOTTLE_LINK="${JSON}.bottle.lnk";
-        local BOTTLE_EXISTS BOTTLE_MISMATCH VERSION_MISMATCH
+        local BOTTLE_LINK BOTTLE=""; BOTTLE_LINK="${JSON}.bottle.lnk";
+        local BOTTLE_EXISTS= BOTTLE_MISMATCH= VERSION_MISMATCH=
 
 
         # Check that the bottle file exists and is still appropriate for the formula

From d3c3882338c2c624ed6aadb325ded83a386cebfe Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 00:46:02 +0300
Subject: [PATCH 031/345] Fix removing old built opencv_ffmpeg when a new
 upstream formula is available

Happened in https://travis-ci.org/skvark/opencv-python/builds/518179810 S1 jobs
---
 config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config.sh b/config.sh
index c31def77..2a7e8ec1 100644
--- a/config.sh
+++ b/config.sh
@@ -92,6 +92,7 @@ function pre_build {
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update
+        generate_ffmpeg_formula
         brew_add_local_bottles
     fi
 
@@ -107,7 +108,6 @@ function pre_build {
     echo 'Installing FFmpeg'
 
     if [ -n "$CACHE_STAGE" ]; then
-        generate_ffmpeg_formula
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew install ffmpeg_opencv

From ea088a936d1596ac31a0ef58303faf6059bb9070 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 01:19:18 +0300
Subject: [PATCH 032/345] Don't print bogus error message when cache warmup is
 complete

---
 travis_osx_brew_cache.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 6a270678..eb15618c 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -223,12 +223,19 @@ function brew_go_bootstrap_mode {
     #Can't just `exit` because that would terminate the build without saving the cache
     #Have to replace further actions with no-ops
     
+    local MESSAGE=""; if [ "$EXIT_CODE" -ne 0 ]; then
+        MESSAGE='Building dependencies took too long. Restart the build in Travis UI to continue from cache.';
+    fi
+    
     eval '
     function '"$cmd"' { return 0; }
     function repair_wheelhouse { return 0; }
-    function install_run {
-        echo -e "\nBuilding dependencies took too long. Restart the build in Travis UI to continue from cache.\n"
-        
+    function install_run {'\
+        "$(if [ -n "$MESSAGE" ]; then
+            echo \
+        '        echo -e "\n'"$MESSAGE"'\n"'
+        fi)"\
+    '    
         # Travis runs user scripts via `eval` i.e. in the same shell process.
         # So have to unset errexit in order to get to cache save stage
         set +e; return '"$EXIT_CODE"'

From bf365e191e33eaabaa362ceeb4e1111a2e9cc417 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 04:12:14 +0300
Subject: [PATCH 033/345] Fix "Error: broken pipe" if `brew info` gives lots of
 output

---
 travis_osx_brew_cache.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index eb15618c..65d4f0a9 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -307,7 +307,9 @@ function _brew_is_bottle_available {
     local PACKAGE;PACKAGE="${1:?}"
     local VAR_KEG_ONLY="$2"
 
-    local INFO;INFO="$(brew info "$PACKAGE" | head -n 1)"
+    # `brew info` prints "Error: Broken pipe" if piped directly to `head` and the info is long
+    # 141 = 128 + SIGPIPE
+    local INFO;INFO="$((brew info "$PACKAGE" | cat || test $? -eq 141) | head -n 1)"
     if [ -n "$VAR_KEG_ONLY" ]; then
         if grep -qwF '[keg-only]' <<<"$INFO"; then
             eval "${VAR_KEG_ONLY}=1"

From df122a018c57a3e3657a538b53710cab3c4b13d4 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 05:22:08 +0300
Subject: [PATCH 034/345] CentOS 5 ccache doesn't have --show-stats

---
 config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config.sh b/config.sh
index 2a7e8ec1..af888179 100644
--- a/config.sh
+++ b/config.sh
@@ -16,7 +16,7 @@ function bdist_wheel_cmd {
     local abs_wheelhouse=$1
     python setup.py bdist_wheel $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
-    if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache --show-stats; fi
+    if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 
 if [ -n "$IS_OSX" ]; then

From 8e23e986a83a5c11b0b348073a419d3678927367 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 02:29:59 +0300
Subject: [PATCH 035/345] Use latest cmake for the main build, too, with better
 Python support

---
 config.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/config.sh b/config.sh
index af888179..3370d221 100644
--- a/config.sh
+++ b/config.sh
@@ -111,6 +111,10 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew install ffmpeg_opencv
+        #cmake is a build dependency of ffmpeg so a bottle should be present in cache
+        if (brew outdated | grep -qxF cmake) || ! (brew list | grep -qxF cmake); then
+            _brew_install_and_cache cmake 1 0
+        fi
     fi
 
     if [ -n "$CACHE_STAGE" ]; then

From a22f8bf9f447f9c9ed8f6c4a4a10024f147bf9c7 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 2 May 2019 23:55:12 +0300
Subject: [PATCH 036/345] JSON format change for formula without any bottles

---
 travis_osx_brew_cache.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 65d4f0a9..5eaefe42 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -285,7 +285,7 @@ function _brew_parse_package_info {
     revision=data["revision"]
     # in bottle''s json, revision is included into version; here, they are separate
     print data["versions"]["stable"]+("_"+str(revision) if revision else "")
-    bottle_data=data["bottle"]["stable"]
+    bottle_data=data["bottle"].get("stable",{"rebuild":"","files":{}})
     print bottle_data["rebuild"]
     print bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"]     #prevent losing trailing blank line to command substitution
     ' \

From 676971681d846ad0a82b07afc7ccb7bedc1bfe34 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Fri, 3 May 2019 22:34:38 +0300
Subject: [PATCH 037/345] Speed up repeat checks for the same deps

---
 travis_osx_brew_cache.sh | 85 +++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 5eaefe42..e3a69cc3 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -27,7 +27,8 @@ export HOMEBREW_NO_INSTALL_CLEANUP=1
 # see https://docs.brew.sh/Manpage , "info formula" section
 export HOMEBREW_NO_GITHUB_API=1
 
-
+#Packages already installed in the current session to avoid checking them again
+_BREW_ALREADY_INSTALLED='$'     #$ = illegal package name; a blank line would cause macos grep to swallow everything
 
 
 #Public functions
@@ -37,39 +38,8 @@ function brew_install_and_cache_within_time_limit {
     # use bottle if available, build and cache bottle if not.
     # Terminate and exit with status 1 if this takes too long.
     # Exit with status 2 on any other error.
-    ( set -eE -o pipefail; trap '{ sleep 3; exit 2; }' ERR
-
-    local PACKAGE TIME_LIMIT TIME_HARD_LIMIT TIME_START
-    PACKAGE="${1:?}" || exit 2
-    TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || exit 2
-    TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || exit 2
-    TIME_START=${4:-$BREW_TIME_START} || exit 2
-
-    local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
-    
-    if brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE"); then
-        echo "Already installed and the latest version: $PACKAGE"
-        return 0
-    fi
-
-    
-    _brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
-    [ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
-
-    # Whitespace is illegal in package names so converting all whitespace into single spaces due to no quotes is okay.
-    DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || exit 2
-    for dep in $DEPS; do
-        #TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
-        #While we don't know that yet, we can make better use of Travis-given time with a laxer limit
-        #We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
-        brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || exit $?
-    done
-
-    _brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || exit $?
-    _brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || exit 2
-    _brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || exit $?
-    ) \
-    || if test $? -eq 1; then brew_go_bootstrap_mode; return 1; else return 2; fi      #must run this in current process
+    _brew_install_and_cache_within_time_limit $@ \
+    || if test $? -eq 1; then brew_go_bootstrap_mode; return 1; else return 2; fi
 }
 
 function brew_add_local_bottles {
@@ -246,6 +216,46 @@ function brew_go_bootstrap_mode {
 
 #Internal functions
 
+function _brew_install_and_cache_within_time_limit {
+    # This fn is run with || so errexit can't be enabled
+
+    local PACKAGE TIME_LIMIT TIME_HARD_LIMIT TIME_START MARKED_INSTALLED
+    PACKAGE="${1:?}" || return 2
+    TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || return 2
+    TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || return 2
+    TIME_START=${4:-$BREW_TIME_START} || return 2
+
+    if grep -qxFf <(cat <<<"$_BREW_ALREADY_INSTALLED") <<<"$PACKAGE"; then
+        MARKED_INSTALLED=1
+    fi
+        
+    if [ -n "$MARKED_INSTALLED" ] || (brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE")); then
+        echo "Already installed and the latest version: $PACKAGE"
+        if [ -z "$MARKED_INSTALLED" ]; then _brew_mark_installed "$PACKAGE"; fi
+        return 0
+    fi
+    
+    local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
+    
+    _brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
+    [ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
+
+    # Whitespace is illegal in package names so converting all whitespace into single spaces due to no quotes is okay.
+    DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || return 2
+    DEPS=`grep -vxF <(cat <<<"$_BREW_ALREADY_INSTALLED") <<<"$DEPS"` || test $? -eq 1 || return 2
+    for dep in $DEPS; do
+        #TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
+        #While we don't know that yet, we can make better use of Travis-given time with a laxer limit
+        #We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
+        _brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || return $?
+    done
+
+    _brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || return $?
+    _brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || return 2
+    _brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || return $?
+}
+    
+
 function _brew_parse_bottle_json {
     # Parse JSON file resulting from `brew bottle --json`
     # and save data into specified variables
@@ -386,10 +396,13 @@ function _brew_install_and_cache {
         echo "$CACHED_BOTTLE" >"$BOTTLE_LINK"
         
     fi
+    
+    _brew_mark_installed "$PACKAGE"
 }
 
-
-
+function _brew_mark_installed {
+    _BREW_ALREADY_INSTALLED="$_BREW_ALREADY_INSTALLED"$'\n'"${1:?}"
+}
 
 function _brew_check_elapsed_build_time {
     # If time limit has been reached,

From 87902b0e40fd04ec47bf4d53d4b6cfa342250ad9 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 4 May 2019 11:02:49 +0300
Subject: [PATCH 038/345] Add prefix to all files related to CI rather than
 project

---
 .travis.yml                                               | 3 ++-
 config.sh => travis_config.sh                             | 0
 multibuild_customize.sh => travis_multibuild_customize.sh | 0
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename config.sh => travis_config.sh (100%)
 rename multibuild_customize.sh => travis_multibuild_customize.sh (100%)

diff --git a/.travis.yml b/.travis.yml
index 34d989f8..81d2331e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ env:
         - TEST_DEPENDS="numpy==1.11.1"
         # params to bdist_wheel. used to set osx build target.
         - BDIST_PARAMS=""
+        - CONFIG_PATH="travis_config.sh"
         - USE_CCACHE=1
         - PLAT=x86_64
         - UNICODE_WIDTH=32
@@ -663,7 +664,7 @@ before_install: |
     if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
     source multibuild/travis_steps.sh
     # This sets -x
-    source multibuild_customize.sh
+    source travis_multibuild_customize.sh
     echo $ENABLE_CONTRIB > contrib.enabled
     echo $ENABLE_HEADLESS > headless.enabled
 
diff --git a/config.sh b/travis_config.sh
similarity index 100%
rename from config.sh
rename to travis_config.sh
diff --git a/multibuild_customize.sh b/travis_multibuild_customize.sh
similarity index 100%
rename from multibuild_customize.sh
rename to travis_multibuild_customize.sh

From 61ddc1a2fbbf8ca56a22b5feb72b1e6ca7daf050 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Thu, 13 Jun 2019 19:57:44 +0300
Subject: [PATCH 039/345] Revert "Use latest cmake for the main build, too,
 with better Python support

This reverts commit d4a51981676eacd6763fac5b183e6267a4305610.

cmake 3.14 can't find py3 installation when "python" points to Python 3 while cmake 3.9 can
---
 travis_config.sh | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 3370d221..af888179 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -111,10 +111,6 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew install ffmpeg_opencv
-        #cmake is a build dependency of ffmpeg so a bottle should be present in cache
-        if (brew outdated | grep -qxF cmake) || ! (brew list | grep -qxF cmake); then
-            _brew_install_and_cache cmake 1 0
-        fi
     fi
 
     if [ -n "$CACHE_STAGE" ]; then

From 8f08f38ad6d07544b276663a03ae67febc1991d4 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Tue, 30 Jul 2019 08:27:45 +0200
Subject: [PATCH 040/345] Travis CI: Xenial is now the default Ubuntu in Travis

https://blog.travis-ci.com/2019-04-15-xenial-default-build-environment

Also: __sudo: required__ no longer is [Travis are now recommending removing the __sudo__ tag](https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration) because the sudo command is always available in Travis CI and there is no longer any way to turn it off.
---
 .travis.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 81d2331e..d1efa36a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,11 +13,9 @@ env:
 
 # Host Python is never used
 language: generic
-# Required to invoke docker ourselves as per https://docs.travis-ci.com/user/docker/
-sudo: required
 services: docker
-# https://docs.travis-ci.com/user/reference/trusty/
-dist: trusty
+# https://docs.travis-ci.com/user/reference/xenial
+dist: xenial
 
 # Save some time, we and setup check them out on demand instead
 # https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth

From a229f278b7fa90e6e0099d90b3d17b0e2cc59d1e Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Sat, 17 Aug 2019 16:08:13 +0300
Subject: [PATCH 041/345] Allow passing custom CMake arguments

---
 README.md | 30 ++++++++++++++++++++----------
 setup.py  |  6 ++++++
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 10229096..0db6eb08 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,10 @@ The aim of this repository is to provide means to package each new [OpenCV relea
 
 ### Build process
 
-The project is structured like a normal Python package with a standard ``setup.py`` file. The build process for a single entry in the build matrices is as follows (see for example ``appveyor.yml`` file):
+The project is structured like a normal Python package with a standard ``setup.py`` file.
+The build process for a single entry in the build matrices is as follows (see for example ``appveyor.yml`` file):
+
+0. In Linux and MacOS build: get OpenCV's optional C dependencies that we compile against
 
 1. Checkout repository and submodules
 
@@ -86,25 +89,32 @@ The project is structured like a normal Python package with a standard ``setup.p
    -  Contrib modules are also included as a submodule
 
 2. Find OpenCV version from the sources
-3. Install dependencies (numpy)
+3. Install Python dependencies
+
+   - ``setup.py`` installs the dependencies itself, so you need to run it in an environment
+     where you have the rights to install modules with Pip for the running Python
+
 4. Build OpenCV
 
    -  tests are disabled, otherwise build time increases too much
    -  there are 4 build matrix entries for each build combination: with and without contrib modules, with and without GUI (headless)
    -  Linux builds run in manylinux Docker containers (CentOS 5)
 
-5. Copy each ``.pyd/.so`` file to cv2 folder of this project and
-   generate wheel
+5. Rearrange OpenCV's build result, add our custom files and generate wheel
+
+6. Linux and macOS wheels are transformed with auditwheel and delocate, correspondingly
 
-   - Linux and macOS wheels are checked with auditwheel and delocate
+7. Install the generated wheel
+8. Test that Python can import the library and run some sanity checks
+9. Use twine to upload the generated wheel to PyPI (only in release builds)
 
-6. Install the generated wheel
-7. Test that Python can import the library and run some sanity checks
-8. Use twine to upload the generated wheel to PyPI (only in release builds)
+Steps 1--5 are handled by ``setup.py bdist_wheel``.
 
-The ``cv2.pyd/.so`` file is normally copied to site-packages. To avoid polluting the root folder this package wraps the statically built binary into cv2 package and ``__init__.py`` file in the package handles the import logic correctly.
+The build can be customized with environment variables.
+In addition to any variables that OpenCV's build accepts, we recognize:
 
-Since all packages use the same ``cv2`` namespace explained above, uninstall the other package before switching for example from ``opencv-python`` to ``opencv-contrib-python``.
+- ``ENABLE_CONTRIB`` and ``ENABLE_HEADLESS``. Set to ``1`` to build the contrib and/or headless version
+- ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build.
 
 ### Licensing
 
diff --git a/setup.py b/setup.py
index a6494914..29dc1efd 100644
--- a/setup.py
+++ b/setup.py
@@ -154,6 +154,12 @@ def main():
     if sys.platform.startswith('linux') and not x64:
         cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
 
+        
+    if 'CMAKE_ARGS' in os.environ:
+        import shlex
+        cmake_args.extend(shlex.split(os.environ['CMAKE_ARGS']))
+        del shlex
+        
     # ABI config variables are introduced in PEP 425
     if sys.version_info[:2] < (3, 2):
         import warnings

From a7019ef748fd3680e844c752fd670e21297da2f0 Mon Sep 17 00:00:00 2001
From: Abhishek Thakur <abhi.una12@gmail.com>
Date: Sun, 18 Aug 2019 16:22:07 +0530
Subject: [PATCH 042/345] Added OpenSSL & various protocol support to FFmpeg
 backend (#229)

* Added OpenSSL & different protocol support to FFmpeg backend
- Fixed Docker dependencies (both x86 & x86-64)
- Fixes bug #204

* Additional Fixes
- updates to OpenSSL build from scratch
- removed specific protocol
- Added neccessary dependency

* Fixed ./Configure command

* Updates for docker images:
- Added perl build from scratch
- Fixed wrong/redundant dependencies/paths
- Fixed & updated openssl installation

* Fixed Empty continuation lines bug & added comments

* fix inconsitent spacing

* Don't add perl 5.10 to PATH

* fix syntax error

* Fixed OpenSSL build fails in i686 Dockerfile due to buggy perl source

* Fixing manylinux docker entrypoint for i686 in 32 bit images

* ENTRYPOINT not needed, it only affects "docker run" invocations

* manylinux1 provides better libcurl for cmake

* manylinux1 provides the toolchain and git

git install fails in i686, too

* cleanup tar invocations

* nasm is not installed in manylinux1

* detect i686 in openssl configure

* move perl to a separate subtree as it's a private dependency

* rm it after library build

* comment unusual openssl build step

* avoid redundant work in perl build

* build each library in a separate dockerfile command for easier debugging

* comment custom i686 step

* update dockerfile README

* opencv now bundles libjpeg-turbo

and the separate's onre buid fails dueto expired certificate at https://kent.dl.sourceforge.net
---
 docker/Dockerfile_i686   | 86 ++++++++++++++++++++++++----------------
 docker/Dockerfile_x86_64 | 83 +++++++++++++++++++++-----------------
 docker/README.md         |  3 +-
 3 files changed, 99 insertions(+), 73 deletions(-)

diff --git a/docker/Dockerfile_i686 b/docker/Dockerfile_i686
index 62366543..98d70324 100644
--- a/docker/Dockerfile_i686
+++ b/docker/Dockerfile_i686
@@ -14,43 +14,74 @@ ENV QTDIR /opt/Qt4.8.7
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
-	tar -zxf cmake-3.9.0.tar.gz && \
+	tar -xf cmake-3.9.0.tar.gz && \
 	cd cmake-3.9.0 && \
-	yum -y install curl-devel zlib-devel && \
+    true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \
+         against the same newer OpenSSL as other source-built tools \
+         (1.0.2s as of this writing)' && \
+	yum -y install zlib-devel && \
 	./configure --system-curl && \
-	make && \
+	make -j4 && \
 	make install && \
 	cd .. && \
 	rm -rf cmake-3.9.0*
 
-RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool make mercurial pkgconfig zlib-devel -y && \
-	yum remove nasm -y && \
-	mkdir ~/ffmpeg_sources && \
-	cd ~/ffmpeg_sources && \
+# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
+# manylinux provides the toolchain and git; we provide cmake
+RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
+    mkdir ~/ffmpeg_sources
+
+# Newer openssl configure requires newer perl
+RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
+	tar -xf perl-5.20.1.tar.gz && \
+	cd perl-5.20.1 && \
+	./Configure -des -Dprefix="$HOME/openssl_build" && \
+	true '#perl build scripts do much redundant work \
+	     if running "make install" separately' && \
+	make install -j4 && \
+	cd .. && \
+	rm -rf perl-5.20.1*
+
+RUN 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 && \
+    true '#in i686, ./config detects x64 in i686 without linux32 \
+         when run from "docker build"' && \
+	PERL="$HOME/openssl_build/bin/perl" linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
+	make -j4 && \
+    true '#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.13.02/nasm-2.13.02.tar.bz2 && \
-	tar xjvf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
+	tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
 	./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
 	make -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	make install
+
+RUN cd ~/ffmpeg_sources && \
 	curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
-	tar xzvf 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 -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	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 -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	make install
+
+RUN cd ~/ffmpeg_sources && \
 	curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
-	tar xjvf 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-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
+	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 -j4 && \
 	make install && \
 	echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
@@ -60,30 +91,15 @@ RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
 
-RUN mkdir libjpeg-turbo && \
-	cd libjpeg-turbo && \
-	export PATH=~/bin:$PATH && \
-	curl -L https://kent.dl.sourceforge.net/project/libjpeg-turbo/1.5.3/libjpeg-turbo-1.5.3.tar.gz > libjpeg-turbo-1.5.3.tar.gz && \
-	tar xzvf libjpeg-turbo-1.5.3.tar.gz && \
-	cd libjpeg-turbo-1.5.3 && \
-	export CFLAGS="-fPIC" && \
-	export CXXFLAGS="-fPIC" && \
-	autoreconf -fiv && \
-	./configure --host=i686-pc-linux-gnu && \
-	make && \
-	make install && \
-	cd ../../ && \
-	rm -rf libjpeg-turbo
-
-ENV JPEG_LIBRARY /opt/libjpeg-turbo/lib32/libjpeg.a
-ENV JPEG_INCLUDE_DIR /opt/libjpeg-turbo/include
-
 RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
 	mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
 
+#in i686, yum metadata ends up with slightly wrong timestamps
+#which inhibits its update
+#https://github.com/skvark/opencv-python/issues/148
 RUN yum clean all
 
 ENV PATH "$HOME/bin:$PATH"
diff --git a/docker/Dockerfile_x86_64 b/docker/Dockerfile_x86_64
index e9de76e8..81b59974 100644
--- a/docker/Dockerfile_x86_64
+++ b/docker/Dockerfile_x86_64
@@ -14,43 +14,72 @@ ENV QTDIR /opt/Qt4.8.7
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
-	tar -zxf cmake-3.9.0.tar.gz && \
+	tar -xf cmake-3.9.0.tar.gz && \
 	cd cmake-3.9.0 && \
-	yum -y install curl-devel zlib-devel && \
+    true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \
+         against the same newer OpenSSL as other source-built tools \
+         (1.0.2s as of this writing)' && \
+	yum -y install zlib-devel && \
 	./configure --system-curl && \
-	make && \
+	make -j4 && \
 	make install && \
 	cd .. && \
 	rm -rf cmake-3.9.0*
 
-RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool make mercurial pkgconfig zlib-devel -y && \
-	yum remove nasm -y && \
-	mkdir ~/ffmpeg_sources && \
-	cd ~/ffmpeg_sources && \
+# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
+# manylinux provides the toolchain and git; we provide cmake
+RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
+    mkdir ~/ffmpeg_sources
+
+# Newer openssl configure requires newer perl
+RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
+	tar -xf perl-5.20.1.tar.gz && \
+	cd perl-5.20.1 && \
+	./Configure -des -Dprefix="$HOME/openssl_build" && \
+	true '#perl build scripts do much redundant work \
+	     if running "make install" separately' && \
+	make install -j4 && \
+	cd .. && \
+	rm -rf perl-5.20.1*
+
+RUN 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 && \
+	PERL="$HOME/openssl_build/bin/perl" ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
+	make -j4 && \
+    true '#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.13.02/nasm-2.13.02.tar.bz2 && \
-	tar xjvf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
+	tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
 	./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
 	make -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	make install
+
+RUN cd ~/ffmpeg_sources && \
 	curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
-	tar xzvf 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 -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	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 -j4 && \
-	make install && \
-	cd ~/ffmpeg_sources && \
+	make install
+
+RUN cd ~/ffmpeg_sources && \
 	curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
-	tar xjvf 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-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
+	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 -j4 && \
 	make install && \
 	echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
@@ -60,28 +89,10 @@ RUN yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ libtool
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
 
-RUN mkdir libjpeg-turbo && \
-	cd libjpeg-turbo && \
-	export PATH=~/bin:$PATH && \
-	curl -L https://kent.dl.sourceforge.net/project/libjpeg-turbo/1.5.3/libjpeg-turbo-1.5.3.tar.gz > libjpeg-turbo-1.5.3.tar.gz && \
-	tar xzvf libjpeg-turbo-1.5.3.tar.gz && \
-	cd libjpeg-turbo-1.5.3 && \
-	export CFLAGS="-fPIC" && \
-	export CXXFLAGS="-fPIC" && \
-	autoreconf -fiv && \
-	./configure && \
-	make && \
-	make install && \
-	cd ../../ && \
-	rm -rf libjpeg-turbo
-
-ENV JPEG_LIBRARY /opt/libjpeg-turbo/lib64/libjpeg.a
-ENV JPEG_INCLUDE_DIR /opt/libjpeg-turbo/include
-
 RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
 	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
 	mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
 
-ENV PATH "$HOME/bin:$PATH"
\ No newline at end of file
+ENV PATH "$HOME/bin:$PATH"
diff --git a/docker/README.md b/docker/README.md
index 2e8602bf..e31d7a07 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -10,6 +10,5 @@ The images have following extra software installed:
 
 - Qt 4.8.7
 - Cmake 3.9.0
-- FFmpeg with libvpx (latest snapshots at the build time)
-- libjpeg-turbo 1.5.3
+- FFmpeg with libvpx (latest snapshots at the build time) and recent openssl
 - Some missing headers included from more recent Linux to be able to enable V4L / V4L2 support in OpenCV
\ No newline at end of file

From 9b41acdc769a9247918c55c1435dd60ae47fcaf8 Mon Sep 17 00:00:00 2001
From: native-api <vano@mail.mipt.ru>
Date: Sun, 18 Aug 2019 13:53:51 +0300
Subject: [PATCH 043/345] Including a custom libjpeg is no longer needed (#231)

* Including a custom libjpeg is no longer needed

Since https://github.com/opencv/opencv/pull/11497, OpenCV bundles its own

* (dummy commit to trigger rebuild)
---
 setup.py | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/setup.py b/setup.py
index 29dc1efd..9fb1e049 100644
--- a/setup.py
+++ b/setup.py
@@ -133,13 +133,6 @@ def main():
         cmake_args.append("-DWITH_V4L=ON")
         cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
-        if all(v in os.environ for v in ('JPEG_INCLUDE_DIR', 'JPEG_LIBRARY')):
-            cmake_args += [
-                "-DBUILD_JPEG=OFF",
-                "-DJPEG_INCLUDE_DIR=%s" % os.environ['JPEG_INCLUDE_DIR'],
-                "-DJPEG_LIBRARY=%s" % os.environ['JPEG_LIBRARY']
-            ]
-
     # Fixes for macOS builds
     if sys.platform == 'darwin':
         cmake_args.append("-DWITH_LAPACK=OFF")  # Some OSX LAPACK fns are incompatible, see

From 9f1a4422141babc7bfa244e41cfcde081a4876bf Mon Sep 17 00:00:00 2001
From: native-api <vano@mail.mipt.ru>
Date: Sun, 18 Aug 2019 14:03:02 +0300
Subject: [PATCH 044/345] Use Travis workspaces (#228)

* Use one job for MacOS Homebrew builds cache with Travis workspaces

* Brew build job needs to both feed to other jobs and cache between builds

* Move Linux jobs to the Final stage

With only 1 OSX job in S1, the Linux part is now the critical path and holds the build time back
---
 .travis.yml | 190 +++++++++++++++++++++++-----------------------------
 1 file changed, 84 insertions(+), 106 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d1efa36a..e6213b1c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,11 +25,6 @@ git:
 # https://docs.travis-ci.com/user/caching
 cache:
   directories:
-    # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
-    - $HOME/Library/Caches/Homebrew
-    - /usr/local/Homebrew/
-    # used in OSX custom build script dealing with local bottle caching
-    - $HOME/local_bottle_metadata
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
 
@@ -43,222 +38,205 @@ matrix:
   fast_finish: true
   include:
 
+    - os: osx
+      osx_image: xcode8.3
+      stage: s1
+      workspaces:
+        create:
+          name: brew_cache
+          paths:
+            # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
+            - $HOME/Library/Caches/Homebrew
+            - /usr/local/Homebrew/
+            # used in OSX custom build script dealing with local bottle caching
+            - $HOME/local_bottle_metadata
+      #workspaces share within the same build, cache shares between builds
+      cache:
+        directories:
+          # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
+          - $HOME/.ccache
+          # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
+          - $HOME/Library/Caches/Homebrew
+          - /usr/local/Homebrew/
+          # used in OSX custom build script dealing with local bottle caching
+          - $HOME/local_bottle_metadata
+
     # default builds for MacOS
-    - &osx-10
+      #further jobs in the list will use the same stage until the next assignment
+    - stage: final
       os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-10
-      stage: s1
-    - &osx-30
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-30
-      stage: s1
-    - &osx-40
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-40
-      stage: s1
-    - &osx-50
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-50
-      stage: s1
-    - &osx-60
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-      stage: final
-    - <<: *osx-60
-      stage: s1
+      workspaces:
+        use: brew_cache
 
     # headless builds for MacOS
-    - &osx-70
-      os: osx
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-70
-      stage: s1
-    - &osx-80
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-80
-      stage: s1
-    - &osx-90
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-90
-      stage: s1
-    - &osx-100
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-100
-      stage: s1
-    - &osx-110
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-      stage: final
-    - <<: *osx-110
-      stage: s1
+      workspaces:
+        use: brew_cache
 
     # Contrib builds for MacOS
-    - &osx-120
-      os: osx
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-120
-      stage: s1
-    - &osx-130
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-130
-      stage: s1
-    - &osx-140
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-140
-      stage: s1
-    - &osx-150
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-      stage: final
-    - <<: *osx-150
-      stage: s1
-    - &osx-160
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-      stage: final
-    - <<: *osx-160
-      stage: s1
+      workspaces:
+        use: brew_cache
 
     # headless contrib builds for MacOS
-    - &osx-170
-      os: osx
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-170
-      stage: s1
-    - &osx-180
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.4
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-180
-      stage: s1
-    - &osx-190
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-190
-      stage: s1
-    - &osx-200
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-      stage: final
-    - <<: *osx-200
-      stage: s1
-    - &osx-210
-      os: osx
+      workspaces:
+        use: brew_cache
+    - os: osx
       osx_image: xcode8.3
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-      stage: final
-    - <<: *osx-210
-      stage: s1
+      workspaces:
+        use: brew_cache
 
     # default builds for Linux
     - os: linux
-      # the following jobs will use the same stage name by default
-      stage: s1
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0

From 3126712cc7a42e9e59d1d462109cd8d10451e058 Mon Sep 17 00:00:00 2001
From: native-api <vano@mail.mipt.ru>
Date: Tue, 20 Aug 2019 19:54:45 +0300
Subject: [PATCH 045/345] Don't build unused Qt features; use all cores (#236)

* Don't build unused Qt features; use all cores

* cmake does bootstrapping, too; comment unclear steps

* Use Docker comment syntax

* tab to space
---
 docker/Dockerfile_i686   | 140 +++++++++++++++++++++------------------
 docker/Dockerfile_x86_64 | 136 +++++++++++++++++++------------------
 2 files changed, 146 insertions(+), 130 deletions(-)

diff --git a/docker/Dockerfile_i686 b/docker/Dockerfile_i686
index 98d70324..cc97e661 100644
--- a/docker/Dockerfile_i686
+++ b/docker/Dockerfile_i686
@@ -1,30 +1,38 @@
 FROM quay.io/pypa/manylinux1_i686:latest
 
 RUN curl -O -L https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz && \
-	tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
-	cd qt-everywhere* && \
-	./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license && \
-	gmake -j5 && \
-	gmake install && \
-	cd .. && \
-	rm -rf qt-everywhere-opensource-src-4.8.7 && \
-	rm qt-everywhere-opensource-src-4.8.7.tar.gz
+    tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
+    cd qt-everywhere* && \
+    #configure does a bootstrap make under the hood
+    #manylinux1 is too old to have `nproc`
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    #OpenCV only links against QtCore, QtGui, QtTest
+    ./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license \
+    -no-sql-sqlite -no-qt3support -no-xmlpatterns -no-multimedia \
+    -no-webkit -no-script -no-declarative -no-dbus -make libs && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf qt-everywhere-opensource-src-4.8.7 && \
+    rm qt-everywhere-opensource-src-4.8.7.tar.gz
 
 ENV QTDIR /opt/Qt4.8.7
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
-	tar -xf cmake-3.9.0.tar.gz && \
-	cd cmake-3.9.0 && \
-    true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \
-         against the same newer OpenSSL as other source-built tools \
-         (1.0.2s as of this writing)' && \
-	yum -y install zlib-devel && \
-	./configure --system-curl && \
-	make -j4 && \
-	make install && \
-	cd .. && \
-	rm -rf cmake-3.9.0*
+    tar -xf cmake-3.9.0.tar.gz && \
+    cd cmake-3.9.0 && \
+    #manylinux1 provides curl-devel equivalent and libcurl statically linked
+    # against the same newer OpenSSL as other source-built tools
+    # (1.0.2s as of this writing)
+    yum -y install zlib-devel && \
+    #configure does a bootstrap make under the hood
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    ./configure --system-curl && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf cmake-3.9.0*
 
 # https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
 # manylinux provides the toolchain and git; we provide cmake
@@ -33,69 +41,69 @@ RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
 
 # Newer openssl configure requires newer perl
 RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
-	tar -xf perl-5.20.1.tar.gz && \
-	cd perl-5.20.1 && \
-	./Configure -des -Dprefix="$HOME/openssl_build" && \
-	true '#perl build scripts do much redundant work \
-	     if running "make install" separately' && \
-	make install -j4 && \
-	cd .. && \
-	rm -rf perl-5.20.1*
+    tar -xf perl-5.20.1.tar.gz && \
+    cd perl-5.20.1 && \
+    ./Configure -des -Dprefix="$HOME/openssl_build" && \
+    #perl build scripts do much redundant work
+    # if running "make install" separately
+    make install -j$(getconf _NPROCESSORS_ONLN) && \
+    cd .. && \
+    rm -rf perl-5.20.1*
 
 RUN 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 && \
-    true '#in i686, ./config detects x64 in i686 without linux32 \
-         when run from "docker build"' && \
-	PERL="$HOME/openssl_build/bin/perl" linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
-	make -j4 && \
-    true '#skip installing documentation' && \
-	make install_sw && \
+    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 && \
+    #in i686, ./config detects x64 in i686 container without linux32
+    # when run from "docker build"
+    PERL="$HOME/openssl_build/bin/perl" linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" 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.13.02/nasm-2.13.02.tar.bz2 && \
-	tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
-	./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
-	make -j4 && \
-	make install
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \
+    tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./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 -j4 && \
-	make install
+    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 -j4 && \
-	make install
+    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 -j4 && \
-	make install && \
-	echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
-	ldconfig && \
-	rm -rf ~/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
 
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
 
 RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
-	mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
+    mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
 
 #in i686, yum metadata ends up with slightly wrong timestamps
 #which inhibits its update
diff --git a/docker/Dockerfile_x86_64 b/docker/Dockerfile_x86_64
index 81b59974..f7b0b081 100644
--- a/docker/Dockerfile_x86_64
+++ b/docker/Dockerfile_x86_64
@@ -1,30 +1,38 @@
 FROM quay.io/pypa/manylinux1_x86_64:latest
 
 RUN curl -O -L https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz && \
-	tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
-	cd qt-everywhere* && \
-	./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license && \
-	gmake -j5 && \
-	gmake install && \
-	cd .. && \
-	rm -rf qt-everywhere-opensource-src-4.8.7 && \
-	rm qt-everywhere-opensource-src-4.8.7.tar.gz
+    tar -xf qt-everywhere-opensource-src-4.8.7.tar.gz && \
+    cd qt-everywhere* && \
+    #configure does a bootstrap make under the hood
+    #manylinux1 is too old to have `nproc`
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    #OpenCV only links against QtCore, QtGui, QtTest
+    ./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license \
+    -no-sql-sqlite -no-qt3support -no-xmlpatterns -no-multimedia \
+    -no-webkit -no-script -no-declarative -no-dbus -make libs && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf qt-everywhere-opensource-src-4.8.7 && \
+    rm qt-everywhere-opensource-src-4.8.7.tar.gz
 
 ENV QTDIR /opt/Qt4.8.7
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN curl -O -L https://cmake.org/files/v3.9/cmake-3.9.0.tar.gz && \
-	tar -xf cmake-3.9.0.tar.gz && \
-	cd cmake-3.9.0 && \
-    true '#manylinux1 provides curl-devel equivalent and libcurl statically linked \
-         against the same newer OpenSSL as other source-built tools \
-         (1.0.2s as of this writing)' && \
-	yum -y install zlib-devel && \
-	./configure --system-curl && \
-	make -j4 && \
-	make install && \
-	cd .. && \
-	rm -rf cmake-3.9.0*
+    tar -xf cmake-3.9.0.tar.gz && \
+    cd cmake-3.9.0 && \
+    #manylinux1 provides curl-devel equivalent and libcurl statically linked
+    # against the same newer OpenSSL as other source-built tools
+    # (1.0.2s as of this writing)
+    yum -y install zlib-devel && \
+    #configure does a bootstrap make under the hood
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    ./configure --system-curl && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf cmake-3.9.0*
 
 # https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#GettheDependencies
 # manylinux provides the toolchain and git; we provide cmake
@@ -33,66 +41,66 @@ RUN yum install freetype-devel bzip2-devel zlib-devel -y && \
 
 # Newer openssl configure requires newer perl
 RUN curl -O -L https://www.cpan.org/src/5.0/perl-5.20.1.tar.gz && \
-	tar -xf perl-5.20.1.tar.gz && \
-	cd perl-5.20.1 && \
-	./Configure -des -Dprefix="$HOME/openssl_build" && \
-	true '#perl build scripts do much redundant work \
-	     if running "make install" separately' && \
-	make install -j4 && \
-	cd .. && \
-	rm -rf perl-5.20.1*
+    tar -xf perl-5.20.1.tar.gz && \
+    cd perl-5.20.1 && \
+    ./Configure -des -Dprefix="$HOME/openssl_build" && \
+    #perl build scripts do much redundant work
+    # if running "make install" separately
+    make install -j$(getconf _NPROCESSORS_ONLN) && \
+    cd .. && \
+    rm -rf perl-5.20.1*
 
 RUN 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 && \
-	PERL="$HOME/openssl_build/bin/perl" ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
-	make -j4 && \
-    true '#skip installing documentation' && \
-	make install_sw && \
+    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 && \
+    PERL="$HOME/openssl_build/bin/perl" ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" 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.13.02/nasm-2.13.02.tar.bz2 && \
-	tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
-	./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
-	make -j4 && \
-	make install
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \
+    tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./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 -j4 && \
-	make install
+    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 -j4 && \
-	make install
+    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 -j4 && \
-	make install && \
-	echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
-	ldconfig && \
-	rm -rf ~/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
 
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
 
 RUN curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/videodev2.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
-	curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
-	mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-common.h && \
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/uapi/linux/v4l2-controls.h && \
+    curl -O https://raw.githubusercontent.com/torvalds/linux/v4.14/include/linux/compiler.h && \
+    mv videodev2.h v4l2-common.h v4l2-controls.h compiler.h /usr/include/linux
 
 ENV PATH "$HOME/bin:$PATH"

From 5582b2e178920743013f985fe97329a4cee9057e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 29 Aug 2019 20:23:47 +0300
Subject: [PATCH 046/345] i686 patchelf / auditwheel issue fix (revert back to
 full Qt build)

---
 docker/Dockerfile_i686 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/docker/Dockerfile_i686 b/docker/Dockerfile_i686
index cc97e661..d5b315a2 100644
--- a/docker/Dockerfile_i686
+++ b/docker/Dockerfile_i686
@@ -7,9 +7,7 @@ RUN curl -O -L https://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensou
     #manylinux1 is too old to have `nproc`
     export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
     #OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license \
-    -no-sql-sqlite -no-qt3support -no-xmlpatterns -no-multimedia \
-    -no-webkit -no-script -no-declarative -no-dbus -make libs && \
+    ./configure -prefix /opt/Qt4.8.7 -release -opensource -confirm-license -make && \
     make && \
     make install && \
     cd .. && \

From ca9a5273175315e6652a610b3572c3afd0321e18 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 5 Sep 2019 18:40:28 +0300
Subject: [PATCH 047/345] add note to the README about branches

---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 0db6eb08..8c2f9306 100644
--- a/README.md
+++ b/README.md
@@ -134,10 +134,12 @@ Linux and MacOS wheels ship with [Qt 4.8.7](http://doc.qt.io/qt-4.8/lgpl.html) l
 
 ### Releases
 
-A release is made and uploaded to PyPI when a new tag is pushed to master branch. These tags differentiate packages (this repo might have modifications but OpenCV version stays same) and should be incremented sequentially. In practice, release version numbers look like this:
+A release is made and uploaded to PyPI when a new tag is pushed to the repo. These tags differentiate packages (this repo might have modifications but OpenCV version stays same) and should be incremented sequentially. In practice, release version numbers look like this:
 
 ``cv_major.cv_minor.cv_revision.package_revision`` e.g. ``3.1.0.0``
 
+The master branch follows OpenCV master branch releases. 3.4 branch follows OpenCV 3.4 bugfix releases.
+
 ### Development builds
 
 Every commit to the master branch of this repo will be built. Possible build artifacts use local version identifiers:

From efb20ee3de71657726846360395278d7a90d0766 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 7 Sep 2019 14:57:20 +0300
Subject: [PATCH 048/345] add std=c++11

---
 setup.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/setup.py b/setup.py
index 9fb1e049..994b8198 100644
--- a/setup.py
+++ b/setup.py
@@ -102,7 +102,7 @@ def main():
         # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
         "-DPYTHON%d_EXECUTABLE=%s" % (sys.version_info[0], sys.executable),
         "-DBUILD_opencv_python%d=ON" % sys.version_info[0],
-        
+
         # 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.
@@ -111,7 +111,7 @@ def main():
         # 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",
@@ -137,8 +137,8 @@ def main():
     if sys.platform == 'darwin':
         cmake_args.append("-DWITH_LAPACK=OFF")  # Some OSX LAPACK fns are incompatible, see
                                                 # https://github.com/skvark/opencv-python/issues/21
-        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
-        cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7")
+        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11")
+        cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8")
 
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with
@@ -147,12 +147,12 @@ def main():
     if sys.platform.startswith('linux') and not x64:
         cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
 
-        
+
     if 'CMAKE_ARGS' in os.environ:
         import shlex
         cmake_args.extend(shlex.split(os.environ['CMAKE_ARGS']))
         del shlex
-        
+
     # ABI config variables are introduced in PEP 425
     if sys.version_info[:2] < (3, 2):
         import warnings

From 6093cc63cb65431e7d4d8f895dd7e73acd1e5d06 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 7 Sep 2019 16:38:49 +0300
Subject: [PATCH 049/345] remove flag

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 994b8198..e887c74d 100644
--- a/setup.py
+++ b/setup.py
@@ -137,7 +137,7 @@ def main():
     if sys.platform == 'darwin':
         cmake_args.append("-DWITH_LAPACK=OFF")  # Some OSX LAPACK fns are incompatible, see
                                                 # https://github.com/skvark/opencv-python/issues/21
-        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11")
+        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8")
 
     if sys.platform.startswith('linux'):

From 358097f6e188e4bd443f79ddc404a263300a05b7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 7 Sep 2019 19:30:06 +0300
Subject: [PATCH 050/345] try another flag

---
 setup.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/setup.py b/setup.py
index e887c74d..2e730bba 100644
--- a/setup.py
+++ b/setup.py
@@ -140,6 +140,10 @@ def main():
         cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8")
 
+    if sys.platform == 'darwin' and build_contrib:
+        # see: https://github.com/opencv/opencv_contrib/issues/1388#issuecomment-354403896
+        cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
+
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with
                                               # devtoolset-2 GCC 4.8.2 or vanilla GCC 4.9.4

From c966038b7247c7f47061717128ab41452ad468bf Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 9 Sep 2019 18:12:57 +0300
Subject: [PATCH 051/345] add -std=c++11

---
 setup.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 2e730bba..bf159995 100644
--- a/setup.py
+++ b/setup.py
@@ -141,8 +141,7 @@ def main():
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8")
 
     if sys.platform == 'darwin' and build_contrib:
-        # see: https://github.com/opencv/opencv_contrib/issues/1388#issuecomment-354403896
-        cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
+        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11")
 
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with

From 3fed34b192f7b3a557d3992d175144e39116957e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 9 Sep 2019 21:17:46 +0300
Subject: [PATCH 052/345] no narrowing

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index bf159995..4589bde8 100644
--- a/setup.py
+++ b/setup.py
@@ -141,7 +141,7 @@ def main():
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.8")
 
     if sys.platform == 'darwin' and build_contrib:
-        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11")
+        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11 -Wno-c++11-narrowing")
 
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with

From 91f64abd93611d48367f8c615f8a6f9bd8b954a8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 11 Sep 2019 17:15:54 +0300
Subject: [PATCH 053/345] bump OpenCV version

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index 33b765d7..4a7ca5a2 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 33b765d7979fd8a6038026aa44f6ff1a9c082b7b
+Subproject commit 4a7ca5a291038a773ea0b67eaf6fbed9ad72170b
diff --git a/opencv_contrib b/opencv_contrib
index f26c9836..6d656ca0 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit f26c98365da6af93cb5e49397b571190fca7bb55
+Subproject commit 6d656ca069afb3a3cb43a3484ee3a2d215982997

From 0d24dcca4a138f9f69aee0a5f8230153e3cc8918 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 23 Aug 2019 14:43:20 +0300
Subject: [PATCH 054/345] patch OpenEXR on 32-bit Linux

---
 patches/patchOpenEXR | 288 +++++++++++++++++++++++++++++++++++++++++++
 setup.py             |   2 +
 2 files changed, 290 insertions(+)
 create mode 100644 patches/patchOpenEXR

diff --git a/patches/patchOpenEXR b/patches/patchOpenEXR
new file mode 100644
index 00000000..52dba087
--- /dev/null
+++ b/patches/patchOpenEXR
@@ -0,0 +1,288 @@
+diff -ruN opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
+--- opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-22 20:02:54.769176800 +0300
++++ opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 14:31:17.103949100 +0300
+@@ -1,138 +1,146 @@
+-///////////////////////////////////////////////////////////////////////////
+-//
+-// Copyright (c) 2009-2014 DreamWorks Animation LLC. 
+-//
+-// All rights reserved.
+-//
+-// 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 name of DreamWorks Animation nor the names of
+-// its 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 THE COPYRIGHT
+-// OWNER 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.
+-//
+-///////////////////////////////////////////////////////////////////////////
+-
+-#include "ImfSimd.h"
+-#include "ImfSystemSpecific.h"
+-#include "ImfNamespace.h"
+-#include "OpenEXRConfig.h"
+-
+-OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
+-
+-namespace {
+-#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
+-
+-    // Helper functions for gcc + SSE enabled
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
+-    {
+-        __asm__ __volatile__ (
+-            "cpuid"
+-            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
+-            : /* Input   */ "a"(n)
+-            : /* Clobber */);
+-    }
+-
+-#else // IMF_HAVE_SSE2 && __GNUC__
+-
+-    // Helper functions for generic compiler - all disabled
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
+-    {
+-        eax = ebx = ecx = edx = 0;
+-    }
+-
+-#endif // IMF_HAVE_SSE2 && __GNUC__
+-
+-
+-#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+-
+-    void xgetbv(int n, int &eax, int &edx)
+-    {
+-        __asm__ __volatile__ (
+-            "xgetbv"
+-            : /* Output  */ "=a"(eax), "=d"(edx) 
+-            : /* Input   */ "c"(n)
+-            : /* Clobber */);
+-    }
+-
+-#else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+-
+-    void xgetbv(int n, int &eax, int &edx)
+-    {
+-        eax = edx = 0;
+-    }
+-
+-#endif //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+-
+-} // namespace 
+-
+-CpuId::CpuId():
+-    sse2(false), 
+-    sse3(false), 
+-    ssse3(false),
+-    sse4_1(false), 
+-    sse4_2(false), 
+-    avx(false), 
+-    f16c(false)
+-{
+-    bool osxsave = false;
+-    int  max     = 0;
+-    int  eax, ebx, ecx, edx;
+-
+-    cpuid(0, max, ebx, ecx, edx);
+-    if (max > 0)
+-    {
+-        cpuid(1, eax, ebx, ecx, edx);
+-        sse2    = ( edx & (1<<26) );
+-        sse3    = ( ecx & (1<< 0) );
+-        ssse3   = ( ecx & (1<< 9) );
+-        sse4_1  = ( ecx & (1<<19) );
+-        sse4_2  = ( ecx & (1<<20) );
+-        osxsave = ( ecx & (1<<27) );
+-        avx     = ( ecx & (1<<28) );
+-        f16c    = ( ecx & (1<<29) );
+-
+-        if (!osxsave)
+-        {
+-            avx = f16c = false;
+-        }
+-        else
+-        {
+-            xgetbv(0, eax, edx);
+-            // eax bit 1 - SSE managed, bit 2 - AVX managed
+-            if ((eax & 6) != 6)
+-            {
+-                avx = f16c = false;
+-            }
+-        }
+-    }
+-
+-#if defined(IMF_HAVE_SSE2) && defined(__ANDROID__)
+-    sse2 = true;
+-    sse3 = true;
+-#ifdef __x86_64__
+-    ssse3 = true;
+-    sse4_1 = true;
+-#endif
+-#endif
+-}
+-
+-OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
++///////////////////////////////////////////////////////////////////////////
++//
++// Copyright (c) 2009-2014 DreamWorks Animation LLC.
++//
++// All rights reserved.
++//
++// 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 name of DreamWorks Animation nor the names of
++// its 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 THE COPYRIGHT
++// OWNER 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.
++//
++///////////////////////////////////////////////////////////////////////////
++
++#include "ImfSimd.h"
++#include "ImfSystemSpecific.h"
++#include "ImfNamespace.h"
++#include "OpenEXRConfig.h"
++
++OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
++
++namespace {
++#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
++
++    // Helper functions for gcc + SSE enabled
++    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    {
++		#ifdef __i386__
++	        __asm__ __volatile__ (
++	            "pushl %%ebx; cpuid; movl %%ebx, %0; popl %%ebx"
++	            : /* Output  */ "=m"(ebx), "=a"(eax), "=c"(ecx), "=d"(edx)
++	            : /* Input   */ "a"(n)
++	            : /* Clobber */);
++		#else
++	         __asm__ __volatile__ (
++	             "cpuid"
++	             : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
++	             : /* Input   */ "a"(n)
++	             : /* Clobber */);
++		#endif
++    }
++
++#else // IMF_HAVE_SSE2 && __GNUC__
++
++    // Helper functions for generic compiler - all disabled
++    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    {
++        eax = ebx = ecx = edx = 0;
++    }
++
++#endif // IMF_HAVE_SSE2 && __GNUC__
++
++
++#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
++
++    void xgetbv(int n, int &eax, int &edx)
++    {
++        __asm__ __volatile__ (
++            "xgetbv"
++            : /* Output  */ "=a"(eax), "=d"(edx)
++            : /* Input   */ "c"(n)
++            : /* Clobber */);
++    }
++
++#else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
++
++    void xgetbv(int n, int &eax, int &edx)
++    {
++        eax = edx = 0;
++    }
++
++#endif //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
++
++} // namespace
++
++CpuId::CpuId():
++    sse2(false),
++    sse3(false),
++    ssse3(false),
++    sse4_1(false),
++    sse4_2(false),
++    avx(false),
++    f16c(false)
++{
++    bool osxsave = false;
++    int  max     = 0;
++    int  eax, ebx, ecx, edx;
++
++    cpuid(0, max, ebx, ecx, edx);
++    if (max > 0)
++    {
++        cpuid(1, eax, ebx, ecx, edx);
++        sse2    = ( edx & (1<<26) );
++        sse3    = ( ecx & (1<< 0) );
++        ssse3   = ( ecx & (1<< 9) );
++        sse4_1  = ( ecx & (1<<19) );
++        sse4_2  = ( ecx & (1<<20) );
++        osxsave = ( ecx & (1<<27) );
++        avx     = ( ecx & (1<<28) );
++        f16c    = ( ecx & (1<<29) );
++
++        if (!osxsave)
++        {
++            avx = f16c = false;
++        }
++        else
++        {
++            xgetbv(0, eax, edx);
++            // eax bit 1 - SSE managed, bit 2 - AVX managed
++            if ((eax & 6) != 6)
++            {
++                avx = f16c = false;
++            }
++        }
++    }
++
++#if defined(IMF_HAVE_SSE2) && defined(__ANDROID__)
++    sse2 = true;
++    sse3 = true;
++#ifdef __x86_64__
++    ssse3 = true;
++    sse4_1 = true;
++#endif
++#endif
++}
++
++OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
diff --git a/setup.py b/setup.py
index 4589bde8..f6684f91 100644
--- a/setup.py
+++ b/setup.py
@@ -149,6 +149,8 @@ def main():
                                               # see https://github.com/skvark/opencv-python/issues/138
     if sys.platform.startswith('linux') and not x64:
         cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
+        # patch openEXR when building on i386, see: https://github.com/openexr/openexr/issues/128
+        subprocess.check_call(["patch", "-p0", "<", "patches/patchOpenEXR"])
 
 
     if 'CMAKE_ARGS' in os.environ:

From c36d98e09e3c89d44ab30543fba7d3ad0744f465 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 23 Aug 2019 08:20:11 -0400
Subject: [PATCH 055/345] fix patch file

---
 patches/patchOpenEXR | 304 ++++---------------------------------------
 1 file changed, 22 insertions(+), 282 deletions(-)

diff --git a/patches/patchOpenEXR b/patches/patchOpenEXR
index 52dba087..6633e844 100644
--- a/patches/patchOpenEXR
+++ b/patches/patchOpenEXR
@@ -1,288 +1,28 @@
 diff -ruN opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
---- opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-22 20:02:54.769176800 +0300
-+++ opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 14:31:17.103949100 +0300
-@@ -1,138 +1,146 @@
--///////////////////////////////////////////////////////////////////////////
--//
--// Copyright (c) 2009-2014 DreamWorks Animation LLC. 
--//
--// All rights reserved.
--//
--// 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 name of DreamWorks Animation nor the names of
--// its 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 THE COPYRIGHT
--// OWNER 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.
--//
--///////////////////////////////////////////////////////////////////////////
--
--#include "ImfSimd.h"
--#include "ImfSystemSpecific.h"
--#include "ImfNamespace.h"
--#include "OpenEXRConfig.h"
--
--OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
--
--namespace {
--#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
--
--    // Helper functions for gcc + SSE enabled
--    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
--    {
+--- opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 08:11:43.536117200 -0400
++++ opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 08:16:58.337879800 -0400
+@@ -44,11 +44,19 @@
+     // Helper functions for gcc + SSE enabled
+     void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
+     {
 -        __asm__ __volatile__ (
 -            "cpuid"
 -            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
 -            : /* Input   */ "a"(n)
 -            : /* Clobber */);
--    }
--
--#else // IMF_HAVE_SSE2 && __GNUC__
--
--    // Helper functions for generic compiler - all disabled
--    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
--    {
--        eax = ebx = ecx = edx = 0;
--    }
--
--#endif // IMF_HAVE_SSE2 && __GNUC__
--
--
--#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
--
--    void xgetbv(int n, int &eax, int &edx)
--    {
--        __asm__ __volatile__ (
--            "xgetbv"
--            : /* Output  */ "=a"(eax), "=d"(edx) 
--            : /* Input   */ "c"(n)
--            : /* Clobber */);
--    }
--
--#else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
--
--    void xgetbv(int n, int &eax, int &edx)
--    {
--        eax = edx = 0;
--    }
--
--#endif //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
--
--} // namespace 
--
--CpuId::CpuId():
--    sse2(false), 
--    sse3(false), 
--    ssse3(false),
--    sse4_1(false), 
--    sse4_2(false), 
--    avx(false), 
--    f16c(false)
--{
--    bool osxsave = false;
--    int  max     = 0;
--    int  eax, ebx, ecx, edx;
--
--    cpuid(0, max, ebx, ecx, edx);
--    if (max > 0)
--    {
--        cpuid(1, eax, ebx, ecx, edx);
--        sse2    = ( edx & (1<<26) );
--        sse3    = ( ecx & (1<< 0) );
--        ssse3   = ( ecx & (1<< 9) );
--        sse4_1  = ( ecx & (1<<19) );
--        sse4_2  = ( ecx & (1<<20) );
--        osxsave = ( ecx & (1<<27) );
--        avx     = ( ecx & (1<<28) );
--        f16c    = ( ecx & (1<<29) );
--
--        if (!osxsave)
--        {
--            avx = f16c = false;
--        }
--        else
--        {
--            xgetbv(0, eax, edx);
--            // eax bit 1 - SSE managed, bit 2 - AVX managed
--            if ((eax & 6) != 6)
--            {
--                avx = f16c = false;
--            }
--        }
--    }
--
--#if defined(IMF_HAVE_SSE2) && defined(__ANDROID__)
--    sse2 = true;
--    sse3 = true;
--#ifdef __x86_64__
--    ssse3 = true;
--    sse4_1 = true;
--#endif
--#endif
--}
--
--OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
-+///////////////////////////////////////////////////////////////////////////
-+//
-+// Copyright (c) 2009-2014 DreamWorks Animation LLC.
-+//
-+// All rights reserved.
-+//
-+// 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 name of DreamWorks Animation nor the names of
-+// its 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 THE COPYRIGHT
-+// OWNER 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.
-+//
-+///////////////////////////////////////////////////////////////////////////
-+
-+#include "ImfSimd.h"
-+#include "ImfSystemSpecific.h"
-+#include "ImfNamespace.h"
-+#include "OpenEXRConfig.h"
-+
-+OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
-+
-+namespace {
-+#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
-+
-+    // Helper functions for gcc + SSE enabled
-+    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
-+    {
-+		#ifdef __i386__
-+	        __asm__ __volatile__ (
-+	            "pushl %%ebx; cpuid; movl %%ebx, %0; popl %%ebx"
-+	            : /* Output  */ "=m"(ebx), "=a"(eax), "=c"(ecx), "=d"(edx)
-+	            : /* Input   */ "a"(n)
-+	            : /* Clobber */);
-+		#else
-+	         __asm__ __volatile__ (
-+	             "cpuid"
-+	             : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
-+	             : /* Input   */ "a"(n)
-+	             : /* Clobber */);
-+		#endif
-+    }
-+
-+#else // IMF_HAVE_SSE2 && __GNUC__
-+
-+    // Helper functions for generic compiler - all disabled
-+    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
-+    {
-+        eax = ebx = ecx = edx = 0;
-+    }
-+
-+#endif // IMF_HAVE_SSE2 && __GNUC__
-+
-+
-+#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-+
-+    void xgetbv(int n, int &eax, int &edx)
-+    {
-+        __asm__ __volatile__ (
-+            "xgetbv"
-+            : /* Output  */ "=a"(eax), "=d"(edx)
-+            : /* Input   */ "c"(n)
-+            : /* Clobber */);
-+    }
-+
-+#else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-+
-+    void xgetbv(int n, int &eax, int &edx)
-+    {
-+        eax = edx = 0;
-+    }
-+
-+#endif //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-+
-+} // namespace
-+
-+CpuId::CpuId():
-+    sse2(false),
-+    sse3(false),
-+    ssse3(false),
-+    sse4_1(false),
-+    sse4_2(false),
-+    avx(false),
-+    f16c(false)
-+{
-+    bool osxsave = false;
-+    int  max     = 0;
-+    int  eax, ebx, ecx, edx;
-+
-+    cpuid(0, max, ebx, ecx, edx);
-+    if (max > 0)
-+    {
-+        cpuid(1, eax, ebx, ecx, edx);
-+        sse2    = ( edx & (1<<26) );
-+        sse3    = ( ecx & (1<< 0) );
-+        ssse3   = ( ecx & (1<< 9) );
-+        sse4_1  = ( ecx & (1<<19) );
-+        sse4_2  = ( ecx & (1<<20) );
-+        osxsave = ( ecx & (1<<27) );
-+        avx     = ( ecx & (1<<28) );
-+        f16c    = ( ecx & (1<<29) );
-+
-+        if (!osxsave)
-+        {
-+            avx = f16c = false;
-+        }
-+        else
-+        {
-+            xgetbv(0, eax, edx);
-+            // eax bit 1 - SSE managed, bit 2 - AVX managed
-+            if ((eax & 6) != 6)
-+            {
-+                avx = f16c = false;
-+            }
-+        }
-+    }
-+
-+#if defined(IMF_HAVE_SSE2) && defined(__ANDROID__)
-+    sse2 = true;
-+    sse3 = true;
-+#ifdef __x86_64__
-+    ssse3 = true;
-+    sse4_1 = true;
-+#endif
-+#endif
-+}
-+
-+OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
++        #ifdef __i386__
++            __asm__ __volatile__ (
++                "pushl %%ebx; cpuid; movl %%ebx, %0; popl %%ebx"
++                : /* Output  */ "=m"(ebx), "=a"(eax), "=c"(ecx), "=d"(edx) 
++                : /* Input   */ "a"(n)
++                : /* Clobber */);
++        #else
++            __asm__ __volatile__ (
++                "cpuid"
++                : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
++                : /* Input   */ "a"(n)
++                : /* Clobber */);
++        #endif
+     }
+ 
+ #else // IMF_HAVE_SSE2 && __GNUC__

From 45a77d6c6e24519de68e08f71742f078526623c4 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 25 Aug 2019 15:57:26 +0300
Subject: [PATCH 056/345] fix subprocess call

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index f6684f91..5f67e56b 100644
--- a/setup.py
+++ b/setup.py
@@ -150,7 +150,7 @@ def main():
     if sys.platform.startswith('linux') and not x64:
         cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
         # patch openEXR when building on i386, see: https://github.com/openexr/openexr/issues/128
-        subprocess.check_call(["patch", "-p0", "<", "patches/patchOpenEXR"])
+        subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
 
     if 'CMAKE_ARGS' in os.environ:

From 22e5ae842115a00a2f8a4d34b82c6f8eb767433f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 25 Aug 2019 10:55:31 -0400
Subject: [PATCH 057/345] fix patch

---
 patches/patchOpenEXR | 66 ++++++++++++++++++++++++++++++++------------
 1 file changed, 49 insertions(+), 17 deletions(-)

diff --git a/patches/patchOpenEXR b/patches/patchOpenEXR
index 6633e844..e2a1ffc7 100644
--- a/patches/patchOpenEXR
+++ b/patches/patchOpenEXR
@@ -1,28 +1,60 @@
 diff -ruN opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
---- opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 08:11:43.536117200 -0400
-+++ opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-23 08:16:58.337879800 -0400
-@@ -44,11 +44,19 @@
+--- opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-25 10:40:57.596395000 -0400
++++ opencv_patched/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp	2019-08-25 10:53:15.331689900 -0400
+@@ -40,21 +40,19 @@
+ 
+ namespace {
+ #if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
+-
++#include <cpuid.h>
      // Helper functions for gcc + SSE enabled
-     void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
++					unsigned int &ecx, unsigned int &edx)
      {
 -        __asm__ __volatile__ (
 -            "cpuid"
 -            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
 -            : /* Input   */ "a"(n)
 -            : /* Clobber */);
-+        #ifdef __i386__
-+            __asm__ __volatile__ (
-+                "pushl %%ebx; cpuid; movl %%ebx, %0; popl %%ebx"
-+                : /* Output  */ "=m"(ebx), "=a"(eax), "=c"(ecx), "=d"(edx) 
-+                : /* Input   */ "a"(n)
-+                : /* Clobber */);
-+        #else
-+            __asm__ __volatile__ (
-+                "cpuid"
-+                : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
-+                : /* Input   */ "a"(n)
-+                : /* Clobber */);
-+        #endif
++        __get_cpuid(n, &eax, &ebx, &ecx, &edx);
      }
  
  #else // IMF_HAVE_SSE2 && __GNUC__
+ 
+     // Helper functions for generic compiler - all disabled
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
++					unsigned int &ecx, unsigned int &edx)
+     {
+         eax = ebx = ecx = edx = 0;
+     }
+@@ -64,7 +62,7 @@
+ 
+ #ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+ 
+-    void xgetbv(int n, int &eax, int &edx)
++    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
+     {
+         __asm__ __volatile__ (
+             "xgetbv"
+@@ -75,7 +73,7 @@
+ 
+ #else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+ 
+-    void xgetbv(int n, int &eax, int &edx)
++    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
+     {
+         eax = edx = 0;
+     }
+@@ -94,8 +92,8 @@
+     f16c(false)
+ {
+     bool osxsave = false;
+-    int  max     = 0;
+-    int  eax, ebx, ecx, edx;
++    unsigned int  max     = 0;
++    unsigned int  eax, ebx, ecx, edx;
+ 
+     cpuid(0, max, ebx, ecx, edx);
+     if (max > 0)

From 59243695afc3ad161cd5ce9bc1d753f88cb4d19d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 19 Nov 2019 17:56:38 +0200
Subject: [PATCH 058/345] OpenCV 3.4.8

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index ddbd10c0..6bdb9ca7 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit ddbd10c0019f3ee5f43b7902d47e7fc4303a6574
+Subproject commit 6bdb9ca725de52ada2b452699fbbd39d8ef41188
diff --git a/opencv_contrib b/opencv_contrib
index 0915b7ea..9d3efbd8 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 0915b7eaddba3c06d83e201c9a7595e73801f417
+Subproject commit 9d3efbd8f159f04fdb4e1d05693c922b5f06b1d7

From 9fc0c169344018e99f4b3e044c1461aaf079d09e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 19 Nov 2019 18:24:44 +0200
Subject: [PATCH 059/345] revert ffmpeg binary search path

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index e45eee5a..cac1456b 100644
--- a/setup.py
+++ b/setup.py
@@ -78,7 +78,7 @@ def main():
     # 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 []) +
+        'cv2': ([r'bin/opencv_ffmpeg\d{3}%s\.dll' % ('_64' if x64 else '')] if os.name == 'nt' else []) +
         # In Windows, in python/X.Y/<arch>/; in Linux, in just python/X.Y/.
         # Naming conventions vary so widely between versions and OSes
         # had to give up on checking them.

From 32ce23ec0f971db4b88cbeff837e2e57000817b2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 19 Nov 2019 19:28:28 +0200
Subject: [PATCH 060/345] fix data search path

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index cac1456b..24666ab0 100644
--- a/setup.py
+++ b/setup.py
@@ -85,7 +85,7 @@ def main():
         ['python/cv2[^/]*%(ext)s' % {'ext': re.escape(sysconfig.get_config_var('SO'))}],
 
         'cv2.data': [  # OPENCV_OTHER_INSTALL_PATH
-            ('etc' if os.name == 'nt' else 'share/opencv4') +
+            ('etc' if os.name == 'nt' else 'share/OpenCV') +
             r'/haarcascades/.*\.xml'
         ]
     }

From aec30500ac592fdfb24ac1547731f0fa91d1e04f Mon Sep 17 00:00:00 2001
From: Mateusz Bysiek <mateusz.bysiek@gmail.com>
Date: Sat, 7 Dec 2019 14:31:05 +0900
Subject: [PATCH 061/345] don't use deprecated brew tap-pin

instead refer to the full package name when installing

fixes https://github.com/skvark/opencv-python/issues/266

context:
https://brew.sh/2019/04/04/homebrew-2.1.0/
https://github.com/Homebrew/brew/pull/5925
---
 travis_config.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index f79883f1..526d7180 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -98,11 +98,10 @@ function pre_build {
 
     echo 'Installing QT4'
     brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
-    brew tap --list-pinned | grep -qxF cartr/qt4 || brew tap-pin cartr/qt4
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
+        brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        brew install qt@4
+        brew install cartr/qt4/qt@4
     fi
 
     echo 'Installing FFmpeg'

From 89d683499f4822a71acc47e6d89c77c1ff09fae4 Mon Sep 17 00:00:00 2001
From: Pascal Chambon <pythoniks@gmail.com>
Date: Fri, 22 Nov 2019 17:07:12 +0100
Subject: [PATCH 062/345] add workaround for DLL errors in Windows Server.

---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 12222ab5..40326573 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,8 @@ A: If the import fails on Windows, make sure you have [Visual C++ redistributabl
 
 Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also [Windows Media Feature Pack](https://support.microsoft.com/en-us/help/3145500/media-feature-pack-list-for-windows-n-editions).
 
+If you have Windows Server 2012+, media DLLs are probably missing too; please install the Feature called "Media Foundation" in the Server Manager. Beware, some posts advise to install "Windows Server Essentials Media Pack", but this one requires the "Windows Server Essentials Experience" role, and this role will deeply affect your Windows Server configuration (by enforcing active directory integration etc.); so just installing the "Media Foundation" should be a safer choice.
+
 If the above does not help, check if you are using Anaconda. Old Anaconda versions have a bug which causes the error, see [this issue](https://github.com/skvark/opencv-python/issues/36) for a manual fix.
 
 If you still encounter the error after you have checked all the previous solutions, download [Dependencies](https://github.com/lucasg/Dependencies) and open the ``cv2.pyd`` (located usually at ``C:\Users\username\AppData\Local\Programs\Python\PythonXX\Lib\site-packages\cv2``) file with it to debug missing DLL issues.

From 3848ecfb208ae7d19675fdcd9f0d16efec0cf49b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E5=BB=BA=E5=86=9B?= <wjjn3033@corp.netease.com>
Date: Fri, 27 Dec 2019 16:29:51 +0800
Subject: [PATCH 063/345] fix: give up get_config_var() and use
 get_config_vars() instead.

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 24666ab0..2cce857e 100644
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,7 @@ def main():
 
     package_data = {
         'cv2':
-            ['*%s' % sysconfig.get_config_var('SO')] +
+            ['*%s' % sysconfig.get_config_vars().get('SO')] +
             (['*.dll'] if os.name == 'nt' else []) +
             ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"],
         'cv2.data':

From cde3c56bb0ce65a2c73ea833ba5b3b88f2e3188f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 9 Jan 2020 19:45:41 +0200
Subject: [PATCH 064/345] update dockerfiles

---
 docker/Dockerfile_i686   | 4 ++--
 docker/Dockerfile_x86_64 | 4 ++--
 docker/README.md         | 6 ++----
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/docker/Dockerfile_i686 b/docker/Dockerfile_i686
index d5b315a2..cffc998c 100644
--- a/docker/Dockerfile_i686
+++ b/docker/Dockerfile_i686
@@ -61,8 +61,8 @@ RUN cd ~/ffmpeg_sources && \
     rm -rf ~/openssl_build
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \
-    tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
+    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
diff --git a/docker/Dockerfile_x86_64 b/docker/Dockerfile_x86_64
index f7b0b081..c4d47bc7 100644
--- a/docker/Dockerfile_x86_64
+++ b/docker/Dockerfile_x86_64
@@ -61,8 +61,8 @@ RUN cd ~/ffmpeg_sources && \
     rm -rf ~/openssl_build
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2 && \
-    tar -xf nasm-2.13.02.tar.bz2 && cd nasm-2.13.02 && ./autogen.sh && \
+    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
diff --git a/docker/README.md b/docker/README.md
index e31d7a07..4ac6033c 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -2,13 +2,11 @@
 
 This folder includes Dockerfiles for extending both ``i686`` and ``x86_64`` manylinux images.
 
-The extended images were created to be able to build OpenCV in reasonable time with Travis.
-
-These images have been built locally because the process takes over 1,5 hours with modern i7 processor. The images are hosted at https://quay.io/user/skvark.
+The extended images were created to be able to build OpenCV in reasonable time with Travis. The images are hosted at https://quay.io/user/skvark.
 
 The images have following extra software installed:
 
 - Qt 4.8.7
 - Cmake 3.9.0
-- FFmpeg with libvpx (latest snapshots at the build time) and recent openssl
+- FFmpeg with libvpx (latest snapshots at the build time) and recent openssl + other FFmpeg dependencies built from sources
 - Some missing headers included from more recent Linux to be able to enable V4L / V4L2 support in OpenCV
\ No newline at end of file

From cd5aa672c399081ba0880ffe7d30fb73ebf65bf9 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 9 Jan 2020 21:35:13 +0200
Subject: [PATCH 065/345] OpenCV 3.4.9

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index 6bdb9ca7..64e6cf9f 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 6bdb9ca725de52ada2b452699fbbd39d8ef41188
+Subproject commit 64e6cf9fe50ef25d317d3529a42d4862b93f002a
diff --git a/opencv_contrib b/opencv_contrib
index 9d3efbd8..91b39aa0 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 9d3efbd8f159f04fdb4e1d05693c922b5f06b1d7
+Subproject commit 91b39aa038600425038df6722a5b4d1b5d7b5ca6

From 5d4357b6719c5a370c3444b216fbbf980d661686 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 11 Jan 2020 14:41:54 +0200
Subject: [PATCH 066/345] try to fix macos builds

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 526d7180..a2bd4d44 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,6 +101,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
+        # Added due to: Error: openssl@1.0 is already installed from homebrew/core! Please `brew uninstall openssl@1.0` first."
+        brew uninstall openssl@1.0
         brew install cartr/qt4/qt@4
     fi
 
@@ -119,7 +121,7 @@ function pre_build {
 
     # Have to install macpython late to avoid conflict with Homebrew Python update
     before_install
-    
+
   else
     echo "Running for linux"
   fi

From 7abef67bbc857f8ec84ccecf3d721cc58f1d2d9f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 11 Jan 2020 15:49:16 +0200
Subject: [PATCH 067/345] Revert "try to fix macos builds"

This reverts commit 5d4357b6719c5a370c3444b216fbbf980d661686.
---
 travis_config.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index a2bd4d44..526d7180 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,8 +101,6 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        # Added due to: Error: openssl@1.0 is already installed from homebrew/core! Please `brew uninstall openssl@1.0` first."
-        brew uninstall openssl@1.0
         brew install cartr/qt4/qt@4
     fi
 
@@ -121,7 +119,7 @@ function pre_build {
 
     # Have to install macpython late to avoid conflict with Homebrew Python update
     before_install
-
+    
   else
     echo "Running for linux"
   fi

From cc739293cc43f857cd3938a54b8ff5c4360d89f3 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 11 Jan 2020 16:40:16 +0200
Subject: [PATCH 068/345] try to repair

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 526d7180..f2d885b1 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,6 +101,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
+        brew tap --repair
+        brew audit cartr/qt4/qt@4
         brew install cartr/qt4/qt@4
     fi
 
@@ -119,7 +121,7 @@ function pre_build {
 
     # Have to install macpython late to avoid conflict with Homebrew Python update
     before_install
-    
+
   else
     echo "Running for linux"
   fi

From 37ef0d5a4ddae8aa4c6ad8fdbc7ea457294f3271 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 11 Jan 2020 17:06:42 +0200
Subject: [PATCH 069/345] remove audit

---
 travis_config.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index f2d885b1..f7c773b9 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -102,7 +102,6 @@ function pre_build {
         brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew tap --repair
-        brew audit cartr/qt4/qt@4
         brew install cartr/qt4/qt@4
     fi
 

From fbcfa54625998b8d7418e68e4fdde305a946245d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jan 2020 17:51:17 +0200
Subject: [PATCH 070/345] switch to Qt5

---
 setup.py         | 5 ++++-
 travis_config.sh | 8 +++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/setup.py b/setup.py
index 2cce857e..779ea233 100644
--- a/setup.py
+++ b/setup.py
@@ -123,9 +123,12 @@ def main():
     ] + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else [])
 
     # OS-specific components
-    if (sys.platform == 'darwin' or sys.platform.startswith('linux')) and not build_headless:
+    if sys.platform.startswith('linux') and not build_headless:
         cmake_args.append("-DWITH_QT=4")
 
+    if sys.platform == 'darwin' and not build_headless:
+        cmake_args.append("-DWITH_QT=5")
+
     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")
diff --git a/travis_config.sh b/travis_config.sh
index f7c773b9..3db6e4e5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -96,13 +96,11 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    echo 'Installing QT4'
-    brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
+    echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
+        brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        brew tap --repair
-        brew install cartr/qt4/qt@4
+        brew install qt5
     fi
 
     echo 'Installing FFmpeg'

From 8a6e17eac33130a0f2c8e41abbc53dfe1c827b0b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jan 2020 19:14:31 +0200
Subject: [PATCH 071/345] Revert "switch to Qt5"

This reverts commit fbcfa54625998b8d7418e68e4fdde305a946245d.
---
 setup.py         | 5 +----
 travis_config.sh | 8 +++++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/setup.py b/setup.py
index 779ea233..2cce857e 100644
--- a/setup.py
+++ b/setup.py
@@ -123,12 +123,9 @@ def main():
     ] + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else [])
 
     # OS-specific components
-    if sys.platform.startswith('linux') and not build_headless:
+    if (sys.platform == 'darwin' or sys.platform.startswith('linux')) and not build_headless:
         cmake_args.append("-DWITH_QT=4")
 
-    if sys.platform == 'darwin' and not build_headless:
-        cmake_args.append("-DWITH_QT=5")
-
     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")
diff --git a/travis_config.sh b/travis_config.sh
index 3db6e4e5..f7c773b9 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -96,11 +96,13 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    echo 'Installing qt5'
+    echo 'Installing QT4'
+    brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
+        brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        brew install qt5
+        brew tap --repair
+        brew install cartr/qt4/qt@4
     fi
 
     echo 'Installing FFmpeg'

From 6d91fc217fa44ba57b76cb92025ddb120d74c1d2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jan 2020 19:15:56 +0200
Subject: [PATCH 072/345] try again with qt4

---
 travis_config.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index f7c773b9..36ca29aa 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,7 +101,6 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        brew tap --repair
         brew install cartr/qt4/qt@4
     fi
 

From a7991d7dd5a9be8e3e2a493fd0c461d7b6731f62 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 16 Jan 2020 17:16:34 +0200
Subject: [PATCH 073/345] upgrade macOS env to xcode9.4 and use Qt5

---
 .travis.yml      | 42 +++++++++++++++++++++---------------------
 setup.py         |  5 ++++-
 travis_config.sh |  7 +++----
 3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d5f56edd..92165672 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,7 +38,7 @@ matrix:
   include:
 
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       stage: s1
       workspaces:
         create:
@@ -64,7 +64,7 @@ matrix:
       #further jobs in the list will use the same stage until the next assignment
     - stage: final
       os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -72,7 +72,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -80,7 +80,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -88,7 +88,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -97,7 +97,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=0
@@ -108,7 +108,7 @@ matrix:
 
     # headless builds for MacOS
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=0
@@ -116,7 +116,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -124,7 +124,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -132,7 +132,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -141,7 +141,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=0
@@ -152,7 +152,7 @@ matrix:
 
     # Contrib builds for MacOS
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -160,7 +160,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -168,7 +168,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -176,7 +176,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -185,7 +185,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=1
@@ -196,7 +196,7 @@ matrix:
 
     # headless contrib builds for MacOS
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=2.7
         - ENABLE_CONTRIB=1
@@ -204,7 +204,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -212,7 +212,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=1
@@ -220,7 +220,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=1
@@ -229,7 +229,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
-      osx_image: xcode8.3
+      osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=1
diff --git a/setup.py b/setup.py
index 2cce857e..779ea233 100644
--- a/setup.py
+++ b/setup.py
@@ -123,9 +123,12 @@ def main():
     ] + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else [])
 
     # OS-specific components
-    if (sys.platform == 'darwin' or sys.platform.startswith('linux')) and not build_headless:
+    if sys.platform.startswith('linux') and not build_headless:
         cmake_args.append("-DWITH_QT=4")
 
+    if sys.platform == 'darwin' and not build_headless:
+        cmake_args.append("-DWITH_QT=5")
+
     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")
diff --git a/travis_config.sh b/travis_config.sh
index 36ca29aa..3db6e4e5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -96,12 +96,11 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    echo 'Installing QT4'
-    brew tap | grep -qxF cartr/qt4 || brew tap cartr/qt4
+    echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit cartr/qt4/qt@4 || { [ $? -gt 1 ] && return 2 || return 0; }
+        brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
-        brew install cartr/qt4/qt@4
+        brew install qt5
     fi
 
     echo 'Installing FFmpeg'

From f92b787105f5b9c7787d3562484ba061e8fda18a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 16 Jan 2020 18:19:56 +0200
Subject: [PATCH 074/345] update multibuild

---
 multibuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multibuild b/multibuild
index 68a4af04..24d35a4a 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit 68a4af043e2adb0d9353d4a0e1f3d871203237aa
+Subproject commit 24d35a4af2583473a0ec224dbe1990dd1e0ace5d

From 932c024377bef7957e5e3ff0937fad27cfb7dc5f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 21 Jan 2020 16:19:04 +0200
Subject: [PATCH 075/345] unlink python2

---
 travis_config.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/travis_config.sh b/travis_config.sh
index 3db6e4e5..a3fa30d6 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -108,6 +108,7 @@ function pre_build {
     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 ffmpeg_opencv
     fi
 

From 64a747aeee7cecff16b90d4850b5b46f6486290d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 21 Jan 2020 17:23:49 +0200
Subject: [PATCH 076/345] link qt5

---
 travis_config.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/travis_config.sh b/travis_config.sh
index a3fa30d6..eeb58f10 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,6 +101,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew install qt5
+        brew link qt5 --force
     fi
 
     echo 'Installing FFmpeg'

From f62aef6028cec7bd03ae6eaa880881e5d7d46578 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 1 Feb 2020 13:54:06 +0200
Subject: [PATCH 077/345] try just exporting to the path

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index eeb58f10..27875867 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,7 +101,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew install qt5
-        brew link qt5 --force
+        export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 
     echo 'Installing FFmpeg'

From a7e34e9cff72bb9b4ccb2dae604e62e3a6261863 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 1 Feb 2020 14:25:11 +0200
Subject: [PATCH 078/345] update multibuild

---
 multibuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multibuild b/multibuild
index 24d35a4a..6b0ddb52 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit 24d35a4af2583473a0ec224dbe1990dd1e0ace5d
+Subproject commit 6b0ddb5281f59d976c8026c082c9d73faf274790

From 2801a962a667e049f62d6f46d70bbf4bd9de42ab Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Mar 2020 13:55:24 +0200
Subject: [PATCH 079/345] merge changes from master, update licenses

---
 .gitignore             |   1 +
 .travis.yml            | 302 ++++++++++++++++++-----------------------
 LICENSE-3RD-PARTY.txt  | 174 +++++++++++++++++++++++-
 LICENSE.txt            |   2 +-
 README.md              |   7 +-
 cv2/__init__.py        |   7 +
 patches/patchQtPlugins |  12 ++
 setup.py               |   4 +-
 8 files changed, 329 insertions(+), 180 deletions(-)
 create mode 100644 patches/patchQtPlugins

diff --git a/.gitignore b/.gitignore
index 87caa5f8..0367e1b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,3 +67,4 @@ target/
 # Build temporary files
 /contrib.enabled
 /cv_version.py
+_skbuild/
diff --git a/.travis.yml b/.travis.yml
index 92165672..75801595 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,13 +8,6 @@ env:
         - CONFIG_PATH="travis_config.sh"
         - USE_CCACHE=1
         - UNICODE_WIDTH=32
-        - MB_PYTHON_VERSION=3.7
-
-# Host Python is never used
-language: generic
-services: docker
-# https://docs.travis-ci.com/user/reference/xenial
-dist: xenial
 
 # Save some time, we and setup check them out on demand instead
 # https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth
@@ -33,11 +26,15 @@ stages:
   - s1
   - final
 
-matrix:
+jobs:
   fast_finish: true
+  exclude:
+    - language: ruby
   include:
-
     - os: osx
+      env:
+        - MB_PYTHON_VERSION=3.8
+      language: generic
       osx_image: xcode9.4
       stage: s1
       workspaces:
@@ -63,15 +60,8 @@ matrix:
     # default builds for MacOS
       #further jobs in the list will use the same stage until the next assignment
     - stage: final
-      os: osx
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      workspaces:
-        use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
@@ -80,6 +70,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
@@ -88,6 +79,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
@@ -97,6 +89,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
@@ -108,14 +101,7 @@ matrix:
 
     # headless builds for MacOS
     - os: osx
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
-    - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
@@ -124,6 +110,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
@@ -132,6 +119,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
@@ -141,6 +129,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
@@ -152,14 +141,7 @@ matrix:
 
     # Contrib builds for MacOS
     - os: osx
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      workspaces:
-        use: brew_cache
-    - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
@@ -168,6 +150,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
@@ -176,6 +159,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
@@ -185,6 +169,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
@@ -196,14 +181,7 @@ matrix:
 
     # headless contrib builds for MacOS
     - os: osx
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
-    - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.5
@@ -212,6 +190,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.6
@@ -220,6 +199,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.7
@@ -229,6 +209,7 @@ matrix:
       workspaces:
         use: brew_cache
     - os: osx
+      language: generic
       osx_image: xcode9.4
       env:
         - MB_PYTHON_VERSION=3.8
@@ -240,38 +221,9 @@ matrix:
 
     # default builds for Linux
     - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -279,6 +231,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - PLAT=i686
@@ -287,6 +242,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -295,6 +253,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - PLAT=i686
@@ -304,6 +265,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -312,6 +276,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - PLAT=i686
@@ -321,6 +288,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=0
@@ -329,6 +299,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - PLAT=i686
@@ -340,38 +313,9 @@ matrix:
 
     # headless builds for Linux
     - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=0
@@ -379,6 +323,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - PLAT=i686
@@ -387,6 +334,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
@@ -395,6 +345,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - PLAT=i686
@@ -404,6 +357,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - ENABLE_CONTRIB=0
@@ -412,6 +368,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - PLAT=i686
@@ -421,6 +380,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - ENABLE_CONTRIB=0
@@ -429,6 +391,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - PLAT=i686
@@ -440,38 +405,9 @@ matrix:
 
     # contrib builds for Linux
     - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -479,6 +415,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - PLAT=i686
@@ -487,6 +426,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - TEST_DEPENDS=numpy==1.11.3
@@ -495,6 +437,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - PLAT=i686
@@ -504,6 +449,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - TEST_DEPENDS=numpy==1.14.5
@@ -512,6 +460,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - PLAT=i686
@@ -521,6 +472,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - TEST_DEPENDS=numpy==1.17.3
@@ -529,6 +483,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - PLAT=i686
@@ -541,38 +498,9 @@ matrix:
 
     # headless contrib builds for Linux
     - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-        - PLAT=i686
-        - UNICODE_WIDTH=16
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - ENABLE_CONTRIB=1
@@ -580,6 +508,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.5
         - PLAT=i686
@@ -588,6 +519,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - TEST_DEPENDS=numpy==1.11.3
@@ -596,6 +530,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.6
         - PLAT=i686
@@ -605,6 +542,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - TEST_DEPENDS=numpy==1.14.5
@@ -613,6 +553,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.7
         - PLAT=i686
@@ -622,6 +565,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - TEST_DEPENDS=numpy==1.17.3
@@ -630,6 +576,9 @@ matrix:
       cache:
         directories: $HOME/.ccache
     - os: linux
+      language: generic
+      dist: xenial
+      services: docker
       env:
         - MB_PYTHON_VERSION=3.8
         - PLAT=i686
@@ -711,7 +660,7 @@ before_cache: |
     set +x; set +e
 
 after_success: |
-    # Upload wheels to pypi if requested
+    # Upload wheels to pypi if tag is set, otherwise save to Azure Storage
     if [ -n "$TRAVIS_TAG" ]; then
         set -x
 
@@ -742,5 +691,16 @@ after_success: |
         twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         set +x
     else
-        echo "Tag not set, deployment skipped."
+        set -x
+
+        if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+          curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
+        else
+          brew install azure-cli
+        fi
+
+        az storage container create -n ${TRAVIS_COMMIT} --public-access blob
+        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
+
+        set -x
     fi
diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 9daba95c..83551feb 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -10,12 +10,13 @@ copy or use the software.
                For Open Source Computer Vision Library
                        (3-clause BSD License)
 
-Copyright (C) 2000-2018, Intel Corporation, all rights reserved.
+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,
@@ -80,7 +81,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ------------------------------------------------------------------------------
 FFmpeg is redistributed within opencv-python Windows packages.
-Qt 4.8.7 is redistributed within opencv-python Linux and macOS packages.
+Qt 4.8.7 is redistributed within opencv-python Linux packages.
 This license applies to FFmpeg and Qt binaries in the directory cv2/.
 
                   GNU LESSER GENERAL PUBLIC LICENSE
@@ -585,3 +586,172 @@ necessary.  Here is a sample; alter the names:
   Ty Coon, President of Vice
 
 That's all there is to it!
+
+------------------------------------------------------------------------------
+Qt 5 is redistributed within opencv-pytho macOS packages.
+This license applies to Qt binaries in the directory cv2/.
+
+                   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index e8005c63..328bf506 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2016-2018 Olli-Pekka Heinisuo and contributors
+Copyright (c) Olli-Pekka Heinisuo
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 40326573..46806e1a 100644
--- a/README.md
+++ b/README.md
@@ -128,7 +128,9 @@ Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/s
 
 All wheels ship with [FFmpeg](http://ffmpeg.org) licensed under the [LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).
 
-Linux and MacOS 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).
+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).
+
+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).
 
 ### Versioning
 
@@ -158,13 +160,10 @@ The default ``manylinux`` images have been extended with some OpenCV dependencie
 
 ### Supported Python versions
 
-Python 2.7 is the only supported version in 2.x series. Python 2.7 support will be dropped in the end of 2019.
-
 Python 3.x releases are provided for officially supported versions (not in EOL).
 
 Currently, builds for following Python versions are provided:
 
-- 2.7
 - 3.5
 - 3.6
 - 3.7
diff --git a/cv2/__init__.py b/cv2/__init__.py
index 7612351b..ee8cd254 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -1,4 +1,6 @@
 import importlib
+import os
+import sys
 
 from .cv2 import *
 from .data import *
@@ -6,3 +8,8 @@
 # wildcard import above does not import "private" variables like __version__
 # this makes them available
 globals().update(importlib.import_module('cv2.cv2').__dict__)
+
+if sys.platform == 'darwin':
+    os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
+        os.path.dirname(os.path.abspath(__file__)), 'qt', 'plugins'
+    )
diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
new file mode 100644
index 00000000..00b84582
--- /dev/null
+++ b/patches/patchQtPlugins
@@ -0,0 +1,12 @@
+diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
+index 8ccad4d03a..0d5e2a79e9 100644
+--- a/opencv/CMakeLists.txt
++++ b/opencv/CMakeLists.txt
+@@ -1164,6 +1164,7 @@ 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)
+   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)
diff --git a/setup.py b/setup.py
index 779ea233..3f9ca68d 100644
--- a/setup.py
+++ b/setup.py
@@ -128,6 +128,7 @@ def main():
 
     if sys.platform == 'darwin' and not build_headless:
         cmake_args.append("-DWITH_QT=5")
+        rearrange_cmake_output_data['cv2.qt.plugins.platforms'] = [(r'lib/qt/plugins/platforms/libqcocoa\.dylib')]
 
     if build_headless:
         # it seems that cocoa cannot be disabled so on macOS the package is not truly headless
@@ -144,6 +145,7 @@ def main():
                                                 # https://github.com/skvark/opencv-python/issues/21
         cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")
+        subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
     if sys.platform == 'darwin' and build_contrib:
         cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++ -std=c++11 -Wno-c++11-narrowing")
@@ -203,8 +205,6 @@ def main():
           'Operating System :: POSIX',
           'Operating System :: Unix',
           'Programming Language :: Python',
-          'Programming Language :: Python :: 2',
-          'Programming Language :: Python :: 2.7',
           'Programming Language :: Python :: 3',
           'Programming Language :: Python :: 3.5',
           'Programming Language :: Python :: 3.6',

From b043422b263cd87c8767dd8134716f8ec847f5a5 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Mar 2020 13:56:02 +0200
Subject: [PATCH 080/345] update multibuild

---
 multibuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multibuild b/multibuild
index 6b0ddb52..da36cd54 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit 6b0ddb5281f59d976c8026c082c9d73faf274790
+Subproject commit da36cd5408e03cad504217de4a21bb8f19f2fb2f

From 07c4d737e2dad55c5f9238257b5104e9949b36fd Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Mar 2020 14:09:55 +0200
Subject: [PATCH 081/345] disable MSMF in headless builds #263

---
 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index 3f9ca68d..4ebb8811 100644
--- a/setup.py
+++ b/setup.py
@@ -134,6 +134,7 @@ def main():
         # 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_MSMF=OFF") # see: https://github.com/skvark/opencv-python/issues/263
 
     if sys.platform.startswith('linux'):
         cmake_args.append("-DWITH_V4L=ON")

From fcb818b12885bbc780db116c39a9c4207d626898 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Mar 2020 21:05:50 +0200
Subject: [PATCH 082/345] remove python 2.7

---
 appveyor.yml | 32 --------------------------------
 1 file changed, 32 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index bebe6e16..dab586c7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,14 +6,6 @@ environment:
     secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
 
   matrix:
-    - PYTHON: "C:/Python27"
-      ENABLE_CONTRIB: 0
-      ENABLE_HEADLESS: 0
-
-    - PYTHON: "C:/Python27-x64"
-      ENABLE_CONTRIB: 0
-      ENABLE_HEADLESS: 0
-
     - PYTHON: "C:/Python35"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
@@ -46,14 +38,6 @@ environment:
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python27"
-      ENABLE_CONTRIB: 1
-      ENABLE_HEADLESS: 0
-
-    - PYTHON: "C:/Python27-x64"
-      ENABLE_CONTRIB: 1
-      ENABLE_HEADLESS: 0
-
     - PYTHON: "C:/Python35"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
@@ -86,14 +70,6 @@ environment:
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python27"
-      ENABLE_CONTRIB: 0
-      ENABLE_HEADLESS: 1
-
-    - PYTHON: "C:/Python27-x64"
-      ENABLE_CONTRIB: 0
-      ENABLE_HEADLESS: 1
-
     - PYTHON: "C:/Python35"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
@@ -126,14 +102,6 @@ environment:
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python27"
-      ENABLE_CONTRIB: 1
-      ENABLE_HEADLESS: 1
-
-    - PYTHON: "C:/Python27-x64"
-      ENABLE_CONTRIB: 1
-      ENABLE_HEADLESS: 1
-
     - PYTHON: "C:/Python35"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1

From fb48abe6af6239d4166328ce9062a5d529b194a9 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 4 Apr 2020 20:17:11 +0300
Subject: [PATCH 083/345] update README

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 46806e1a..6a710cd2 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ A: Make sure you have removed old manual installations of OpenCV Python bindings
 
 **Q: Why the packages do not include non-free algorithms?**
 
-A: Non-free algorithms such as SIFT and SURF are not included in these packages because they are patented and therefore cannot be distributed as built binaries. See this issue for more info: https://github.com/skvark/opencv-python/issues/126
+A: Non-free algorithms such as SURF are not included in these packages because they are patented / non-free and therefore cannot be distributed as built binaries. Note that SIFT is included in the builds due to patent expiration since OpenCV versions 4.3.0 and 3.4.10. See this issue for more info: https://github.com/skvark/opencv-python/issues/126
 
 **Q: Why the package and import are different (opencv-python vs. cv2)?**
 

From c08b0d771b8722ffeb859474b1b4a67e0f11a370 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 4 Apr 2020 20:18:18 +0300
Subject: [PATCH 084/345] OpenCV 3.4.10

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index 64e6cf9f..1cc1e6fa 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 64e6cf9fe50ef25d317d3529a42d4862b93f002a
+Subproject commit 1cc1e6fa563f160b54f9c62da965002cab55ca96
diff --git a/opencv_contrib b/opencv_contrib
index 91b39aa0..5d2cf95a 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 91b39aa038600425038df6722a5b4d1b5d7b5ca6
+Subproject commit 5d2cf95afce53d1f742117ae39c9189a0ae4b4dd

From d958923cdd6fd7e23cb62722f645c64fbc6796fd Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 12:54:45 +0300
Subject: [PATCH 085/345] fix FFmpeg binary regex pattern

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 4ebb8811..962775ee 100644
--- a/setup.py
+++ b/setup.py
@@ -78,7 +78,7 @@ def main():
     # Path regexes with forward slashes relative to CMake install dir.
     rearrange_cmake_output_data = {
 
-        'cv2': ([r'bin/opencv_ffmpeg\d{3}%s\.dll' % ('_64' if x64 else '')] if os.name == 'nt' else []) +
+        'cv2': ([r'bin/opencv_ffmpeg\d{3,4}%s\.dll' % ('_64' if x64 else '')] if os.name == 'nt' else []) +
         # In Windows, in python/X.Y/<arch>/; in Linux, in just python/X.Y/.
         # Naming conventions vary so widely between versions and OSes
         # had to give up on checking them.

From 3d074bebe9c5519127075005c3bdae94079ab038 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 15:52:13 +0300
Subject: [PATCH 086/345] initial manylinux2014 changes

---
 docker/{ => manylinux1}/Dockerfile_i686   |  0
 docker/{ => manylinux1}/Dockerfile_x86_64 |  0
 docker/manylinux2014/Dockerfile_i686      | 54 +++++++++++++++++++++++
 docker/manylinux2014/Dockerfile_x86_64    | 52 ++++++++++++++++++++++
 setup.py                                  | 19 ++------
 travis_multibuild_customize.sh            |  2 +-
 6 files changed, 110 insertions(+), 17 deletions(-)
 rename docker/{ => manylinux1}/Dockerfile_i686 (100%)
 rename docker/{ => manylinux1}/Dockerfile_x86_64 (100%)
 create mode 100644 docker/manylinux2014/Dockerfile_i686
 create mode 100644 docker/manylinux2014/Dockerfile_x86_64

diff --git a/docker/Dockerfile_i686 b/docker/manylinux1/Dockerfile_i686
similarity index 100%
rename from docker/Dockerfile_i686
rename to docker/manylinux1/Dockerfile_i686
diff --git a/docker/Dockerfile_x86_64 b/docker/manylinux1/Dockerfile_x86_64
similarity index 100%
rename from docker/Dockerfile_x86_64
rename to docker/manylinux1/Dockerfile_x86_64
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
new file mode 100644
index 00000000..1c6568fe
--- /dev/null
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -0,0 +1,54 @@
+FROM quay.io/pypa/manylinux2014_i686:latest
+
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel -y
+
+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 && \
+    # 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 && \
+    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 && \
+    linux32 ./configure && \
+    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 && \
+    linux32 ./configure && \
+    make -j$(getconf _NPROCESSORS_ONLN) && \
+    make install
+
+RUN cd ~/ffmpeg_sources && \
+    git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
+    cd libvpx && \
+    linux32 ./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" linux32 ./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
+
+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_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
new file mode 100644
index 00000000..ff613b51
--- /dev/null
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -0,0 +1,52 @@
+FROM quay.io/pypa/manylinux2014_x86_64:latest
+
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel -y
+
+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 && \
+    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
+
+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/setup.py b/setup.py
index 758082ca..a2b9e7a8 100644
--- a/setup.py
+++ b/setup.py
@@ -33,6 +33,7 @@ def main():
 
     numpy_version = get_or_install("numpy", minimum_supported_numpy)
     get_or_install("scikit-build")
+    get_or_install("cmake")
     import skbuild
 
     if os.path.exists('.git'):
@@ -125,11 +126,10 @@ def main():
     ] + (["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")] if build_contrib else [])
 
     # OS-specific components
-    if sys.platform.startswith('linux') and not build_headless:
-        cmake_args.append("-DWITH_QT=4")
+    if sys.platform.startswith('linux') or sys.platform == 'darwin' and not build_headless:
+        cmake_args.append("-DWITH_QT=5")
 
     if sys.platform == 'darwin' and not build_headless:
-        cmake_args.append("-DWITH_QT=5")
         rearrange_cmake_output_data['cv2.qt.plugins.platforms'] = [(r'lib/qt/plugins/platforms/libqcocoa\.dylib')]
 
     if build_headless:
@@ -144,22 +144,9 @@ def main():
 
     # Fixes for macOS builds
     if sys.platform == 'darwin':
-        cmake_args.append("-DWITH_LAPACK=OFF")  # Some OSX LAPACK fns are incompatible, see
-                                                # https://github.com/skvark/opencv-python/issues/21
-        cmake_args.append("-DCMAKE_CXX_FLAGS=-stdlib=libc++")
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
-    if sys.platform.startswith('linux'):
-        cmake_args.append("-DWITH_IPP=OFF")   # tests fail with IPP compiled with
-                                              # devtoolset-2 GCC 4.8.2 or vanilla GCC 4.9.4
-                                              # see https://github.com/skvark/opencv-python/issues/138
-    if sys.platform.startswith('linux') and not x64:
-        cmake_args.append("-DCMAKE_CXX_FLAGS=-U__STRICT_ANSI__")
-        # patch openEXR when building on i386, see: https://github.com/openexr/openexr/issues/128
-        subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
-
-
     if 'CMAKE_ARGS' in os.environ:
         import shlex
         cmake_args.extend(shlex.split(os.environ['CMAKE_ARGS']))
diff --git a/travis_multibuild_customize.sh b/travis_multibuild_customize.sh
index e34f5b26..5a9451be 100644
--- a/travis_multibuild_customize.sh
+++ b/travis_multibuild_customize.sh
@@ -3,4 +3,4 @@
 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
 set -x
 REPO_DIR=$(dirname "${BASH_SOURCE[0]}")
-DOCKER_IMAGE='quay.io/skvark/manylinux1_$plat'
+DOCKER_IMAGE='quay.io/skvark/manylinux2014_$plat'

From e165257d7b091466e8f4b4f77c7c9d89e37a7a83 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 16:30:34 +0300
Subject: [PATCH 087/345] fix qmake command and add ccache to i686 image

---
 docker/manylinux2014/Dockerfile_i686 | 7 +++++++
 travis_config.sh                     | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 1c6568fe..83957c6e 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -49,6 +49,13 @@ RUN cd ~/ffmpeg_sources && \
     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/travis_config.sh b/travis_config.sh
index 27875867..c750bef2 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,6 +104,8 @@ function pre_build {
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 
+    qmake -query
+
     echo 'Installing FFmpeg'
 
     if [ -n "$CACHE_STAGE" ]; then
@@ -123,8 +125,8 @@ function pre_build {
 
   else
     echo "Running for linux"
+      qmake-qt5 -query
   fi
-  qmake -query
 }
 
 function run_tests {

From 23cdaad09344fefb8d13edc039414fbcd9c13f67 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 16:52:11 +0300
Subject: [PATCH 088/345] remove qmake query

---
 travis_config.sh | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index c750bef2..fbf565b5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,8 +104,6 @@ function pre_build {
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 
-    qmake -query
-
     echo 'Installing FFmpeg'
 
     if [ -n "$CACHE_STAGE" ]; then
@@ -125,7 +123,6 @@ function pre_build {
 
   else
     echo "Running for linux"
-      qmake-qt5 -query
   fi
 }
 

From 1b9bf2bc7cf9d3bf898953659bc0aaf9277882e2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 18:23:01 +0300
Subject: [PATCH 089/345] override ccache multibuild function, format setup.py
 with black and add DPYTHON3_LIBRARY and DPYTHON3_INCLUDE_DIR

---
 setup.py         | 334 +++++++++++++++++++++++++++++------------------
 travis_config.sh |  26 ++++
 2 files changed, 231 insertions(+), 129 deletions(-)

diff --git a/setup.py b/setup.py
index a2b9e7a8..2ba9295a 100644
--- a/setup.py
+++ b/setup.py
@@ -36,19 +36,24 @@ def main():
     get_or_install("cmake")
     import skbuild
 
-    if os.path.exists('.git'):
+    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])
+        g.run_command(
+            ["submodule", "update", "--init", "--recursive", cmake_source_dir]
+        )
 
         if build_contrib:
-            g.run_command(["submodule", "update", "--init", "--recursive", "opencv_contrib"])
+            g.run_command(
+                ["submodule", "update", "--init", "--recursive", "opencv_contrib"]
+            )
 
     # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
-    x64 = sys.maxsize > 2**32
+    x64 = sys.maxsize > 2 ** 32
 
     package_name = "opencv-python"
 
@@ -61,116 +66,153 @@ def main():
     if build_headless and not build_contrib:
         package_name = "opencv-python-headless"
 
-    long_description = io.open('README.md', encoding="utf-8").read()
+    long_description = io.open("README.md", encoding="utf-8").read()
     package_version = get_opencv_version()
 
-    packages = ['cv2', 'cv2.data']
+    packages = ["cv2", "cv2.data"]
 
     package_data = {
-        'cv2':
-            ['*%s' % sysconfig.get_config_vars().get('SO')] +
-            (['*.dll'] if os.name == 'nt' else []) +
-            ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"],
-        'cv2.data':
-            ["*.xml"]
+        "cv2": ["*%s" % sysconfig.get_config_vars().get("SO")]
+        + (["*.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 []) +
+        "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/<arch>/; 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('SO'))}],
-
-        'cv2.data': [  # OPENCV_OTHER_INSTALL_PATH
-            ('etc' if os.name == 'nt' else 'share/opencv4') +
-            r'/haarcascades/.*\.xml'
-        ]
+        ["python/cv2[^/]*%(ext)s" % {"ext": re.escape(sysconfig.get_config_var("SO"))}],
+        "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']
-    }
+    files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]}
 
-    cmake_args = ([
-        "-G", "Visual Studio 14" + (" Win64" if x64 else '')
-    ] if os.name == 'nt' else [
-        "-G", "Unix Makefiles"  # don't make CMake try (and fail) Ninja first
-    ]) + [
-        # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
-        "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable,
-        "-DPYTHON3_EXECUTABLE=%s" % sys.executable,
-        "-DBUILD_opencv_python3=ON",
-        "-DBUILD_opencv_python2=OFF",
-
-        # 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 [])
+    cmake_args = (
+        (
+            ["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
+            if os.name == "nt"
+            else ["-G", "Unix Makefiles"]  # don't make CMake try (and fail) Ninja first
+        )
+        + [
+            # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
+            "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable,
+            "-DPYTHON3_INCLUDE_DIR=%s" % sysconfig.get_paths()["include"],
+            "-DBUILD_opencv_python3=ON",
+            "-DBUILD_opencv_python2=OFF",
+            # 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",
+        ]
+        + (
+            [
+                "-DPYTHON3_LIBRARY=%s"
+                % os.path.join(
+                    *[
+                        sysconfig.get_config_var("BINDIR"),
+                        "libs",
+                        "python{}.lib".format(
+                            "".join(str(v) for v in sys.version_info[:2])
+                        ),
+                    ]
+                )
+            ]
+            if sys.platform.startswith("win")
+            else [
+                "-DPYTHON3_LIBRARY=%s"
+                % os.path.join(
+                    "/usr/lib/x86_64-linux-gnu/", sysconfig.get_config_var("LDLIBRARY")
+                )
+            ]
+        )
+        + (
+            ["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")]
+            if build_contrib
+            else []
+        )
+    )
 
     # OS-specific components
-    if sys.platform.startswith('linux') or sys.platform == 'darwin' and not build_headless:
+    if (
+        sys.platform.startswith("linux")
+        or sys.platform == "darwin"
+        and not build_headless
+    ):
         cmake_args.append("-DWITH_QT=5")
 
-    if sys.platform == 'darwin' and not build_headless:
-        rearrange_cmake_output_data['cv2.qt.plugins.platforms'] = [(r'lib/qt/plugins/platforms/libqcocoa\.dylib')]
+    if sys.platform == "darwin" and not build_headless:
+        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+            (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
+        ]
 
     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_MSMF=OFF") # see: https://github.com/skvark/opencv-python/issues/263
+        cmake_args.append(
+            "-DWITH_MSMF=OFF"
+        )  # see: https://github.com/skvark/opencv-python/issues/263
 
-    if sys.platform.startswith('linux'):
+    if sys.platform.startswith("linux"):
         cmake_args.append("-DWITH_V4L=ON")
         cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
     # Fixes for macOS builds
-    if sys.platform == 'darwin':
+    if sys.platform == "darwin":
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
-    if 'CMAKE_ARGS' in os.environ:
+    if "CMAKE_ARGS" in os.environ:
         import shlex
-        cmake_args.extend(shlex.split(os.environ['CMAKE_ARGS']))
+
+        cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"]))
         del shlex
 
     # ABI config variables are introduced in PEP 425
     if sys.version_info[:2] < (3, 2):
         import warnings
-        warnings.filterwarnings('ignore', r"Config variable '[^']+' is unset, "
-                                          r"Python ABI tag may be incorrect",
-                                category=RuntimeWarning)
+
+        warnings.filterwarnings(
+            "ignore",
+            r"Config variable '[^']+' is unset, " r"Python ABI tag may be incorrect",
+            category=RuntimeWarning,
+        )
         del warnings
 
     # works via side effect
-    RearrangeCMakeOutput(rearrange_cmake_output_data,
-                         files_outside_package_dir,
-                         package_data.keys())
+    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.',
+        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,
@@ -180,32 +222,32 @@ def main():
         ext_modules=EmptyListWithLength(),
         install_requires="numpy>=%s" % 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',
+            "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):
@@ -213,11 +255,13 @@ 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
 
@@ -231,8 +275,12 @@ def __init__(self, package_paths_re, files_outside_package, packages):
         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.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
@@ -240,16 +288,25 @@ def __init__(self, package_paths_re, files_outside_package, packages):
 
     def __del__(self):
         cls = self.__class__
-        cls._setuptools_wrap._classify_installed_files = cls.wraps._classify_installed_files
+        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):
+    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
@@ -264,10 +321,15 @@ def _classify_installed_files_override(self, install_paths,
 
         # '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]
+        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
 
@@ -276,25 +338,28 @@ def _classify_installed_files_override(self, install_paths,
         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)
+            package_dest_reldir = package_name.replace(".", os.path.sep)
             for relpath_re in relpaths_re:
                 found = False
-                r = re.compile(relpath_re+'$')
+                r = re.compile(relpath_re + "$")
                 for fslash_relpath, relpath in relpaths_zip:
                     m = r.match(fslash_relpath)
-                    if not m: continue
+                    if not m:
+                        continue
                     found = True
                     new_install_relpath = os.path.join(
-                        package_dest_reldir,
-                        os.path.basename(relpath))
+                        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)
+                        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)
+                    if not found:
+                        raise Exception("Not found: '%s'" % relpath_re)
                 del r, found
 
         del relpaths_zip
@@ -302,30 +367,37 @@ def _classify_installed_files_override(self, install_paths,
         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)
+            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))
+                    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
+                    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]
+        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,
+            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
+            cmake_source_dir="",
+            cmake_install_dir=cmake_install_reldir,
         )
 
 
@@ -338,15 +410,15 @@ def get_opencv_version():
     # cv_version.py should be generated by running find_version.py
     runpy.run_path("find_version.py")
     from cv_version import opencv_version
+
     return opencv_version
 
 
 def get_build_env_var_by_name(flag_name):
-
     flag_set = False
 
     try:
-        flag_set = bool(int(os.getenv('ENABLE_' + flag_name.upper() , None)))
+        flag_set = bool(int(os.getenv("ENABLE_" + flag_name.upper(), None)))
     except Exception:
         pass
 
@@ -363,15 +435,19 @@ def get_or_install(name, version=None):
     """ If a package is already installed, build against it. If not, install """
     # Do not import 3rd-party modules into the current process
     import json
+
     js_packages = json.loads(
-        subprocess.check_output([sys.executable, "-m", "pip", "list", "--format", "json"]).decode('ascii'))  # valid names & versions are ASCII as per PEP 440
+        subprocess.check_output(
+            [sys.executable, "-m", "pip", "list", "--format", "json"]
+        ).decode("ascii")
+    )  # valid names & versions are ASCII as per PEP 440
     try:
-        [package] = (package for package in js_packages if package['name'] == name)
+        [package] = (package for package in js_packages if package["name"] == name)
     except ValueError:
         install_packages("%s==%s" % (name, version) if version else name)
         return version
     else:
-        return package['version']
+        return package["version"]
 
 
 # This creates a list which is empty but returns a length of 1.
@@ -381,5 +457,5 @@ def __len__(self):
         return 1
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     main()
diff --git a/travis_config.sh b/travis_config.sh
index fbf565b5..cc5c0e24 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -5,6 +5,32 @@
 #See multibuild/README.rst
 echo "===  Loading config.sh  === "
 
+# custom ccache install because manylinux2014 i686 does not have ccache package
+function activate_ccache {
+    # Link up the correct location for ccache
+    mkdir -p /parent-home/.ccache
+    ln -s /parent-home/.ccache $HOME/.ccache
+
+    # Now install ccache
+    if [ "$(get_platform)" == x86_64 ]; then
+        suppress yum_install ccache
+    fi
+
+    # Create fake compilers and prepend them to the PATH
+    # Note that yum is supposed to create these for us,
+    # but I had trouble finding them
+    local ccache_dir=/usr/lib/ccache/compilers
+    mkdir -p $ccache_dir
+    ln -s /usr/bin/ccache $ccache_dir/gcc
+    ln -s /usr/bin/ccache $ccache_dir/g++
+    ln -s /usr/bin/ccache $ccache_dir/cc
+    ln -s /usr/bin/ccache $ccache_dir/c++
+    export PATH=$ccache_dir:$PATH
+
+    # Prove to the developer that ccache is activated
+    echo "Using C compiler: $(which gcc)"
+}
+
 # To see build progress
 function build_wheel {
     build_bdist_wheel $@

From c69e05d74a0820bce5b7faae854307eead9ac339 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 20:40:50 +0300
Subject: [PATCH 090/345] just disable ccache for i686

---
 .travis.yml      | 16 ++++++++++++++++
 travis_config.sh | 26 --------------------------
 2 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 75801595..abdd069a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -239,6 +239,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -262,6 +263,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.11.3
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -285,6 +287,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -308,6 +311,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.17.3
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -331,6 +335,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -354,6 +359,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.11.3
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -377,6 +383,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -400,6 +407,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.17.3
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -423,6 +431,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -446,6 +455,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -469,6 +479,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -492,6 +503,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -516,6 +528,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -539,6 +552,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -562,6 +576,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -585,6 +600,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
diff --git a/travis_config.sh b/travis_config.sh
index cc5c0e24..fbf565b5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -5,32 +5,6 @@
 #See multibuild/README.rst
 echo "===  Loading config.sh  === "
 
-# custom ccache install because manylinux2014 i686 does not have ccache package
-function activate_ccache {
-    # Link up the correct location for ccache
-    mkdir -p /parent-home/.ccache
-    ln -s /parent-home/.ccache $HOME/.ccache
-
-    # Now install ccache
-    if [ "$(get_platform)" == x86_64 ]; then
-        suppress yum_install ccache
-    fi
-
-    # Create fake compilers and prepend them to the PATH
-    # Note that yum is supposed to create these for us,
-    # but I had trouble finding them
-    local ccache_dir=/usr/lib/ccache/compilers
-    mkdir -p $ccache_dir
-    ln -s /usr/bin/ccache $ccache_dir/gcc
-    ln -s /usr/bin/ccache $ccache_dir/g++
-    ln -s /usr/bin/ccache $ccache_dir/cc
-    ln -s /usr/bin/ccache $ccache_dir/c++
-    export PATH=$ccache_dir:$PATH
-
-    # Prove to the developer that ccache is activated
-    echo "Using C compiler: $(which gcc)"
-}
-
 # To see build progress
 function build_wheel {
     build_bdist_wheel $@

From 8690b218ec6f7f7143a3f5e01b97a30e9b198a41 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 22:03:26 +0300
Subject: [PATCH 091/345] add manually built cmake to i686, lapack

---
 docker/manylinux2014/Dockerfile_i686   | 12 +++++++++++-
 docker/manylinux2014/Dockerfile_x86_64 |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 83957c6e..6133dc19 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel -y
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel lapack-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
@@ -56,6 +56,16 @@ RUN curl -O -L https://github.com/ccache/ccache/releases/download/v3.7.9/ccache-
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
 
+RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
+    tar -xf cmake-3.17.0.tar.gz && \
+    cd cmake-3.17.0 && \
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    ./configure --system-curl && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf cmake-3.17.0*
+
 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_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index ff613b51..55d6b4c2 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel -y
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel lapack-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \

From c5bb48b13c7254eb9760e4829e9b5bb612f0ae24 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 5 Apr 2020 23:00:36 +0300
Subject: [PATCH 092/345] openEXR patch is still needed

---
 setup.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/setup.py b/setup.py
index 2ba9295a..68c125b5 100644
--- a/setup.py
+++ b/setup.py
@@ -180,6 +180,9 @@ def main():
         cmake_args.append("-DWITH_V4L=ON")
         cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
+    if sys.platform.startswith('linux') and not x64:
+        subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
+
     # Fixes for macOS builds
     if sys.platform == "darwin":
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")

From 2945f7f9b517f7b76e6e68288b3213b21df30065 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 6 Apr 2020 18:11:00 +0300
Subject: [PATCH 093/345] update dockerfiles, fix setup.py

---
 docker/README.md                       | 11 +++----
 docker/manylinux2014/Dockerfile_i686   |  2 +-
 docker/manylinux2014/Dockerfile_x86_64 |  2 +-
 setup.py                               | 45 ++++++--------------------
 4 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/docker/README.md b/docker/README.md
index 4ac6033c..7e09ee10 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -1,12 +1,9 @@
 ### Customized manylinux images for opencv-python
 
-This folder includes Dockerfiles for extending both ``i686`` and ``x86_64`` manylinux images.
+The subfolders include Dockerfiles for extending both ``i686`` and ``x86_64`` manylinux1 and manylinux2014 images.
 
-The extended images were created to be able to build OpenCV in reasonable time with Travis. The images are hosted at https://quay.io/user/skvark.
+Manylinux2014 is used in wheels with version 3.4.10.* / 4.3.0.* and above. 
 
-The images have following extra software installed:
+The extended images were created to be able to build OpenCV in reasonable time with Travis. The images are hosted at https://quay.io/user/skvark.
 
-- Qt 4.8.7
-- Cmake 3.9.0
-- FFmpeg with libvpx (latest snapshots at the build time) and recent openssl + other FFmpeg dependencies built from sources
-- Some missing headers included from more recent Linux to be able to enable V4L / V4L2 support in OpenCV
\ No newline at end of file
+See the dockerfiles for more info.
\ No newline at end of file
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 6133dc19..68678e8c 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel lapack-devel -y
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel blas-devel lapack-devel atlas-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 55d6b4c2..f6987f9d 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel lapack-devel -y
+RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel blas-devel lapack-devel atlas-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/setup.py b/setup.py
index 68c125b5..3b82f34d 100644
--- a/setup.py
+++ b/setup.py
@@ -34,7 +34,13 @@ def main():
     numpy_version = get_or_install("numpy", minimum_supported_numpy)
     get_or_install("scikit-build")
     get_or_install("cmake")
+
     import skbuild
+    from skbuild import cmaker
+
+    python_version = cmaker.CMaker.get_python_version()
+    python_lib_path = cmaker.CMaker.get_python_library(python_version)
+    python_include_dir = cmaker.CMaker.get_python_include_dir(python_version)
 
     if os.path.exists(".git"):
 
@@ -109,7 +115,8 @@ def main():
         + [
             # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
             "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable,
-            "-DPYTHON3_INCLUDE_DIR=%s" % sysconfig.get_paths()["include"],
+            "-DPYTHON3_INCLUDE_DIR=%s" % python_include_dir,
+            "-DPYTHON3_LIBRARY=%s" % python_lib_path,
             "-DBUILD_opencv_python3=ON",
             "-DBUILD_opencv_python2=OFF",
             # When off, adds __init__.py and a few more helper .py's. We use our own helper files with a different structure.
@@ -127,27 +134,6 @@ def main():
             "-DBUILD_PERF_TESTS=OFF",
             "-DBUILD_DOCS=OFF",
         ]
-        + (
-            [
-                "-DPYTHON3_LIBRARY=%s"
-                % os.path.join(
-                    *[
-                        sysconfig.get_config_var("BINDIR"),
-                        "libs",
-                        "python{}.lib".format(
-                            "".join(str(v) for v in sys.version_info[:2])
-                        ),
-                    ]
-                )
-            ]
-            if sys.platform.startswith("win")
-            else [
-                "-DPYTHON3_LIBRARY=%s"
-                % os.path.join(
-                    "/usr/lib/x86_64-linux-gnu/", sysconfig.get_config_var("LDLIBRARY")
-                )
-            ]
-        )
         + (
             ["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")]
             if build_contrib
@@ -178,9 +164,10 @@ def main():
 
     if sys.platform.startswith("linux"):
         cmake_args.append("-DWITH_V4L=ON")
+        cmake_args.append("-DWITH_LAPACK=ON")
         cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
-    if sys.platform.startswith('linux') and not x64:
+    if sys.platform.startswith("linux") and not x64:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
     # Fixes for macOS builds
@@ -190,21 +177,9 @@ def main():
 
     if "CMAKE_ARGS" in os.environ:
         import shlex
-
         cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"]))
         del shlex
 
-    # ABI config variables are introduced in PEP 425
-    if sys.version_info[:2] < (3, 2):
-        import warnings
-
-        warnings.filterwarnings(
-            "ignore",
-            r"Config variable '[^']+' is unset, " r"Python ABI tag may be incorrect",
-            category=RuntimeWarning,
-        )
-        del warnings
-
     # works via side effect
     RearrangeCMakeOutput(
         rearrange_cmake_output_data, files_outside_package_dir, package_data.keys()

From a3f18434d0f0081a5dbc67f2a5c9d2079718f63c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 6 Apr 2020 18:25:39 +0300
Subject: [PATCH 094/345] Python 3 executable

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 3b82f34d..1cc5d0e2 100644
--- a/setup.py
+++ b/setup.py
@@ -114,7 +114,7 @@ def main():
         )
         + [
             # skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
-            "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable,
+            "-DPYTHON3_EXECUTABLE=%s" % sys.executable,
             "-DPYTHON3_INCLUDE_DIR=%s" % python_include_dir,
             "-DPYTHON3_LIBRARY=%s" % python_lib_path,
             "-DBUILD_opencv_python3=ON",

From 49ed880fd366de21d094debfe17555ccdc9bd306 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 6 Apr 2020 18:45:35 +0300
Subject: [PATCH 095/345] cmake needs forward slashes

---
 setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 1cc5d0e2..24aa0116 100644
--- a/setup.py
+++ b/setup.py
@@ -39,8 +39,8 @@ def main():
     from skbuild import cmaker
 
     python_version = cmaker.CMaker.get_python_version()
-    python_lib_path = cmaker.CMaker.get_python_library(python_version)
-    python_include_dir = cmaker.CMaker.get_python_include_dir(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"):
 

From a8dfcf21b1470921aec027a2532db37b7a1ba27e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 21 May 2020 13:34:06 +0300
Subject: [PATCH 096/345] Qt5 requires platform plugins also on Linux, update
 i686 Dockerfile

---
 cv2/__init__.py                      | 2 +-
 docker/manylinux2014/Dockerfile_i686 | 6 ++++++
 setup.py                             | 5 +++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/cv2/__init__.py b/cv2/__init__.py
index ee8cd254..1207db95 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -9,7 +9,7 @@
 # this makes them available
 globals().update(importlib.import_module('cv2.cv2').__dict__)
 
-if sys.platform == 'darwin':
+if sys.platform == 'darwin' or sys.platform.startswith("linux"):
     os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), 'qt', 'plugins'
     )
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 68678e8c..e9e49d61 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -68,4 +68,10 @@ RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-
 
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
+
+# in i686, yum metadata ends up with slightly wrong timestamps
+# which inhibits its update
+# https://github.com/skvark/opencv-python/issues/148
+RUN yum clean all
+
 ENV PATH "$HOME/bin:$PATH"
diff --git a/setup.py b/setup.py
index 24aa0116..d5e524dd 100644
--- a/setup.py
+++ b/setup.py
@@ -154,6 +154,11 @@ def main():
             (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
         ]
 
+    if sys.platform.startswith("linux") and not build_headless:
+        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+            (r"lib/qt/plugins/platforms/libqxcb\.so")
+        ]
+
     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")

From c048e37be4dc7174308d409d1740cad4c40a9172 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 21 May 2020 19:02:30 +0300
Subject: [PATCH 097/345] fix plugin path

---
 setup.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index d5e524dd..b116f7bc 100644
--- a/setup.py
+++ b/setup.py
@@ -155,9 +155,14 @@ def main():
         ]
 
     if sys.platform.startswith("linux") and not build_headless:
-        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-            (r"lib/qt/plugins/platforms/libqxcb\.so")
-        ]
+        if x64:
+          rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+              (r"/usr/lib64/qt5/plugins/platforms/libqxcb\.so")
+          ]
+        else:
+          rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+              (r"/usr/lib/qt5/plugins/platforms/libqxcb\.so")
+          ]
 
     if build_headless:
         # it seems that cocoa cannot be disabled so on macOS the package is not truly headless

From 3c4db7e1d803d43fae8d07090e7dd2064c509f74 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 21 May 2020 20:41:04 +0300
Subject: [PATCH 098/345] forgot to enable the patch

---
 setup.py | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/setup.py b/setup.py
index b116f7bc..6eadf3aa 100644
--- a/setup.py
+++ b/setup.py
@@ -155,14 +155,9 @@ def main():
         ]
 
     if sys.platform.startswith("linux") and not build_headless:
-        if x64:
-          rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-              (r"/usr/lib64/qt5/plugins/platforms/libqxcb\.so")
-          ]
-        else:
-          rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-              (r"/usr/lib/qt5/plugins/platforms/libqxcb\.so")
-          ]
+        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+            (r"lib/qt/plugins/platforms/libqxcb\.so")
+        ]
 
     if build_headless:
         # it seems that cocoa cannot be disabled so on macOS the package is not truly headless
@@ -180,10 +175,12 @@ def main():
     if sys.platform.startswith("linux") and not x64:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
+    if sys.platform.startswith("linux") or sys.platform == "darwin":
+        subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
+
     # Fixes for macOS builds
     if sys.platform == "darwin":
         cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")
-        subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
     if "CMAKE_ARGS" in os.environ:
         import shlex

From c7dcf432f47488a31426c11928fd912359050675 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 22 May 2020 17:54:01 +0300
Subject: [PATCH 099/345] update qt patch

---
 patches/patchQtPlugins | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 00b84582..44d47010 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,12 +1,18 @@
+Submodule opencv contains modified content
 diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
-index 8ccad4d03a..0d5e2a79e9 100644
+index 4c0b3880fc..dbe1a74622 100644
 --- a/opencv/CMakeLists.txt
 +++ b/opencv/CMakeLists.txt
-@@ -1164,6 +1164,7 @@ if(WITH_QT OR HAVE_QT)
+@@ -1187,6 +1187,12 @@ 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)
++      install(DIRECTORY ${Qt5_DIR}/../../qt5/plugins 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)

From 8c7037b7fd11bdd6acf2eb4eba912c5f562b5891 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 22 May 2020 18:51:38 +0300
Subject: [PATCH 100/345] fix if

---
 patches/patchQtPlugins | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 44d47010..01b640b3 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,6 +1,7 @@
+Submodule opencv contains untracked content
 Submodule opencv contains modified content
 diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
-index 4c0b3880fc..dbe1a74622 100644
+index 4c0b3880fc..54da25f151 100644
 --- a/opencv/CMakeLists.txt
 +++ b/opencv/CMakeLists.txt
 @@ -1187,6 +1187,12 @@ if(WITH_QT OR HAVE_QT)
@@ -10,7 +11,7 @@ index 4c0b3880fc..dbe1a74622 100644
 +    if(APPLE)
 +      install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
 +    endif()
-+    if(UNIX)
++    if(UNIX AND NOT APPLE)
 +      install(DIRECTORY ${Qt5_DIR}/../../qt5/plugins DESTINATION lib/qt)
 +    endif()
    elseif(HAVE_QT)

From d2060ea2e9649a0e41b0ee8beb7810cdbd598281 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 23 Jun 2020 21:30:20 +0300
Subject: [PATCH 101/345] use custom Qt5 build

---
 docker/manylinux2014/Dockerfile_i686   | 17 ++++++++++++++++-
 docker/manylinux2014/Dockerfile_x86_64 | 17 ++++++++++++++++-
 patches/patchQtPlugins                 |  4 +---
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index e9e49d61..cf0250bf 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,6 +1,21 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel blas-devel lapack-devel atlas-devel -y
+RUN yum install freetype-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 bzip2-devel curl-devel blas-devel lapack-devel atlas-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) && \
+    # OpenCV only links against QtCore, QtGui, QtTest
+    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -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 && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index f6987f9d..4f4c6239 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,6 +1,21 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
-RUN yum install freetype-devel bzip2-devel curl-devel qt5-qtbase-devel blas-devel lapack-devel atlas-devel -y
+RUN yum install freetype-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 bzip2-devel curl-devel blas-devel lapack-devel atlas-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) && \
+    # OpenCV only links against QtCore, QtGui, QtTest
+    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -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 && \
diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 01b640b3..e84aca44 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,5 +1,3 @@
-Submodule opencv contains untracked content
-Submodule opencv contains modified content
 diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
 index 4c0b3880fc..54da25f151 100644
 --- a/opencv/CMakeLists.txt
@@ -12,7 +10,7 @@ index 4c0b3880fc..54da25f151 100644
 +      install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
 +    endif()
 +    if(UNIX AND NOT APPLE)
-+      install(DIRECTORY ${Qt5_DIR}/../../qt5/plugins DESTINATION lib/qt)
++      install(DIRECTORY /opt/Qt5.15.0/plugins DESTINATION lib/qt)
 +    endif()
    elseif(HAVE_QT)
      status("    QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")

From 3290234917b6aca6c490cccd10e971c8bf75e107 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 24 Jun 2020 17:20:40 +0300
Subject: [PATCH 102/345] disable dbus

---
 docker/manylinux2014/Dockerfile_i686   | 2 +-
 docker/manylinux2014/Dockerfile_x86_64 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index cf0250bf..8631e76b 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -7,7 +7,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
     # OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -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 && \
+    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -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 .. && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 4f4c6239..ac68a786 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -7,7 +7,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
     # OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -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 && \
+    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -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 .. && \

From d4401cfc81c8938611b10628a19426c199f0b12c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 24 Jun 2020 18:30:56 +0300
Subject: [PATCH 103/345] set LD_LIBRARY_PATH

---
 travis_config.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/travis_config.sh b/travis_config.sh
index fbf565b5..035791d2 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -24,6 +24,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 # Qt5 libs for auditwheel
   export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)"
 fi
 

From 3da5b1bba3c8f642133a8dd38424aa249c103598 Mon Sep 17 00:00:00 2001
From: johnthagen <johnthagen@users.noreply.github.com>
Date: Thu, 25 Jun 2020 19:15:05 -0400
Subject: [PATCH 104/345] Fix typo in license

---
 LICENSE-3RD-PARTY.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 83551feb..5b45451b 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -588,7 +588,7 @@ necessary.  Here is a sample; alter the names:
 That's all there is to it!
 
 ------------------------------------------------------------------------------
-Qt 5 is redistributed within opencv-pytho macOS packages.
+Qt 5 is redistributed within opencv-python macOS packages.
 This license applies to Qt binaries in the directory cv2/.
 
                    GNU LESSER GENERAL PUBLIC LICENSE
@@ -754,4 +754,4 @@ General Public License ever published by the Free Software Foundation.
 whether future versions of the GNU Lesser General Public License shall
 apply, that proxy's public statement of acceptance of any version is
 permanent authorization for you to choose that version for the
-Library.
\ No newline at end of file
+Library.

From 61591fec97cc86f064b91fd002b556918c7bd8ba Mon Sep 17 00:00:00 2001
From: johnthagen <johnthagen@users.noreply.github.com>
Date: Fri, 26 Jun 2020 07:05:31 -0400
Subject: [PATCH 105/345] Fix FFmpeg packaging reference

---
 LICENSE-3RD-PARTY.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 5b45451b..786dc063 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -80,7 +80,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ------------------------------------------------------------------------------
-FFmpeg is redistributed within opencv-python Windows packages.
+FFmpeg is redistributed within all opencv-python packages.
 Qt 4.8.7 is redistributed within opencv-python Linux packages.
 This license applies to FFmpeg and Qt binaries in the directory cv2/.
 

From db574be4e2912384cd910dc3ed600704539e4c98 Mon Sep 17 00:00:00 2001
From: johnthagen <johnthagen@users.noreply.github.com>
Date: Fri, 26 Jun 2020 07:07:52 -0400
Subject: [PATCH 106/345] Correct headless license reference

---
 LICENSE-3RD-PARTY.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 786dc063..43b0dec7 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -81,7 +81,7 @@ 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 opencv-python Linux packages.
+Qt 4.8.7 is redistributed within non-headless opencv-python Linux packages.
 This license applies to FFmpeg and Qt binaries in the directory cv2/.
 
                   GNU LESSER GENERAL PUBLIC LICENSE
@@ -588,7 +588,7 @@ necessary.  Here is a sample; alter the names:
 That's all there is to it!
 
 ------------------------------------------------------------------------------
-Qt 5 is redistributed within opencv-python macOS packages.
+Qt 5 is redistributed within non-headless opencv-python macOS packages.
 This license applies to Qt binaries in the directory cv2/.
 
                    GNU LESSER GENERAL PUBLIC LICENSE

From 1bba3e6f4fe1653a72a7a43ada4e8ac36b6462f4 Mon Sep 17 00:00:00 2001
From: johnthagen <johnthagen@users.noreply.github.com>
Date: Fri, 26 Jun 2020 07:09:24 -0400
Subject: [PATCH 107/345] Fix headless Qt license reference in README

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6a710cd2..024abe3b 100644
--- a/README.md
+++ b/README.md
@@ -128,9 +128,9 @@ Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/s
 
 All wheels ship with [FFmpeg](http://ffmpeg.org) licensed under the [LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).
 
-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 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).
 
-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 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).
 
 ### Versioning
 

From 89e798669c92d945041049fda53641a37be64c9e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 26 Jun 2020 18:50:47 +0300
Subject: [PATCH 108/345] test namespaced Qt

---
 docker/manylinux2014/Dockerfile_i686   | 2 +-
 docker/manylinux2014/Dockerfile_x86_64 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 8631e76b..d5e071dd 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -7,7 +7,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
     # OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -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 && \
+    ./configure -prefix /opt/Qt5.15.0 -platform linux-g++-32 -qtnamespace QtOpenCVPython -release -opensource -confirm-license -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 .. && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index ac68a786..2d6faa29 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -7,7 +7,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
     # OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt5.15.0 -release -opensource -confirm-license -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 && \
+    ./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 .. && \

From 61f843f0291360f1d870b82913d3dec012ff40b7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 30 Jun 2020 21:42:41 +0300
Subject: [PATCH 109/345] back to Qt4

---
 .travis.yml                            | 32 +++++++++++++-------------
 cv2/__init__.py                        |  2 +-
 docker/manylinux2014/Dockerfile_i686   | 17 +-------------
 docker/manylinux2014/Dockerfile_x86_64 | 17 +-------------
 patches/patchQtPlugins                 | 13 ++++-------
 setup.py                               | 18 ++++-----------
 travis_config.sh                       |  3 ++-
 7 files changed, 30 insertions(+), 72 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index abdd069a..a0e3e53d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -239,7 +239,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -263,7 +263,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.11.3
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -287,7 +287,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -311,7 +311,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.17.3
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
 
@@ -335,7 +335,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -359,7 +359,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.11.3
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -383,7 +383,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -407,7 +407,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.17.3
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
 
@@ -431,7 +431,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -455,7 +455,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -479,7 +479,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -503,7 +503,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
 
@@ -528,7 +528,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -552,7 +552,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -576,7 +576,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -600,7 +600,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
+
       cache:
         directories: $HOME/.ccache
 
diff --git a/cv2/__init__.py b/cv2/__init__.py
index 1207db95..ee8cd254 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -9,7 +9,7 @@
 # this makes them available
 globals().update(importlib.import_module('cv2.cv2').__dict__)
 
-if sys.platform == 'darwin' or sys.platform.startswith("linux"):
+if sys.platform == 'darwin':
     os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), 'qt', 'plugins'
     )
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index d5e071dd..c0586ee5 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,21 +1,6 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
-RUN yum install freetype-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 bzip2-devel curl-devel blas-devel lapack-devel atlas-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) && \
-    # OpenCV only links against QtCore, QtGui, QtTest
-    ./configure -prefix /opt/Qt5.15.0 -platform linux-g++-32 -qtnamespace QtOpenCVPython -release -opensource -confirm-license -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 yum install bzip2-devel curl-devel zlib-devel qt-x11 -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 2d6faa29..d84c6e8b 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,21 +1,6 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
-RUN yum install freetype-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 bzip2-devel curl-devel blas-devel lapack-devel atlas-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) && \
-    # OpenCV only links against QtCore, QtGui, QtTest
-    ./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 yum install bzip2-devel curl-devel zlib-devel qt-x11 -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index e84aca44..c69ef795 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,17 +1,12 @@
 diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
-index 4c0b3880fc..54da25f151 100644
+index 8ccad4d03a..0d5e2a79e9 100644
 --- a/opencv/CMakeLists.txt
 +++ b/opencv/CMakeLists.txt
-@@ -1187,6 +1187,12 @@ if(WITH_QT OR HAVE_QT)
+@@ -1164,6 +1164,7 @@ 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)
-+    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)
-+    endif()
++    install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
    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)
+     status("      QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 6eadf3aa..843d5f03 100644
--- a/setup.py
+++ b/setup.py
@@ -142,23 +142,15 @@ def main():
     )
 
     # OS-specific components
-    if (
-        sys.platform.startswith("linux")
-        or sys.platform == "darwin"
-        and not build_headless
-    ):
-        cmake_args.append("-DWITH_QT=5")
+    if sys.platform.startswith('linux') and not build_headless:
+        cmake_args.append("-DWITH_QT=4")
 
-    if sys.platform == "darwin" and not build_headless:
+    if sys.platform == 'darwin' and not build_headless:
+        cmake_args.append("-DWITH_QT=5")
         rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
             (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
         ]
 
-    if sys.platform.startswith("linux") and not build_headless:
-        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-            (r"lib/qt/plugins/platforms/libqxcb\.so")
-        ]
-
     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")
@@ -175,7 +167,7 @@ def main():
     if sys.platform.startswith("linux") and not x64:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
-    if sys.platform.startswith("linux") or sys.platform == "darwin":
+    if sys.platform == "darwin":
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
     # Fixes for macOS builds
diff --git a/travis_config.sh b/travis_config.sh
index 035791d2..b958fad7 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -24,7 +24,6 @@ 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 # Qt5 libs for auditwheel
   export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)"
 fi
 
@@ -97,6 +96,8 @@ function pre_build {
         brew_add_local_bottles
     fi
 
+    brew style
+
     echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }

From 51f52b2745c15f7ca1a16b00b40194d1858deab7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 30 Jun 2020 23:17:20 +0300
Subject: [PATCH 110/345] use correct package

---
 docker/manylinux2014/Dockerfile_i686   | 2 +-
 docker/manylinux2014/Dockerfile_x86_64 | 2 +-
 travis_config.sh                       | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index c0586ee5..c50a5018 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
-RUN yum install bzip2-devel curl-devel zlib-devel qt-x11 -y
+RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index d84c6e8b..df7e106e 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,6 +1,6 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
-RUN yum install bzip2-devel curl-devel zlib-devel qt-x11 -y
+RUN yum install bzip2-devel curl-devel zlib-devel qt-devel -y
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/travis_config.sh b/travis_config.sh
index b958fad7..fbf565b5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -96,8 +96,6 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    brew style
-
     echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
         brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }

From 4e154a8d21e11f3781d0fbf5804027c19af5983e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 30 Jun 2020 23:48:21 +0300
Subject: [PATCH 111/345] disable ccache again

---
 .travis.yml | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a0e3e53d..abdd069a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -239,7 +239,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -263,7 +263,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.11.3
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -287,7 +287,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -311,7 +311,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.17.3
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -335,7 +335,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -359,7 +359,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.11.3
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -383,7 +383,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -407,7 +407,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.17.3
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -431,7 +431,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -455,7 +455,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -479,7 +479,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -503,7 +503,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 
@@ -528,7 +528,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -552,7 +552,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.11.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -576,7 +576,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.14.5
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -600,7 +600,7 @@ jobs:
         - TEST_DEPENDS=numpy==1.17.3
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
-
+        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
 

From 58be0655ec4de3dfda6d514d92931478e8d05fee Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 2 Jul 2020 21:08:51 +0300
Subject: [PATCH 112/345] update licenses

---
 LICENSE-3RD-PARTY.txt | 877 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 872 insertions(+), 5 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 83551feb..5c6c7632 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -45,7 +45,7 @@ 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.
 
 ------------------------------------------------------------------------------
-libvpx is redistributed within opencv-python Linux packages.
+libvpx is redistributed within all opencv-python Linux packages.
 This license applies to libvpx binary in the directory cv2/.
 
 Copyright (c) 2010, The WebM Project authors. All rights reserved.
@@ -80,9 +80,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ------------------------------------------------------------------------------
-FFmpeg is redistributed within opencv-python Windows packages.
+FFmpeg is redistributed within all opencv-python packages.
 Qt 4.8.7 is redistributed within opencv-python Linux packages.
-This license applies to FFmpeg and Qt binaries in the directory cv2/.
+Libuuid is redistributed within all opencv-python Linux packages.
+This license applies to FFmpeg, Qt and libuuid binaries in the directory cv2/.
 
                   GNU LESSER GENERAL PUBLIC LICENSE
                        Version 2.1, February 1999
@@ -588,7 +589,7 @@ necessary.  Here is a sample; alter the names:
 That's all there is to it!
 
 ------------------------------------------------------------------------------
-Qt 5 is redistributed within opencv-pytho macOS packages.
+Qt 5 is redistributed within opencv-python macOS packages.
 This license applies to Qt binaries in the directory cv2/.
 
                    GNU LESSER GENERAL PUBLIC LICENSE
@@ -754,4 +755,870 @@ General Public License ever published by the Free Software Foundation.
 whether future versions of the GNU Lesser General Public License shall
 apply, that proxy's public statement of acceptance of any version is
 permanent authorization for you to choose that version for the
-Library.
\ No newline at end of file
+Library.
+
+------------------------------------------------------------------------------
+bzip2 is redistributed within all opencv-python Linux packages.
+This license applies to libbz2 binary in the directory cv2/.
+
+This program, "bzip2", the associated library "libbzip2", and all
+documentation, are copyright (C) 1996-2010 Julian R Seward.  All
+rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. The origin of this software must not be misrepresented; you must 
+   not claim that you wrote the original software.  If you use this 
+   software in a product, an acknowledgment in the product 
+   documentation would be appreciated but is not required.
+
+3. Altered source versions must be plainly marked as such, and must
+   not be misrepresented as being the original software.
+
+4. The name of the author may not be used to endorse or promote 
+   products derived from this software without specific prior written 
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
+
+Julian Seward, jseward@bzip.org
+bzip2/libbzip2 version 1.0.6 of 6 September 2010
+
+------------------------------------------------------------------------------
+libcrypto and libssl are redistributed within all opencv-python Linux packages.
+This license applies to libcrypto and libssl binaries in the directory cv2/.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        https://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
+
+------------------------------------------------------------------------------
+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 packages.
+This license applies to libfontconfig binary in the directory cv2/.
+
+Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard
+Copyright © 2005 Patrick Lam
+Copyright © 2009 Roozbeh Pournader
+Copyright © 2008,2009 Red Hat, Inc.
+Copyright © 2008 Danilo Šegan
+Copyright © 2012 Google, 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 the author(s) not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission.  The authors make no
+representations about the suitability of this software for any purpose.  It
+is provided "as is" without express or implied warranty.
+
+THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL THE AUTHOR(S) 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.
+
+------------------------------------------------------------------------------
+libfreetype is redistributed within opencv-python Linux packages.
+This license applies to libfreetype binary in the directory cv2/.
+
+                    The FreeType Project LICENSE
+                    ----------------------------
+
+                            2006-Jan-27
+
+                    Copyright 1996-2002, 2006 by
+          David Turner, Robert Wilhelm, and Werner Lemberg
+
+
+
+Introduction
+============
+
+  The FreeType  Project is distributed in  several archive packages;
+  some of them may contain, in addition to the FreeType font engine,
+  various tools and  contributions which rely on, or  relate to, the
+  FreeType Project.
+
+  This  license applies  to all  files found  in such  packages, and
+  which do not  fall under their own explicit  license.  The license
+  affects  thus  the  FreeType   font  engine,  the  test  programs,
+  documentation and makefiles, at the very least.
+
+  This  license   was  inspired  by  the  BSD,   Artistic,  and  IJG
+  (Independent JPEG  Group) licenses, which  all encourage inclusion
+  and  use of  free  software in  commercial  and freeware  products
+  alike.  As a consequence, its main points are that:
+
+    o We don't promise that this software works. However, we will be
+      interested in any kind of bug reports. (`as is' distribution)
+
+    o You can  use this software for whatever you  want, in parts or
+      full form, without having to pay us. (`royalty-free' usage)
+
+    o You may not pretend that  you wrote this software.  If you use
+      it, or  only parts of it,  in a program,  you must acknowledge
+      somewhere  in  your  documentation  that  you  have  used  the
+      FreeType code. (`credits')
+
+  We  specifically  permit  and  encourage  the  inclusion  of  this
+  software, with  or without modifications,  in commercial products.
+  We  disclaim  all warranties  covering  The  FreeType Project  and
+  assume no liability related to The FreeType Project.
+
+
+  Finally,  many  people  asked  us  for  a  preferred  form  for  a
+  credit/disclaimer to use in compliance with this license.  We thus
+  encourage you to use the following text:
+
+   """
+    Portions of this software are copyright © <year> The FreeType
+    Project (www.freetype.org).  All rights reserved.
+   """
+
+  Please replace <year> with the value from the FreeType version you
+  actually use.
+
+
+Legal Terms
+===========
+
+0. Definitions
+--------------
+
+  Throughout this license,  the terms `package', `FreeType Project',
+  and  `FreeType  archive' refer  to  the  set  of files  originally
+  distributed  by the  authors  (David Turner,  Robert Wilhelm,  and
+  Werner Lemberg) as the `FreeType Project', be they named as alpha,
+  beta or final release.
+
+  `You' refers to  the licensee, or person using  the project, where
+  `using' is a generic term including compiling the project's source
+  code as  well as linking it  to form a  `program' or `executable'.
+  This  program is  referred to  as  `a program  using the  FreeType
+  engine'.
+
+  This  license applies  to all  files distributed  in  the original
+  FreeType  Project,   including  all  source   code,  binaries  and
+  documentation,  unless  otherwise  stated   in  the  file  in  its
+  original, unmodified form as  distributed in the original archive.
+  If you are  unsure whether or not a particular  file is covered by
+  this license, you must contact us to verify this.
+
+  The FreeType  Project is copyright (C) 1996-2000  by David Turner,
+  Robert Wilhelm, and Werner Lemberg.  All rights reserved except as
+  specified below.
+
+1. No Warranty
+--------------
+
+  THE FREETYPE PROJECT  IS PROVIDED `AS IS' WITHOUT  WARRANTY OF ANY
+  KIND, EITHER  EXPRESS OR IMPLIED,  INCLUDING, BUT NOT  LIMITED TO,
+  WARRANTIES  OF  MERCHANTABILITY   AND  FITNESS  FOR  A  PARTICULAR
+  PURPOSE.  IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE  FOR ANY DAMAGES CAUSED  BY THE USE OR  THE INABILITY TO
+  USE, OF THE FREETYPE PROJECT.
+
+2. Redistribution
+-----------------
+
+  This  license  grants  a  worldwide, royalty-free,  perpetual  and
+  irrevocable right  and license to use,  execute, perform, compile,
+  display,  copy,   create  derivative  works   of,  distribute  and
+  sublicense the  FreeType Project (in  both source and  object code
+  forms)  and  derivative works  thereof  for  any  purpose; and  to
+  authorize others  to exercise  some or all  of the  rights granted
+  herein, subject to the following conditions:
+
+    o Redistribution of  source code  must retain this  license file
+      (`FTL.TXT') unaltered; any  additions, deletions or changes to
+      the original  files must be clearly  indicated in accompanying
+      documentation.   The  copyright   notices  of  the  unaltered,
+      original  files must  be  preserved in  all  copies of  source
+      files.
+
+    o Redistribution in binary form must provide a  disclaimer  that
+      states  that  the software is based in part of the work of the
+      FreeType Team,  in  the  distribution  documentation.  We also
+      encourage you to put an URL to the FreeType web page  in  your
+      documentation, though this isn't mandatory.
+
+  These conditions  apply to any  software derived from or  based on
+  the FreeType Project,  not just the unmodified files.   If you use
+  our work, you  must acknowledge us.  However, no  fee need be paid
+  to us.
+
+3. Advertising
+--------------
+
+  Neither the  FreeType authors and  contributors nor you  shall use
+  the name of the  other for commercial, advertising, or promotional
+  purposes without specific prior written permission.
+
+  We suggest,  but do not require, that  you use one or  more of the
+  following phrases to refer  to this software in your documentation
+  or advertising  materials: `FreeType Project',  `FreeType Engine',
+  `FreeType library', or `FreeType Distribution'.
+
+  As  you have  not signed  this license,  you are  not  required to
+  accept  it.   However,  as  the FreeType  Project  is  copyrighted
+  material, only  this license, or  another one contracted  with the
+  authors, grants you  the right to use, distribute,  and modify it.
+  Therefore,  by  using,  distributing,  or modifying  the  FreeType
+  Project, you indicate that you understand and accept all the terms
+  of this license.
+
+4. Contacts
+-----------
+
+  There are two mailing lists related to FreeType:
+
+    o freetype@nongnu.org
+
+      Discusses general use and applications of FreeType, as well as
+      future and  wanted additions to the  library and distribution.
+      If  you are looking  for support,  start in  this list  if you
+      haven't found anything to help you in the documentation.
+
+    o freetype-devel@nongnu.org
+
+      Discusses bugs,  as well  as engine internals,  design issues,
+      specific licenses, porting, etc.
+
+  Our home page can be found at
+
+    https://www.freetype.org
+
+------------------------------------------------------------------------------
+libpng is redistributed within all opencv-python Linux packages.
+This license applies to libpng binary in the directory cv2/.
+
+PNG Reference Library License version 2
+---------------------------------------
+
+ * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2019 Cosmin Truta.
+ * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ * Copyright (c) 1996-1997 Andreas Dilger.
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+
+The software is supplied "as is", without warranty of any kind,
+express or implied, including, without limitation, the warranties
+of merchantability, fitness for a particular purpose, title, and
+non-infringement.  In no event shall the Copyright owners, or
+anyone distributing the software, be liable for any damages or
+other liability, whether in contract, tort or otherwise, arising
+from, out of, or in connection with the software, or the use or
+other dealings in the software, even if advised of the possibility
+of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute
+this software, or portions hereof, for any purpose, without fee,
+subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you
+    must not claim that you wrote the original software.  If you
+    use this software in a product, an acknowledgment in the product
+    documentation would be appreciated, but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must
+    not be misrepresented as being the original software.
+
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
+
+
+PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+-----------------------------------------------------------------------
+
+libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
+Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
+derived from libpng-1.0.6, and are distributed according to the same
+disclaimer and license as libpng-1.0.6 with the following individuals
+added to the list of Contributing Authors:
+
+    Simon-Pierre Cadieux
+    Eric S. Raymond
+    Mans Rullgard
+    Cosmin Truta
+    Gilles Vollant
+    James Yu
+    Mandar Sahastrabuddhe
+    Google Inc.
+    Vadim Barkov
+
+and with the following additions to the disclaimer:
+
+    There is no warranty against interference with your enjoyment of
+    the library or against infringement.  There is no warranty that our
+    efforts or the library will fulfill any of your particular purposes
+    or needs.  This library is provided with all faults, and the entire
+    risk of satisfactory quality, performance, accuracy, and effort is
+    with the user.
+
+Some files in the "contrib" directory and some configure-generated
+files that are distributed with libpng have other copyright owners, and
+are released under other open source licenses.
+
+libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
+Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
+libpng-0.96, and are distributed according to the same disclaimer and
+license as libpng-0.96, with the following individuals added to the
+list of Contributing Authors:
+
+    Tom Lane
+    Glenn Randers-Pehrson
+    Willem van Schaik
+
+libpng versions 0.89, June 1996, through 0.96, May 1997, are
+Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
+and are distributed according to the same disclaimer and license as
+libpng-0.88, with the following individuals added to the list of
+Contributing Authors:
+
+    John Bowler
+    Kevin Bracey
+    Sam Bushell
+    Magnus Holmgren
+    Greg Roelofs
+    Tom Tanner
+
+Some files in the "scripts" directory have other copyright owners,
+but are released under this license.
+
+libpng versions 0.5, May 1995, through 0.88, January 1996, are
+Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+
+For the purposes of this copyright and license, "Contributing Authors"
+is defined as the following set of individuals:
+
+    Andreas Dilger
+    Dave Martindale
+    Guy Eric Schalnat
+    Paul Schmidt
+    Tim Wegner
+
+The PNG Reference Library is supplied "AS IS".  The Contributing
+Authors and Group 42, Inc. disclaim all warranties, expressed or
+implied, including, without limitation, the warranties of
+merchantability and of fitness for any purpose.  The Contributing
+Authors and Group 42, Inc. assume no liability for direct, indirect,
+incidental, special, exemplary, or consequential damages, which may
+result from the use of the PNG Reference Library, even if advised of
+the possibility of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+source code, or portions hereof, for any purpose, without fee, subject
+to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented.
+
+ 2. Altered versions must be plainly marked as such and must not
+    be misrepresented as being the original source.
+
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
+
+The Contributing Authors and Group 42, Inc. specifically permit,
+without fee, and encourage the use of this source code as a component
+to supporting the PNG file format in commercial products.  If you use
+this source code in a product, acknowledgment is not required but would
+be appreciated.
+
+------------------------------------------------------------------------------
+libz is redistributed within all opencv-python Linux packages.
+This license applies to libz binary in the directory cv2/.
+
+  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  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.

From bad9466ea11157db91113a9af47428cf00cd2d31 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 2 Jul 2020 21:24:49 +0300
Subject: [PATCH 113/345] update README

---
 README.md | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/README.md b/README.md
index 6a710cd2..28f76c08 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,17 @@ In addition to any variables that OpenCV's build accepts, we recognize:
 - ``ENABLE_CONTRIB`` and ``ENABLE_HEADLESS``. Set to ``1`` to build the contrib and/or headless version
 - ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build.
 
+### Manual builds
+
+If some dependency is not enabled in the pre-built wheels, you can also run the `setup.py` locally to create a custom wheel.
+
+1. Clone this repository: `git clone --recursive https://github.com/skvark/opencv-python.git`
+2. Go to the root of the repository 
+3. Add custom Cmake flags if needed, for example: `export CMAKE_FLAGS="-DSOME_FLAG=ON -DSOME_OTHER_FLAG=OFF"`
+4. Run ``python setup.py bdist_wheel``
+     - Optionally use the `manylinux` images as a build hosts if maximum portability is needed (and run `auditwheel` for the wheel after build)
+5. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish (upload to local PyPI index, use as dependency in a CI job which runs the PyInstaller / PyOxidizer bundler for your app etc.)
+
 ### Licensing
 
 Opencv-python package (scripts in this repository) is available under MIT license.
@@ -132,6 +143,8 @@ Linux wheels ship with [Qt 4.8.7](http://doc.qt.io/qt-4.8/lgpl.html) licensed un
 
 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).
+
 ### Versioning
 
 ``find_version.py`` script searches for the version information from OpenCV sources and appends also a revision number specific to this repository to the version string.
@@ -168,3 +181,10 @@ Currently, builds for following Python versions are provided:
 - 3.6
 - 3.7
 - 3.8
+
+### Backward compatibility
+
+Starting from 4.2.0 and 3.4.9 builds the macOS Travis build environment was updated to XCode 9.4. The change effectively dropped support for older than 10.13 macOS versions.
+
+Starting from 4.3.0 and 3.4.10 builds the Linux build environment was updated from `manylinux1` to `manylinux2014`. This dropped support for old Linux distributions.
+

From 1d880124ee0ae4b8edb4d1042706fc5a7ec1064f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 2 Jul 2020 22:12:46 +0300
Subject: [PATCH 114/345] try to fix the brew issue

---
 travis_config.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/travis_config.sh b/travis_config.sh
index fbf565b5..9da98202 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -94,6 +94,8 @@ function pre_build {
         brew update
         generate_ffmpeg_formula
         brew_add_local_bottles
+    else
+        brew style
     fi
 
     echo 'Installing qt5'

From 7fdd4fc46a73bfeb661606b5c40bcaee790d57fc Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 2 Jul 2020 22:19:58 +0300
Subject: [PATCH 115/345] change the command location and fix README

---
 README.md        | 2 +-
 travis_config.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 28f76c08..9daa1a4f 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,7 @@ If some dependency is not enabled in the pre-built wheels, you can also run the
 3. Add custom Cmake flags if needed, for example: `export CMAKE_FLAGS="-DSOME_FLAG=ON -DSOME_OTHER_FLAG=OFF"`
 4. Run ``python setup.py bdist_wheel``
      - Optionally use the `manylinux` images as a build hosts if maximum portability is needed (and run `auditwheel` for the wheel after build)
-5. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish (upload to local PyPI index, use as dependency in a CI job which runs the PyInstaller / PyOxidizer bundler for your app etc.)
+5. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish
 
 ### Licensing
 
diff --git a/travis_config.sh b/travis_config.sh
index 9da98202..b8defe87 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -89,13 +89,13 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
+    brew style
+
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update
         generate_ffmpeg_formula
         brew_add_local_bottles
-    else
-        brew style
     fi
 
     echo 'Installing qt5'

From 048b9c1ea986a0bddf57ad07732be0d84ddb9cf9 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 2 Jul 2020 22:31:11 +0300
Subject: [PATCH 116/345] try update-reset

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index b8defe87..aaa276b2 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -89,7 +89,7 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
-    brew style
+    brew update-reset
 
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then

From 05413b407f5e7a5626c624dcf6bad4764531d464 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 3 Jul 2020 21:37:48 +0300
Subject: [PATCH 117/345] try to install homebrew

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index aaa276b2..9df4c072 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -89,7 +89,7 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
-    brew update-reset
+    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
 
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then

From b2b07000196a2230ab1f6ee5cc4071b8ad87f484 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 3 Jul 2020 22:27:47 +0300
Subject: [PATCH 118/345] revert back to original...

---
 travis_config.sh | 2 --
 1 file changed, 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 9df4c072..fbf565b5 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -89,8 +89,6 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
-    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
-
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update

From f2b30d60fde1d2b6a17dd3978914e0c0239661f3 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 4 Jul 2020 23:09:51 +0300
Subject: [PATCH 119/345] add macOS licenses

---
 LICENSE-3RD-PARTY.txt | 1163 +++++++++++++++++++++++++++++++++--------
 1 file changed, 935 insertions(+), 228 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 5c6c7632..3148b06c 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -83,7 +83,11 @@ 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 opencv-python Linux packages.
 Libuuid is redistributed within all opencv-python Linux packages.
-This license applies to FFmpeg, Qt and libuuid binaries in the directory cv2/.
+
+Libbluray, libgnutls, libnettle, libhogweed, libintl, libmp3lame, libp11,
+librtmp, libsoxr, libtasn1,  are redistributed within all opencv-python macOS packages.
+
+This license applies to the above library binaries in the directory cv2/.
 
                   GNU LESSER GENERAL PUBLIC LICENSE
                        Version 2.1, February 1999
@@ -543,54 +547,13 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 DAMAGES.
 
                      END OF TERMS AND CONDITIONS
-
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
 
 ------------------------------------------------------------------------------
 Qt 5 is redistributed within opencv-python macOS packages.
-This license applies to Qt binaries in the directory cv2/.
+libgmp is redistributed within opencv-python macOS packages.
+libidn2 is redistributed within opencv-python macOS packages.
+libunistring is redistributed within opencv-python macOS packages.
+This license applies to the above binaries in the directory cv2/.
 
                    GNU LESSER GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
@@ -800,185 +763,133 @@ Julian Seward, jseward@bzip.org
 bzip2/libbzip2 version 1.0.6 of 6 September 2010
 
 ------------------------------------------------------------------------------
-libcrypto and libssl are redistributed within all opencv-python Linux packages.
-This license applies to libcrypto and libssl binaries in the directory cv2/.
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        https://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
+libcrypto and libssl are redistributed within all opencv-python Linux and macOS packages.
+libopencore-amrnb and libopencore-amrwb are redistributed within all opencv-python Linux and macOS packages.
+This license applies to above binaries in the directory cv2/.
+
+  LICENSE ISSUES
+  ==============
+
+  The OpenSSL toolkit stays under a double license, i.e. both the conditions of
+  the OpenSSL License and the original SSLeay license apply to the toolkit.
+  See below for the actual license texts.
+
+  OpenSSL License
+  ---------------
+
+/* ====================================================================
+ * Copyright (c) 1998-2019 The OpenSSL Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. 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.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please contact
+ *    openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ *    nor may "OpenSSL" appear in their names without prior written
+ *    permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED 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 THE OpenSSL PROJECT OR
+ * ITS 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.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com).  This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+ Original SSLeay License
+ -----------------------
+
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay@cryptsoft.com)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
 
 ------------------------------------------------------------------------------
 libexpat is redistributed within all opencv-python Linux packages.
@@ -1007,7 +918,7 @@ 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 packages.
+libfontconfig is redistributed within all opencv-python Linux and macOS packages.
 This license applies to libfontconfig binary in the directory cv2/.
 
 Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard
@@ -1037,7 +948,7 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 PERFORMANCE OF THIS SOFTWARE.
 
 ------------------------------------------------------------------------------
-libfreetype is redistributed within opencv-python Linux packages.
+libfreetype is redistributed within opencv-python Linux and macOS packages.
 This license applies to libfreetype binary in the directory cv2/.
 
                     The FreeType Project LICENSE
@@ -1208,7 +1119,7 @@ Legal Terms
     https://www.freetype.org
 
 ------------------------------------------------------------------------------
-libpng is redistributed within all opencv-python Linux packages.
+libpng is redistributed within all opencv-python Linux and macOS packages.
 This license applies to libpng binary in the directory cv2/.
 
 PNG Reference Library License version 2
@@ -1622,3 +1533,799 @@ 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/.
+
+Copyright © 2018-2019, VideoLAN and dav1d authors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. 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.
+
+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 THE COPYRIGHT OWNER 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.
+
+------------------------------------------------------------------------------
+libffi is redistributed within opencv-python macOS packages.
+This license applies to libffi binary in the directory cv2/.
+
+libffi - Copyright (c) 1996-2020  Anthony Green, Red Hat, Inc and others.
+See source files for details.
+
+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.
+
+------------------------------------------------------------------------------
+libogg is redistributed within opencv-python macOS packages.
+This license applies to libogg binary in the directory cv2/.
+
+Copyright (c) 2002, Xiph.org Foundation
+
+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 name of the Xiph.org Foundation nor the names of its
+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 THE FOUNDATION
+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.
+
+------------------------------------------------------------------------------
+libopenjp2 is redistributed within opencv-python macOS packages.
+This license applies to libopenjp2 binary in the directory cv2/.
+
+The copyright in this software is being made available under the 2-clauses 
+BSD License, included below. This software may be subject to other third 
+party and contributor rights, including patent rights, and no such rights
+are granted under this license.
+
+Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
+Copyright (c) 2002-2014, Professor Benoit Macq
+Copyright (c) 2003-2014, Antonin Descampe
+Copyright (c) 2003-2009, Francois-Olivier Devaux
+Copyright (c) 2005, Herve Drolon, FreeImage Team
+Copyright (c) 2002-2003, Yannick Verschueren
+Copyright (c) 2001-2003, David Janssens
+Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
+Copyright (c) 2012, CS Systemes d'Information, France
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. 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.
+
+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 THE COPYRIGHT OWNER 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.
+
+------------------------------------------------------------------------------
+libopus is redistributed within opencv-python macOS packages.
+This license applies to libopus binary in the directory cv2/.
+
+Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic,
+                    Jean-Marc Valin, Timothy B. Terriberry,
+                    CSIRO, Gregory Maxwell, Mark Borgerding,
+                    Erik de Castro Lopo
+
+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 name of Internet Society, IETF or IETF Trust, nor the
+names of specific 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 THE COPYRIGHT OWNER
+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.
+
+Opus is subject to the royalty-free patent licenses which are
+specified at:
+
+Xiph.Org Foundation:
+https://datatracker.ietf.org/ipr/1524/
+
+Microsoft Corporation:
+https://datatracker.ietf.org/ipr/1914/
+
+Broadcom Corporation:
+https://datatracker.ietf.org/ipr/1526/
+
+------------------------------------------------------------------------------
+librav1e is redistributed within opencv-python macOS packages.
+This license applies to librav1e binary in the directory cv2/.
+
+BSD 2-Clause License
+
+Copyright (c) 2017-2020, the rav1e contributors
+All rights reserved.
+
+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.
+
+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 THE COPYRIGHT HOLDER 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.
+
+------------------------------------------------------------------------------
+libsnappy is redistributed within opencv-python macOS packages.
+This license applies to libsnappy binary in the directory cv2/.
+
+Copyright 2011, Google Inc.
+All rights reserved.
+
+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 name of Google Inc. nor the names of its
+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 THE COPYRIGHT
+OWNER 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.
+
+------------------------------------------------------------------------------
+libspeex is redistributed within opencv-python macOS packages.
+This license applies to libspeex binary in the directory cv2/.
+
+Copyright 2002-2008   Xiph.org Foundation
+Copyright 2002-2008   Jean-Marc Valin
+Copyright 2005-2007 Analog Devices Inc.
+Copyright 2005-2008 Commonwealth Scientific and Industrial Research 
+                        Organisation (CSIRO)
+Copyright 1993, 2002, 2006 David Rowe
+Copyright 2003    EpicGames
+Copyright 1992-1994 Jutta Degener, Carsten Bormann
+
+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 name of the Xiph.org Foundation nor the names of its
+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 THE FOUNDATION 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.
+
+------------------------------------------------------------------------------
+libsrt is redistributed within opencv-python macOS packages.
+This license applies to libsrt binary in the directory cv2/.
+
+/*
+ *  
+ * Copyright (c) 2001-2017 Cisco Systems, Inc.
+ * All rights reserved.
+ * 
+ * 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 name of the Cisco Systems, Inc. nor the names of its
+ *   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 THE
+ * 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.
+ *
+ */
+
+
+ Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in 
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
+
+------------------------------------------------------------------------------
+libtheoradec and libtheoraenc are redistributed within opencv-python macOS packages.
+This license applies to libtheoradec and libtheoraenc binaries in the directory cv2/.
+
+  Copyright (C) 2002-2009 Xiph.org Foundation
+
+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 name of the Xiph.org Foundation nor the names of its
+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 THE FOUNDATION
+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.
+
+------------------------------------------------------------------------------
+libwebp and libwebpmux are redistributed within opencv-python macOS packages.
+This license applies to libwebp  and libwebpmux binaries in the directory cv2/.
+
+Copyright (c) 2010, Google Inc. All rights reserved.
+
+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 name of Google nor the names of its 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 THE COPYRIGHT
+HOLDER 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.
+
+------------------------------------------------------------------------------
+libvorbis and libvorbisenc are redistributed within opencv-python macOS packages.
+This license applies to libvorbis and libvorbisenc binaries in the directory cv2/.
+
+Copyright (c) 2002-2020 Xiph.org Foundation
+
+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 name of the Xiph.org Foundation nor the names of its
+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 THE FOUNDATION
+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.
\ No newline at end of file

From 75bbcf68f18a64fbf43c0ee19ca439434e3c09c7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 19:23:21 +0300
Subject: [PATCH 120/345] initial sdist support

---
 .travis.yml     | 190 +++++++++++++++++++++++++++++++++---------------
 MANIFEST.in     |  10 +++
 find_version.py |  96 ++++++++++++------------
 pyproject.toml  |   2 +
 setup.py        |  84 ++++++---------------
 5 files changed, 219 insertions(+), 163 deletions(-)
 create mode 100644 MANIFEST.in
 create mode 100644 pyproject.toml

diff --git a/.travis.yml b/.travis.yml
index abdd069a..49d1ac4c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,10 +4,10 @@ env:
         # pip dependencies to _test_ your project
         - TEST_DEPENDS="numpy==1.11.1"
         # params to bdist_wheel. used to set osx build target.
-        - BDIST_PARAMS=""
         - CONFIG_PATH="travis_config.sh"
         - USE_CCACHE=1
         - UNICODE_WIDTH=32
+        - SDIST=0
 
 # Save some time, we and setup check them out on demand instead
 # https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth
@@ -28,6 +28,7 @@ stages:
 
 jobs:
   fast_finish: true
+  # Travis exclude is buggy, this seems to be the only way to disable default build
   exclude:
     - language: ruby
   include:
@@ -57,6 +58,40 @@ jobs:
           # used in OSX custom build script dealing with local bottle caching
           - $HOME/local_bottle_metadata
 
+    # source distributions
+    - os: linux
+      env:
+        - SDIST=1
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=0
+      python: "3.8"
+      language: python
+      dist: xenial
+    - os: linux
+      env:
+        - SDIST=1
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=1
+      python: "3.8"
+      language: python
+      dist: xenial
+    - os: linux
+      env:
+        - SDIST=1
+        - ENABLE_CONTRIB=1
+        - ENABLE_HEADLESS=0
+      python: "3.8"
+      language: python
+      dist: xenial
+    - os: linux
+      env:
+        - SDIST=1
+        - ENABLE_CONTRIB=1
+        - ENABLE_HEADLESS=1
+      python: "3.8"
+      language: python
+      dist: xenial
+
     # default builds for MacOS
       #further jobs in the list will use the same stage until the next assignment
     - stage: final
@@ -606,56 +641,74 @@ jobs:
 
 # The first line is printed in the folding header in Travis output
 before_install: |
-    # Check out and prepare the source
     set -e
-    # Multibuild doesn't have releases, so --depth would break eventually (see
-    # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-    git submodule update --init multibuild
-    echo "Source multibuild/common_utils.sh"
-    source multibuild/common_utils.sh
-    # https://github.com/matthew-brett/multibuild/issues/116
-    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-    echo "Source multibuild/travis_steps.sh"
-    source multibuild/travis_steps.sh
-    # This sets -x
-    echo "Source travis_multibuild_customize.sh"
-    source travis_multibuild_customize.sh
-    echo $ENABLE_CONTRIB > contrib.enabled
-    echo $ENABLE_HEADLESS > headless.enabled
 
-    if [ -n "$IS_OSX" ]; then
-        echo "homebrew"
-        TAPS="$(brew --repository)/Library/Taps"
-        if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
-            rm -rf "$TAPS/caskroom/homebrew-cask"
-        fi
-        find "$TAPS" -type d -name .git -exec \
-                bash -xec '
-                    cd $(dirname '\''{}'\'') || echo "status: $?"
-                    git clean -fxd || echo "status: $?"
-                    sleep 1 || echo "status: $?"
-                    git status || echo "status: $?"' \; || echo "status: $?"
+    if [ -z "$SDIST" ]; then
+        echo "sdist build"
+    else
+        # Check out and prepare the source
+        # Multibuild doesn't have releases, so --depth would break eventually (see
+        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+        git submodule update --init multibuild
 
-        brew_cache_cleanup
+        source multibuild/common_utils.sh
+
+        # https://github.com/matthew-brett/multibuild/issues/116
+        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+
+        source multibuild/travis_steps.sh
+        # This sets -x
+
+        source travis_multibuild_customize.sh
+        echo $ENABLE_CONTRIB > contrib.enabled
+        echo $ENABLE_HEADLESS > headless.enabled
+
+        if [ -n "$IS_OSX" ]; then
+            echo "homebrew"
+            TAPS="$(brew --repository)/Library/Taps"
+            if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
+                rm -rf "$TAPS/caskroom/homebrew-cask"
+            fi
+            find "$TAPS" -type d -name .git -exec \
+                    bash -xec '
+                        cd $(dirname '\''{}'\'') || echo "status: $?"
+                        git clean -fxd || echo "status: $?"
+                        sleep 1 || echo "status: $?"
+                        git status || echo "status: $?"' \; || echo "status: $?"
+            brew_cache_cleanup
+        fi
+        echo "end"
+        # Not interested in travis internal scripts' output
     fi
-    echo "end"
-    # Not interested in travis internal scripts' output
+
     set +x
 
 install: |
     # Build and package
     set -x
-    build_wheel $REPO_DIR $PLAT
+
+    if [ -z "$SDIST" ]; then
+        python setup.py sdist
+    else
+        build_wheel $REPO_DIR $PLAT
+    fi
+
     set +x
 
 script: |
     # Install and run tests
     set -x
-    install_run $PLAT && rc=$? || rc=$?
+
+    if [ -z "$SDIST" ]; then
+      echo "sdist"
+    else
+        install_run $PLAT && rc=$? || rc=$?
+    fi
+
     set +x
 
-    #otherwise, Travis logic terminates prematurely
-    #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
+    # otherwise, Travis logic terminates prematurely
+    # https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
 
     test "$rc" -eq 0
@@ -676,19 +729,11 @@ before_cache: |
     set +x; set +e
 
 after_success: |
-    # Upload wheels to pypi if tag is set, otherwise save to Azure Storage
-    if [ -n "$TRAVIS_TAG" ]; then
-        set -x
+    # Upload wheels to pypi if tag is set
 
-        if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-          pip install --user twine
-          pip install --user --upgrade six
-        fi
+    set -x
 
-        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-          pip install twine
-          pip install --upgrade pyOpenSSL
-        fi
+    if [ -n "$TRAVIS_TAG" ]; then
 
         if [[ $ENABLE_CONTRIB == 0 ]]; then
             if [[ $ENABLE_HEADLESS == 0 ]]; then
@@ -704,19 +749,50 @@ after_success: |
             fi
         fi
 
-        twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
-        set +x
-    else
-        set -x
-
         if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-          curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
-        else
-          brew install azure-cli
+          pip install --user twine
+          pip install --user --upgrade six
+
+          if [ -z "$SDIST" ]; then
+            twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
+          else
+            twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
+          fi
+
         fi
 
-        az storage container create -n ${TRAVIS_COMMIT} --public-access blob
-        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
+        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
+          # macpython 3.5 doesn't support recent TLS protocols which causes twine
+          # upload to fail, so we use the system Python to run twine
+          /usr/bin/python -m ensurepip --user
+          /usr/bin/python -m pip install --user -U pip
+          /usr/bin/python -m pip install --user -U -I twine
+
+          if [ -z "$SDIST" ]; then
+            /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
+          else
+            /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
+          fi
+
+        fi
 
-        set -x
     fi
+
+    # Save to Azure storage always
+
+    if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+      curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
+    else
+      brew install azure-cli
+    fi
+
+    az storage container create -n ${TRAVIS_COMMIT} --public-access blob
+
+    if [ -z "$SDIST" ]; then
+      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
+    else
+      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
+    fi
+
+    set +x
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 00000000..480bb3d4
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,10 @@
+include LICENSE-3RD-PARTY.txt
+include LICENSE.txt
+include README.md
+include find_version.py
+include setup.py
+recursive-include cv2 *
+recursive-include docker *
+recursive-include opencv *
+recursive-include opencv_contrib *
+recursive-include patches *
diff --git a/find_version.py b/find_version.py
index 519542e4..b7ad0613 100644
--- a/find_version.py
+++ b/find_version.py
@@ -2,49 +2,53 @@
 import os
 import subprocess
 
-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 <tag>-<n>-g<shortened sha-1>
-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)
-
-print("Version: ", opencv_version)
-
-with open('cv_version.py', 'w') as f:
-    f.write('opencv_version = "{}"'.format(opencv_version))
+if __name__ == "__main__":
+  contrib = sys.argv[1]
+  headless = sys.argv[2]
+
+  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 <tag>-<n>-g<shortened sha-1>
+  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 = {}".format(headless))
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..ef8a4804
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,2 @@
+[build-system]
+requires = ["setuptools", "wheel", "scikit-build", "cmake"]
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 843d5f03..4bde2f7f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,3 @@
-# No 3rd-party modules here, see "3rd-party" note below
 import io
 import os
 import os.path
@@ -7,23 +6,20 @@
 import subprocess
 import re
 import sysconfig
+import skbuild
+from skbuild import cmaker
 
 
 def main():
-
     os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
-    # These are neede for source fetching
+    # These are needed for source fetching
     cmake_source_dir = "opencv"
+    minimum_supported_numpy = "1.11.1"
     build_contrib = get_build_env_var_by_name("contrib")
     # headless flag to skip GUI deps if needed
     build_headless = get_build_env_var_by_name("headless")
 
-    # Only import 3rd-party modules after having installed all the build dependencies:
-    # any of them, or their dependencies, can be updated during that process,
-    # leading to version conflicts
-    minimum_supported_numpy = "1.11.1"
-
     if sys.version_info[:2] >= (3, 6):
         minimum_supported_numpy = "1.11.3"
     if sys.version_info[:2] >= (3, 7):
@@ -31,21 +27,14 @@ def main():
     if sys.version_info[:2] >= (3, 8):
         minimum_supported_numpy = "1.17.3"
 
-    numpy_version = get_or_install("numpy", minimum_supported_numpy)
-    get_or_install("scikit-build")
-    get_or_install("cmake")
-
-    import skbuild
-    from skbuild import cmaker
+    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"])
@@ -58,6 +47,8 @@ def main():
                 ["submodule", "update", "--init", "--recursive", "opencv_contrib"]
             )
 
+    package_version, build_contrib, build_headless = get_opencv_version(build_contrib, build_headless)
+
     # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
     x64 = sys.maxsize > 2 ** 32
 
@@ -73,12 +64,11 @@ def main():
         package_name = "opencv-python-headless"
 
     long_description = io.open("README.md", encoding="utf-8").read()
-    package_version = get_opencv_version()
 
     packages = ["cv2", "cv2.data"]
 
     package_data = {
-        "cv2": ["*%s" % sysconfig.get_config_vars().get("SO")]
+        "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"],
@@ -96,7 +86,7 @@ def main():
         # In Windows, in python/X.Y/<arch>/; 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("SO"))}],
+        ["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"
         ],
@@ -108,7 +98,7 @@ def main():
 
     cmake_args = (
         (
-            ["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
+            ["-G", "Visual Studio 15" + (" Win64" if x64 else "")]
             if os.name == "nt"
             else ["-G", "Unix Makefiles"]  # don't make CMake try (and fail) Ninja first
         )
@@ -170,15 +160,6 @@ def main():
     if sys.platform == "darwin":
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
-    # Fixes for macOS builds
-    if sys.platform == "darwin":
-        cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")
-
-    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()
@@ -197,7 +178,7 @@ def main():
         maintainer="Olli-Pekka Heinisuo",
         include_package_data=True,
         ext_modules=EmptyListWithLength(),
-        install_requires="numpy>=%s" % numpy_version,
+        install_requires=numpy_version,
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Environment :: Console",
@@ -377,19 +358,22 @@ def _classify_installed_files_override(
             cmake_install_dir=cmake_install_reldir,
         )
 
+def get_opencv_version(contrib, headless):
+    # 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")
 
-def install_packages(*requirements):
-    # No more convenient way until PEP 518 is implemented; setuptools only handles eggs
-    subprocess.check_call([sys.executable, "-m", "pip", "install"] + list(requirements))
-
+    if not os.path.exists(version_file):
+      old_args = sys.argv.copy()
+      sys.argv = ['', str(contrib), str(headless)]
+      runpy.run_path("find_version.py ", run_name="__main__")
+      sys.argv = old_args
 
-def get_opencv_version():
-    # cv_version.py should be generated by running find_version.py
-    runpy.run_path("find_version.py")
-    from cv_version import opencv_version
-
-    return opencv_version
+    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
@@ -407,26 +391,6 @@ def get_build_env_var_by_name(flag_name):
 
     return flag_set
 
-
-def get_or_install(name, version=None):
-    """ If a package is already installed, build against it. If not, install """
-    # Do not import 3rd-party modules into the current process
-    import json
-
-    js_packages = json.loads(
-        subprocess.check_output(
-            [sys.executable, "-m", "pip", "list", "--format", "json"]
-        ).decode("ascii")
-    )  # valid names & versions are ASCII as per PEP 440
-    try:
-        [package] = (package for package in js_packages if package["name"] == name)
-    except ValueError:
-        install_packages("%s==%s" % (name, version) if version else name)
-        return version
-    else:
-        return package["version"]
-
-
 # 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):

From 55fc534a6776bec8f2c61834c8d9e273ff042ad5 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:17:34 +0300
Subject: [PATCH 121/345] multiple fixes

---
 .travis.yml      | 14 ++++++++------
 MANIFEST.in      |  1 +
 appveyor.yml     |  2 +-
 pyproject.toml   |  8 +++++++-
 setup.py         |  5 ++---
 travis_config.sh |  2 +-
 6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 49d1ac4c..2f5a9874 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -643,7 +643,7 @@ jobs:
 before_install: |
     set -e
 
-    if [ -z "$SDIST" ]; then
+    if [ -n "$SDIST" ]; then
         echo "sdist build"
     else
         # Check out and prepare the source
@@ -687,7 +687,9 @@ install: |
     # Build and package
     set -x
 
-    if [ -z "$SDIST" ]; then
+    if [ -n "$SDIST" ]; then
+        python -m pip install --upgrade pip
+        python -m pip install scikit-build
         python setup.py sdist
     else
         build_wheel $REPO_DIR $PLAT
@@ -699,7 +701,7 @@ script: |
     # Install and run tests
     set -x
 
-    if [ -z "$SDIST" ]; then
+    if [ -n "$SDIST" ]; then
       echo "sdist"
     else
         install_run $PLAT && rc=$? || rc=$?
@@ -753,7 +755,7 @@ after_success: |
           pip install --user twine
           pip install --user --upgrade six
 
-          if [ -z "$SDIST" ]; then
+          if [ -n "$SDIST" ]; then
             twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
           else
             twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
@@ -768,7 +770,7 @@ after_success: |
           /usr/bin/python -m pip install --user -U pip
           /usr/bin/python -m pip install --user -U -I twine
 
-          if [ -z "$SDIST" ]; then
+          if [ -n "$SDIST" ]; then
             /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
           else
             /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
@@ -788,7 +790,7 @@ after_success: |
 
     az storage container create -n ${TRAVIS_COMMIT} --public-access blob
 
-    if [ -z "$SDIST" ]; then
+    if [ -n "$SDIST" ]; then
       az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
     else
       az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
diff --git a/MANIFEST.in b/MANIFEST.in
index 480bb3d4..45cb6c40 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,6 +3,7 @@ include LICENSE.txt
 include README.md
 include find_version.py
 include setup.py
+include pyproject.toml
 recursive-include cv2 *
 recursive-include docker *
 recursive-include opencv *
diff --git a/appveyor.yml b/appveyor.yml
index dab586c7..ada90638 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    "%PYTHON%/python.exe" setup.py bdist_wheel
+    "%PYTHON%/python.exe" -m pip wheel . --no-build-isolation --verbose
 
 before_test:
 - ps: |
diff --git a/pyproject.toml b/pyproject.toml
index ef8a4804..7522b5ef 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,8 @@
 [build-system]
-requires = ["setuptools", "wheel", "scikit-build", "cmake"]
\ No newline at end of file
+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
diff --git a/setup.py b/setup.py
index 4bde2f7f..fe8cbd47 100644
--- a/setup.py
+++ b/setup.py
@@ -15,13 +15,13 @@ def main():
 
     # These are needed for source fetching
     cmake_source_dir = "opencv"
-    minimum_supported_numpy = "1.11.1"
+    minimum_supported_numpy = "1.13.1"
     build_contrib = get_build_env_var_by_name("contrib")
     # headless flag to skip GUI deps if needed
     build_headless = get_build_env_var_by_name("headless")
 
     if sys.version_info[:2] >= (3, 6):
-        minimum_supported_numpy = "1.11.3"
+        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):
@@ -176,7 +176,6 @@ def main():
         packages=packages,
         package_data=package_data,
         maintainer="Olli-Pekka Heinisuo",
-        include_package_data=True,
         ext_modules=EmptyListWithLength(),
         install_requires=numpy_version,
         classifiers=[
diff --git a/travis_config.sh b/travis_config.sh
index fbf565b5..480a547b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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
-    python setup.py bdist_wheel $BDIST_PARAMS
+    pip wheel . --no-build-isolation --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }

From eb679346a89f54bd9d669a00ffb1304dd3ad1ca4 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:20:30 +0300
Subject: [PATCH 122/345] fix typo

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index fe8cbd47..e9b8b93a 100644
--- a/setup.py
+++ b/setup.py
@@ -366,7 +366,7 @@ def get_opencv_version(contrib, headless):
     if not os.path.exists(version_file):
       old_args = sys.argv.copy()
       sys.argv = ['', str(contrib), str(headless)]
-      runpy.run_path("find_version.py ", run_name="__main__")
+      runpy.run_path("find_version.py", run_name="__main__")
       sys.argv = old_args
 
     with open(version_file) as fp:

From 9c911168a0cde6b1bb5e8eec2ca5fcf88cb2c841 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:21:50 +0300
Subject: [PATCH 123/345] add stage

---
 .travis.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 2f5a9874..d3cbd821 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -60,6 +60,7 @@ jobs:
 
     # source distributions
     - os: linux
+      stage: s1
       env:
         - SDIST=1
         - ENABLE_CONTRIB=0
@@ -68,6 +69,7 @@ jobs:
       language: python
       dist: xenial
     - os: linux
+      stage: s1
       env:
         - SDIST=1
         - ENABLE_CONTRIB=0
@@ -76,6 +78,7 @@ jobs:
       language: python
       dist: xenial
     - os: linux
+      stage: s1
       env:
         - SDIST=1
         - ENABLE_CONTRIB=1
@@ -84,6 +87,7 @@ jobs:
       language: python
       dist: xenial
     - os: linux
+      stage: s1
       env:
         - SDIST=1
         - ENABLE_CONTRIB=1

From b404b877c91849570eb368ff26290980c611b863 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:34:12 +0300
Subject: [PATCH 124/345] more fixes

---
 .travis.yml  | 72 ++++++++++++++++++++++++++--------------------------
 appveyor.yml |  2 +-
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d3cbd821..4af08b7d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -647,7 +647,7 @@ jobs:
 before_install: |
     set -e
 
-    if [ -n "$SDIST" ]; then
+    if [[ $SDIST == 1 ]]; then
         echo "sdist build"
     else
         # Check out and prepare the source
@@ -691,7 +691,7 @@ install: |
     # Build and package
     set -x
 
-    if [ -n "$SDIST" ]; then
+    if [[ $SDIST == 1 ]]; then
         python -m pip install --upgrade pip
         python -m pip install scikit-build
         python setup.py sdist
@@ -705,7 +705,7 @@ script: |
     # Install and run tests
     set -x
 
-    if [ -n "$SDIST" ]; then
+    if [[ $SDIST == 1 ]]; then
       echo "sdist"
     else
         install_run $PLAT && rc=$? || rc=$?
@@ -741,47 +741,47 @@ after_success: |
 
     if [ -n "$TRAVIS_TAG" ]; then
 
-        if [[ $ENABLE_CONTRIB == 0 ]]; then
-            if [[ $ENABLE_HEADLESS == 0 ]]; then
-              echo "This is default build. Deployment will be done to to PyPI entry opencv-python."
-            else
-              echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-python-headless."
-            fi
-        else
-            if [[ $ENABLE_HEADLESS == 0 ]]; then
-              echo "This is contrib build. Deployment will be done to to PyPI entry opencv-contrib-python."
-            else
-              echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-contrib-python-headless."
-            fi
-        fi
-
-        if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-          pip install --user twine
-          pip install --user --upgrade six
-
-          if [ -n "$SDIST" ]; then
-            twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
+      if [[ $ENABLE_CONTRIB == 0 ]]; then
+          if [[ $ENABLE_HEADLESS == 0 ]]; then
+            echo "This is default build. Deployment will be done to to PyPI entry opencv-python."
+          else
+            echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-python-headless."
+          fi
+      else
+          if [[ $ENABLE_HEADLESS == 0 ]]; then
+            echo "This is contrib build. Deployment will be done to to PyPI entry opencv-contrib-python."
           else
-            twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
+            echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-contrib-python-headless."
           fi
+      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
+        else
+          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
-        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-          # macpython 3.5 doesn't support recent TLS protocols which causes twine
-          # upload to fail, so we use the system Python to run twine
-          /usr/bin/python -m ensurepip --user
-          /usr/bin/python -m pip install --user -U pip
-          /usr/bin/python -m pip install --user -U -I twine
+      fi
 
-          if [ -n "$SDIST" ]; then
-            /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
-          else
-            /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
-          fi
+      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
+        # macpython 3.5 doesn't support recent TLS protocols which causes twine
+        # upload to fail, so we use the system Python to run twine
+        /usr/bin/python -m ensurepip --user
+        /usr/bin/python -m pip install --user -U pip
+        /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
+        else
+          /usr/bin/python -m upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
+      fi
+
     fi
 
     # Save to Azure storage always
@@ -794,7 +794,7 @@ after_success: |
 
     az storage container create -n ${TRAVIS_COMMIT} --public-access blob
 
-    if [ -n "$SDIST" ]; then
+    if [[ $SDIST == 1 ]]; then
       az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
     else
       az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
diff --git a/appveyor.yml b/appveyor.yml
index ada90638..511140c5 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    "%PYTHON%/python.exe" -m pip wheel . --no-build-isolation --verbose
+    "%PYTHON%/python.exe" -m pip wheel . --verbose
 
 before_test:
 - ps: |

From 6a9d2f1c64937c4883cfa077a82e2f2fa8e9efbe Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:39:30 +0300
Subject: [PATCH 125/345] Visual Studio 14, travis fixes

---
 .travis.yml | 106 ++++++++++++++++++++++++++--------------------------
 setup.py    |   2 +-
 2 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4af08b7d..0b49e310 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -648,41 +648,41 @@ before_install: |
     set -e
 
     if [[ $SDIST == 1 ]]; then
-        echo "sdist build"
+      echo "sdist build"
     else
-        # Check out and prepare the source
-        # Multibuild doesn't have releases, so --depth would break eventually (see
-        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-        git submodule update --init multibuild
-
-        source multibuild/common_utils.sh
-
-        # https://github.com/matthew-brett/multibuild/issues/116
-        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-
-        source multibuild/travis_steps.sh
-        # This sets -x
-
-        source travis_multibuild_customize.sh
-        echo $ENABLE_CONTRIB > contrib.enabled
-        echo $ENABLE_HEADLESS > headless.enabled
-
-        if [ -n "$IS_OSX" ]; then
-            echo "homebrew"
-            TAPS="$(brew --repository)/Library/Taps"
-            if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
-                rm -rf "$TAPS/caskroom/homebrew-cask"
-            fi
-            find "$TAPS" -type d -name .git -exec \
-                    bash -xec '
-                        cd $(dirname '\''{}'\'') || echo "status: $?"
-                        git clean -fxd || echo "status: $?"
-                        sleep 1 || echo "status: $?"
-                        git status || echo "status: $?"' \; || echo "status: $?"
-            brew_cache_cleanup
+      # Check out and prepare the source
+      # Multibuild doesn't have releases, so --depth would break eventually (see
+      # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+      git submodule update --init multibuild
+
+      source multibuild/common_utils.sh
+
+      # https://github.com/matthew-brett/multibuild/issues/116
+      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+
+      source multibuild/travis_steps.sh
+      # This sets -x
+
+      source travis_multibuild_customize.sh
+      echo $ENABLE_CONTRIB > contrib.enabled
+      echo $ENABLE_HEADLESS > headless.enabled
+
+      if [ -n "$IS_OSX" ]; then
+        echo "homebrew"
+        TAPS="$(brew --repository)/Library/Taps"
+        if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
+            rm -rf "$TAPS/caskroom/homebrew-cask"
         fi
-        echo "end"
-        # Not interested in travis internal scripts' output
+        find "$TAPS" -type d -name .git -exec \
+                bash -xec '
+                    cd $(dirname '\''{}'\'') || echo "status: $?"
+                    git clean -fxd || echo "status: $?"
+                    sleep 1 || echo "status: $?"
+                    git status || echo "status: $?"' \; || echo "status: $?"
+        brew_cache_cleanup
+      fi
+      echo "end"
+      # Not interested in travis internal scripts' output
     fi
 
     set +x
@@ -692,11 +692,11 @@ install: |
     set -x
 
     if [[ $SDIST == 1 ]]; then
-        python -m pip install --upgrade pip
-        python -m pip install scikit-build
-        python setup.py sdist
+      python -m pip install --upgrade pip
+      python -m pip install scikit-build
+      python setup.py sdist
     else
-        build_wheel $REPO_DIR $PLAT
+      build_wheel $REPO_DIR $PLAT
     fi
 
     set +x
@@ -708,7 +708,7 @@ script: |
     if [[ $SDIST == 1 ]]; then
       echo "sdist"
     else
-        install_run $PLAT && rc=$? || rc=$?
+      install_run $PLAT && rc=$? || rc=$?
     fi
 
     set +x
@@ -724,12 +724,12 @@ before_cache: |
     set -e; set -x
     if [ -n "$IS_OSX" ]; then
 
-        # When Taps is cached, this dir causes "Error: file exists" on `brew update`
-        if [ -e "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask" ]; then
-            rm -rf "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask"
-        fi
+      # When Taps is cached, this dir causes "Error: file exists" on `brew update`
+      if [ -e "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask" ]; then
+        rm -rf "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask"
+      fi
 
-        brew_cache_cleanup
+      brew_cache_cleanup
 
     fi
     set +x; set +e
@@ -742,17 +742,17 @@ after_success: |
     if [ -n "$TRAVIS_TAG" ]; then
 
       if [[ $ENABLE_CONTRIB == 0 ]]; then
-          if [[ $ENABLE_HEADLESS == 0 ]]; then
-            echo "This is default build. Deployment will be done to to PyPI entry opencv-python."
-          else
-            echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-python-headless."
-          fi
+        if [[ $ENABLE_HEADLESS == 0 ]]; then
+          echo "This is default build. Deployment will be done to to PyPI entry opencv-python."
+        else
+          echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-python-headless."
+        fi
       else
-          if [[ $ENABLE_HEADLESS == 0 ]]; then
-            echo "This is contrib build. Deployment will be done to to PyPI entry opencv-contrib-python."
-          else
-            echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-contrib-python-headless."
-          fi
+        if [[ $ENABLE_HEADLESS == 0 ]]; then
+          echo "This is contrib build. Deployment will be done to to PyPI entry opencv-contrib-python."
+        else
+          echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-contrib-python-headless."
+        fi
       fi
 
       if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
diff --git a/setup.py b/setup.py
index e9b8b93a..acd585f6 100644
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ def main():
 
     cmake_args = (
         (
-            ["-G", "Visual Studio 15" + (" Win64" if x64 else "")]
+            ["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
             if os.name == "nt"
             else ["-G", "Unix Makefiles"]  # don't make CMake try (and fail) Ninja first
         )

From 09f01ddbda6c6ffc121fb21dc86a4f0748d31f74 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:46:20 +0300
Subject: [PATCH 126/345] clean up travis

---
 .travis.yml | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 0b49e310..120ed69b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -647,9 +647,7 @@ jobs:
 before_install: |
     set -e
 
-    if [[ $SDIST == 1 ]]; then
-      echo "sdist build"
-    else
+    if [[ $SDIST == 0 ]]; then
       # Check out and prepare the source
       # Multibuild doesn't have releases, so --depth would break eventually (see
       # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
@@ -703,16 +701,13 @@ install: |
 
 script: |
     # Install and run tests
-    set -x
 
-    if [[ $SDIST == 1 ]]; then
-      echo "sdist"
-    else
+    if [[ $SDIST == 0 ]]; then
+      set -x
       install_run $PLAT && rc=$? || rc=$?
+      set +x
     fi
 
-    set +x
-
     # otherwise, Travis logic terminates prematurely
     # https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR

From 9fe282b6c5accf635366e9a18e4ac2d1d99a8d92 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:52:00 +0300
Subject: [PATCH 127/345] trying to fix travis...

---
 .travis.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 120ed69b..c2462d8f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -701,17 +701,15 @@ install: |
 
 script: |
     # Install and run tests
-
     if [[ $SDIST == 0 ]]; then
       set -x
       install_run $PLAT && rc=$? || rc=$?
       set +x
     fi
 
-    # otherwise, Travis logic terminates prematurely
-    # https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
+    #otherwise, Travis logic terminates prematurely
+    #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
-
     test "$rc" -eq 0
 
 before_cache: |

From 51dcf9c06bda466df6d284e2ab95f0e8fd061347 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 13 Jul 2020 23:58:02 +0300
Subject: [PATCH 128/345] need to source multibuild to get past tests

---
 .travis.yml | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c2462d8f..f80a8de7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -647,21 +647,22 @@ jobs:
 before_install: |
     set -e
 
-    if [[ $SDIST == 0 ]]; then
-      # Check out and prepare the source
-      # Multibuild doesn't have releases, so --depth would break eventually (see
-      # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-      git submodule update --init multibuild
+    # Check out and prepare the source
+    # Multibuild doesn't have releases, so --depth would break eventually (see
+    # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+    git submodule update --init multibuild
+
+    source multibuild/common_utils.sh
 
-      source multibuild/common_utils.sh
+    # https://github.com/matthew-brett/multibuild/issues/116
+    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
 
-      # https://github.com/matthew-brett/multibuild/issues/116
-      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+    source multibuild/travis_steps.sh
+    # This sets -x
+    source travis_multibuild_customize.sh
 
-      source multibuild/travis_steps.sh
-      # This sets -x
+    if [[ $SDIST == 0 ]]; then
 
-      source travis_multibuild_customize.sh
       echo $ENABLE_CONTRIB > contrib.enabled
       echo $ENABLE_HEADLESS > headless.enabled
 

From 615cca37946456c4a4b348c2131af8929672fa0d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 00:10:37 +0300
Subject: [PATCH 129/345] save wheels to dist

---
 .travis.yml      | 32 +++++++++++++++++---------------
 appveyor.yml     |  2 +-
 travis_config.sh |  2 +-
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f80a8de7..ba7c691d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -647,22 +647,21 @@ jobs:
 before_install: |
     set -e
 
-    # Check out and prepare the source
-    # Multibuild doesn't have releases, so --depth would break eventually (see
-    # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-    git submodule update --init multibuild
-
-    source multibuild/common_utils.sh
+    if [[ $SDIST == 0 ]]; then
+      # Check out and prepare the source
+      # Multibuild doesn't have releases, so --depth would break eventually (see
+      # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+      git submodule update --init multibuild
 
-    # https://github.com/matthew-brett/multibuild/issues/116
-    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+      source multibuild/common_utils.sh
 
-    source multibuild/travis_steps.sh
-    # This sets -x
-    source travis_multibuild_customize.sh
+      # https://github.com/matthew-brett/multibuild/issues/116
+      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
 
-    if [[ $SDIST == 0 ]]; then
+      source multibuild/travis_steps.sh
+      # This sets -x
 
+      source travis_multibuild_customize.sh
       echo $ENABLE_CONTRIB > contrib.enabled
       echo $ENABLE_HEADLESS > headless.enabled
 
@@ -702,12 +701,15 @@ install: |
 
 script: |
     # Install and run tests
-    if [[ $SDIST == 0 ]]; then
-      set -x
+    set -x
+    if [[ $SDIST == 1 ]]; then
+      echo "skipping tests because of sdist"
+    else
       install_run $PLAT && rc=$? || rc=$?
-      set +x
     fi
 
+    set +x
+
     #otherwise, Travis logic terminates prematurely
     #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
     trap ERR
diff --git a/appveyor.yml b/appveyor.yml
index 511140c5..4dd3421d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    "%PYTHON%/python.exe" -m pip wheel . --verbose
+    "%PYTHON%/python.exe" -m pip wheel . --verbose --wheel-dir=dist
 
 before_test:
 - ps: |
diff --git a/travis_config.sh b/travis_config.sh
index 480a547b..a30a42db 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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
-    pip wheel . --no-build-isolation --verbose $BDIST_PARAMS
+    pip wheel . --no-build-isolation --verbose --wheel-dir=dist $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }

From 106a9d81afc0636638f29b366ed32a6569b00db8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 00:14:50 +0300
Subject: [PATCH 130/345] try to skip the script step

---
 .travis.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index ba7c691d..37e1b0fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -61,6 +61,7 @@ jobs:
     # source distributions
     - os: linux
       stage: s1
+      script: skip
       env:
         - SDIST=1
         - ENABLE_CONTRIB=0
@@ -70,6 +71,7 @@ jobs:
       dist: xenial
     - os: linux
       stage: s1
+      script: skip
       env:
         - SDIST=1
         - ENABLE_CONTRIB=0
@@ -79,6 +81,7 @@ jobs:
       dist: xenial
     - os: linux
       stage: s1
+      script: skip
       env:
         - SDIST=1
         - ENABLE_CONTRIB=1
@@ -88,6 +91,7 @@ jobs:
       dist: xenial
     - os: linux
       stage: s1
+      script: skip
       env:
         - SDIST=1
         - ENABLE_CONTRIB=1

From fead8dfd58d842cd40e6b394f1e7e3810cfe1e0c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 00:59:58 +0300
Subject: [PATCH 131/345] try absolute path

---
 appveyor.yml     | 2 +-
 travis_config.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 4dd3421d..0a6e47f0 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    "%PYTHON%/python.exe" -m pip wheel . --verbose --wheel-dir=dist
+    "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
 
 before_test:
 - ps: |
diff --git a/travis_config.sh b/travis_config.sh
index a30a42db..9a079e8c 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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
-    pip wheel . --no-build-isolation --verbose --wheel-dir=dist $BDIST_PARAMS
+    pip wheel . --wheel-dir="$PWD/dist" --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }

From 43adb25e89e407bb51a6dd05e43f8021c7163c33 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 15:22:12 +0300
Subject: [PATCH 132/345] fix regression

---
 setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index acd585f6..640bf3ea 100644
--- a/setup.py
+++ b/setup.py
@@ -154,10 +154,10 @@ def main():
         cmake_args.append("-DWITH_LAPACK=ON")
         cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
-    if sys.platform.startswith("linux") and not x64:
+    if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
-    if sys.platform == "darwin":
+    if sys.platform == "darwin" and "bdist_wheel" in sys.argv:
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
     # works via side effect

From 9e21313bd8990e918e0b58654672f342a391eb35 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 15:25:01 +0300
Subject: [PATCH 133/345] ignore warning

---
 appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/appveyor.yml b/appveyor.yml
index 0a6e47f0..46ea0087 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -148,7 +148,7 @@ before_test:
 
     cd ${Env:APPVEYOR_BUILD_FOLDER}\tests
     $env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
-    &"${Env:PYTHON}/python.exe" -m pip install --user (ls "../dist/opencv_*.whl")
+    &"${Env:PYTHON}/python.exe" -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
     if ($LastExitCode -ne 0) {throw $LastExitCode}
 
 test_script:

From 243e27398e9e09620c6e77bddbc84f462a05470b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 14 Jul 2020 22:08:26 +0300
Subject: [PATCH 134/345] upload only opencv wheels

---
 .travis.yml  | 2 +-
 appveyor.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 37e1b0fd..aa3093fc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -797,7 +797,7 @@ after_success: |
     if [[ $SDIST == 1 ]]; then
       az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
     else
-      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern *.whl
+      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
     fi
 
     set +x
diff --git a/appveyor.yml b/appveyor.yml
index 46ea0087..03980bbf 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -158,7 +158,7 @@ test_script:
     "%PYTHON%/python.exe" -m unittest test
 
 artifacts:
-- path: dist\*.whl
+- path: dist\opencv*.whl
   name: wheels
 
 deploy_script:

From 705d1f0602fa147ca7945150238717af71c231c2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 15:18:05 +0300
Subject: [PATCH 135/345] use python instead of ruby

---
 .travis.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index aa3093fc..e6880e71 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,6 +20,8 @@ cache:
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
 
+language: python
+
 # Add more cache stages (s2 etc) and corresponding OSX jobs like s1
 # if brew builds start to take longer than one Travis time limit
 stages:
@@ -30,7 +32,7 @@ jobs:
   fast_finish: true
   # Travis exclude is buggy, this seems to be the only way to disable default build
   exclude:
-    - language: ruby
+    - language: python
   include:
     - os: osx
       env:

From 9a33dcf847cc9bc0a08ce73a66fc6e89f1f6645a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 16:16:56 +0300
Subject: [PATCH 136/345] test

---
 .travis.yml      | 4 +---
 travis_config.sh | 3 ++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index e6880e71..aa3093fc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,8 +20,6 @@ cache:
     # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
     - $HOME/.ccache
 
-language: python
-
 # Add more cache stages (s2 etc) and corresponding OSX jobs like s1
 # if brew builds start to take longer than one Travis time limit
 stages:
@@ -32,7 +30,7 @@ jobs:
   fast_finish: true
   # Travis exclude is buggy, this seems to be the only way to disable default build
   exclude:
-    - language: python
+    - language: ruby
   include:
     - os: osx
       env:
diff --git a/travis_config.sh b/travis_config.sh
index 9a079e8c..d606c838 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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
-    pip wheel . --wheel-dir="$PWD/dist" --verbose $BDIST_PARAMS
+    pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
@@ -110,6 +110,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew unlink python@2
+        brew update
         brew install ffmpeg_opencv
     fi
 

From 43a2cb8623e31f038e50bc65f48392041c6c171c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 16:59:48 +0300
Subject: [PATCH 137/345] verbose

---
 travis_config.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index d606c838..2f97fe9d 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -110,8 +110,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew unlink python@2
-        brew update
-        brew install ffmpeg_opencv
+        brew install ffmpeg_opencv --vd
     fi
 
     if [ -n "$CACHE_STAGE" ]; then

From 3f8604adbf329027b7dbe00eb0c672fe51cb3102 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 18:16:30 +0300
Subject: [PATCH 138/345] try to vendor ruby

---
 appveyor.yml     |  2 +-
 setup.py         | 93 ++++++++++++++++++++++++++++++------------------
 travis_config.sh |  6 ++--
 3 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 03980bbf..3a4fcb75 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
+    set "CI_BUILD=True" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
 
 before_test:
 - ps: |
diff --git a/setup.py b/setup.py
index 640bf3ea..6d9be880 100644
--- a/setup.py
+++ b/setup.py
@@ -13,11 +13,11 @@
 def main():
     os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
-    # These are needed for source fetching
+    CI_BUILD = os.environ.get("CI_BUILD", "False")
+    is_CI_build = True if CI_BUILD == "True" else False
     cmake_source_dir = "opencv"
     minimum_supported_numpy = "1.13.1"
     build_contrib = get_build_env_var_by_name("contrib")
-    # headless flag to skip GUI deps if needed
     build_headless = get_build_env_var_by_name("headless")
 
     if sys.version_info[:2] >= (3, 6):
@@ -30,11 +30,16 @@ def main():
     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('\\', '/')
+    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"])
@@ -47,7 +52,9 @@ def main():
                 ["submodule", "update", "--init", "--recursive", "opencv_contrib"]
             )
 
-    package_version, build_contrib, build_headless = get_opencv_version(build_contrib, build_headless)
+    package_version, build_contrib, build_headless = get_opencv_version(
+        build_contrib, build_headless
+    )
 
     # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
     x64 = sys.maxsize > 2 ** 32
@@ -86,7 +93,10 @@ def main():
         # In Windows, in python/X.Y/<arch>/; 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"))}],
+        [
+            "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"
         ],
@@ -96,12 +106,14 @@ def main():
     # 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 = (
-        (
-            ["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
-            if os.name == "nt"
-            else ["-G", "Unix Makefiles"]  # don't make CMake try (and fail) Ninja first
-        )
+        (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,
@@ -131,33 +143,40 @@ def main():
         )
     )
 
-    # OS-specific components
-    if sys.platform.startswith('linux') and not build_headless:
-        cmake_args.append("-DWITH_QT=4")
-
-    if sys.platform == 'darwin' and not build_headless:
-        cmake_args.append("-DWITH_QT=5")
-        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-            (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
-        ]
-
     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_MSMF=OFF"
-        )  # see: https://github.com/skvark/opencv-python/issues/263
+        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
+
+    # 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.startswith("linux"):
-        cmake_args.append("-DWITH_V4L=ON")
-        cmake_args.append("-DWITH_LAPACK=ON")
-        cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
+        if sys.platform == "darwin" and not build_headless:
+            cmake_args.append("-DWITH_QT=5")
+
+        if sys.platform.startswith("linux"):
+            cmake_args.append("-DWITH_V4L=ON")
+            cmake_args.append("-DWITH_LAPACK=ON")
+            cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
 
     if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
-    if sys.platform == "darwin" and "bdist_wheel" in sys.argv:
+    if (
+        sys.platform == "darwin"
+        and "bdist_wheel" in sys.argv
+        and ("WITH_QT=5" in sys.argv or "WITH_QT=5" in cmake_args)
+    ):
+        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
+            (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
+        ]
         subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
 
     # works via side effect
@@ -357,22 +376,25 @@ def _classify_installed_files_override(
             cmake_install_dir=cmake_install_reldir,
         )
 
+
 def get_opencv_version(contrib, headless):
     # 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")
 
-    if not os.path.exists(version_file):
-      old_args = sys.argv.copy()
-      sys.argv = ['', str(contrib), str(headless)]
-      runpy.run_path("find_version.py", run_name="__main__")
-      sys.argv = old_args
+    # generate a fresh version.py always when Git repository exists
+    if os.path.exists(".git"):
+        old_args = sys.argv.copy()
+        sys.argv = ["", str(contrib), str(headless)]
+        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']
+    return version["opencv_version"], version["contrib"], version["headless"]
+
 
 def get_build_env_var_by_name(flag_name):
     flag_set = False
@@ -390,6 +412,7 @@ def get_build_env_var_by_name(flag_name):
 
     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):
diff --git a/travis_config.sh b/travis_config.sh
index 2f97fe9d..b371b355 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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
-    pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
+    CI_BUILD=1 pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
@@ -89,9 +89,11 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
+    export HOMEBREW_FORCE_VENDOR_RUBY=1
+    brew update
+
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
-        brew update
         generate_ffmpeg_formula
         brew_add_local_bottles
     fi

From 8bbf351be3cd5f5edba09d1d7e06c1d1f654bbb3 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 21:24:14 +0300
Subject: [PATCH 139/345] fix flags

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index b371b355..a37e8160 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -112,7 +112,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew unlink python@2
-        brew install ffmpeg_opencv --vd
+        brew install -vd ffmpeg_opencv
     fi
 
     if [ -n "$CACHE_STAGE" ]; then

From 8541d771737df245557753ce5198655fd18619c6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 22:04:01 +0300
Subject: [PATCH 140/345] add brew style

---
 travis_config.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/travis_config.sh b/travis_config.sh
index a37e8160..f72480eb 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -90,6 +90,7 @@ function pre_build {
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
     export HOMEBREW_FORCE_VENDOR_RUBY=1
+    brew style
     brew update
 
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally

From e1b13aae1656180b4092ee6eb080951a8ffd96f9 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 22:25:53 +0300
Subject: [PATCH 141/345] try updating homebrew

---
 .travis.yml      | 3 ++-
 travis_config.sh | 5 +----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index aa3093fc..b29da346 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -670,7 +670,8 @@ before_install: |
       echo $ENABLE_HEADLESS > headless.enabled
 
       if [ -n "$IS_OSX" ]; then
-        echo "homebrew"
+        export HOMEBREW_FORCE_VENDOR_RUBY=1
+        brew upgrade
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
             rm -rf "$TAPS/caskroom/homebrew-cask"
diff --git a/travis_config.sh b/travis_config.sh
index f72480eb..c2d4c6fc 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -89,12 +89,9 @@ function pre_build {
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
 
-    export HOMEBREW_FORCE_VENDOR_RUBY=1
-    brew style
-    brew update
-
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
+        brew update
         generate_ffmpeg_formula
         brew_add_local_bottles
     fi

From 34df00569a4c34f19e188bfd7dd4cb648902758a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 22:36:15 +0300
Subject: [PATCH 142/345] try brew doctor

---
 .travis.yml      | 2 --
 travis_config.sh | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index b29da346..7d0509c1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -670,8 +670,6 @@ before_install: |
       echo $ENABLE_HEADLESS > headless.enabled
 
       if [ -n "$IS_OSX" ]; then
-        export HOMEBREW_FORCE_VENDOR_RUBY=1
-        brew upgrade
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
             rm -rf "$TAPS/caskroom/homebrew-cask"
diff --git a/travis_config.sh b/travis_config.sh
index c2d4c6fc..bbf9816f 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -88,6 +88,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
+    brew doctor
 
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then

From bb9c8670600b006bbe22658945e491ed6f7a07e5 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 22:48:39 +0300
Subject: [PATCH 143/345] add sbin to path

---
 .travis.yml      | 1 +
 travis_config.sh | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 7d0509c1..c15ea7fe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -670,6 +670,7 @@ before_install: |
       echo $ENABLE_HEADLESS > headless.enabled
 
       if [ -n "$IS_OSX" ]; then
+        echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
             rm -rf "$TAPS/caskroom/homebrew-cask"
diff --git a/travis_config.sh b/travis_config.sh
index bbf9816f..c2d4c6fc 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -88,7 +88,6 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
-    brew doctor
 
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then

From 04254a626f684bf26b4eef2f637a66c70782b42c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 22:50:19 +0300
Subject: [PATCH 144/345] do not use bash profile

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index c15ea7fe..a95fea50 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -670,7 +670,7 @@ before_install: |
       echo $ENABLE_HEADLESS > headless.enabled
 
       if [ -n "$IS_OSX" ]; then
-        echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
+        export PATH="/usr/local/sbin:$PATH"
         TAPS="$(brew --repository)/Library/Taps"
         if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
             rm -rf "$TAPS/caskroom/homebrew-cask"

From d434c0113e112f7cc0e1d1e4beb1637ffa29253f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 15 Jul 2020 23:48:44 +0300
Subject: [PATCH 145/345] set travis user manually

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index c2d4c6fc..9e114b46 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -88,7 +88,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
-
+    export USER=travis
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update

From 85bb4a397249fef78b6043934f57bab9121ae424 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 17 Jul 2020 14:17:48 +0300
Subject: [PATCH 146/345] update README, minor fixes, update issue template

---
 .github/issue_template.md | 27 +++++++++++++++++
 README.md                 | 62 ++++++++++++++++++++++++---------------
 cv2/__init__.py           | 11 ++++++-
 find_version.py           |  4 ++-
 setup.py                  | 35 ++++++++++++----------
 5 files changed, 97 insertions(+), 42 deletions(-)

diff --git a/.github/issue_template.md b/.github/issue_template.md
index a9091557..79146689 100644
--- a/.github/issue_template.md
+++ b/.github/issue_template.md
@@ -13,3 +13,30 @@ Write here what went wrong.
 - architecture (e.g. x86)
 - opencv-python version
 
+##### Issue submission checklist
+
+ - [ ] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
+   <!--
+
+   Use Q&A forums such as https://answers.opencv.org/questions/ and https://stackoverflow.com/ and other communities
+   to discuss problems. Tickets without real issue statements related to this build toolchain will be closed.
+
+   -->
+ - [ ] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
+   <!--
+
+   If you have some OpenCV bug report which needs to fixed in the C++ code, 
+   please report issue to the OpenCV repository: 
+
+   https://github.com/opencv/opencv/issues
+
+   See also:
+
+   * OpenCV documentation: https://docs.opencv.org
+   * OpenCV FAQ page: https://github.com/opencv/opencv/wiki/FAQ
+   * OpenCV forum: https://answers.opencv.org
+   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
+
+   -->
+ - [ ] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
+ - [ ] I'm using the latest version of ``opencv-python``
diff --git a/README.md b/README.md
index 6b6f10ba..cb79ea3e 100644
--- a/README.md
+++ b/README.md
@@ -73,11 +73,11 @@ 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 OS X)](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/skvark/opencv-python.svg?maxAge=3600&label=Linux+macOS)](https://travis-ci.org/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.
 
-### Build process
+### CI build process
 
 The project is structured like a normal Python package with a standard ``setup.py`` file.
 The build process for a single entry in the build matrices is as follows (see for example ``appveyor.yml`` file):
@@ -91,43 +91,57 @@ The build process for a single entry in the build matrices is as follows (see fo
    -  Contrib modules are also included as a submodule
 
 2. Find OpenCV version from the sources
-3. Install Python dependencies
 
-   - ``setup.py`` installs the dependencies itself, so you need to run it in an environment
-     where you have the rights to install modules with Pip for the running Python
-
-4. Build OpenCV
+3. Build OpenCV
 
    -  tests are disabled, otherwise build time increases too much
    -  there are 4 build matrix entries for each build combination: with and without contrib modules, with and without GUI (headless)
    -  Linux builds run in manylinux Docker containers (CentOS 5)
+   -  source distributions are separate entries in the build matrix 
 
-5. Rearrange OpenCV's build result, add our custom files and generate wheel
+4. Rearrange OpenCV's build result, add our custom files and generate wheel
 
-6. Linux and macOS wheels are transformed with auditwheel and delocate, correspondingly
+5. Linux and macOS wheels are transformed with auditwheel and delocate, correspondingly
 
-7. Install the generated wheel
-8. Test that Python can import the library and run some sanity checks
-9. Use twine to upload the generated wheel to PyPI (only in release builds)
+6. Install the generated wheel
+7. Test that Python can import the library and run some sanity checks
+8. Use twine to upload the generated wheel to PyPI (only in release builds)
 
-Steps 1--5 are handled by ``setup.py bdist_wheel``.
+Steps 1--4 are handled by ``pip wheel``.
 
-The build can be customized with environment variables.
-In addition to any variables that OpenCV's build accepts, we recognize:
+The build can be customized with environment variables. In addition to any variables that OpenCV's build accepts, we recognize:
 
+- ``CI_BUILD``. Set to ``1`` to emulate the CI environment build behaviour. Used only in CI builds to force certain build flags on in ``setup.py``. Do not use this unless you know what you are doing.
 - ``ENABLE_CONTRIB`` and ``ENABLE_HEADLESS``. Set to ``1`` to build the contrib and/or headless version
-- ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build.
+- ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build. 
+
+See the next section for more info about manual builds outside the CI environment.
 
 ### Manual builds
 
-If some dependency is not enabled in the pre-built wheels, you can also run the `setup.py` locally to create a custom wheel.
+If some dependency is not enabled in the pre-built wheels, you can also run the build locally to create a custom wheel.
 
 1. Clone this repository: `git clone --recursive https://github.com/skvark/opencv-python.git`
-2. Go to the root of the repository 
-3. Add custom Cmake flags if needed, for example: `export CMAKE_FLAGS="-DSOME_FLAG=ON -DSOME_OTHER_FLAG=OFF"`
-4. Run ``python setup.py bdist_wheel``
-     - Optionally use the `manylinux` images as a build hosts if maximum portability is needed (and run `auditwheel` for the wheel after build)
-5. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish
+2. ``cd opencv-python``
+3. Add custom Cmake flags if needed, for example: `export CMAKE_FLAGS="-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)
+6. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish
+
+#### 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.
+
+You can also force ``pip`` to build the wheels from the source distribution for example with: 
+
+``pip install --no-binary opencv-python opencv-python``
+``pip install --no-binary :all: opencv-python``
+
+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 and enable them. 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. 
 
 ### Licensing
 
@@ -147,7 +161,7 @@ The packages include also other binaries. Full list of licenses can be found fro
 
 ### Versioning
 
-``find_version.py`` script searches for the version information from OpenCV sources and appends also a revision number specific to this repository to the version string.
+``find_version.py`` script searches for the version information from OpenCV sources and appends also a revision number specific to this repository to the version string. It saves the version information to ``version.py`` file under ``cv2`` in addition to some other flags.
 
 ### Releases
 
@@ -177,7 +191,7 @@ Python 3.x releases are provided for officially supported versions (not in EOL).
 
 Currently, builds for following Python versions are provided:
 
-- 3.5
+- 3.5 (EOL in 2020-09-13, builds for 3.5 will not be provided after this)
 - 3.6
 - 3.7
 - 3.8
diff --git a/cv2/__init__.py b/cv2/__init__.py
index ee8cd254..b901c204 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -9,7 +9,16 @@
 # this makes them available
 globals().update(importlib.import_module('cv2.cv2').__dict__)
 
-if sys.platform == 'darwin':
+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'
     )
diff --git a/find_version.py b/find_version.py
index b7ad0613..5210c8b1 100644
--- a/find_version.py
+++ b/find_version.py
@@ -5,6 +5,7 @@
 if __name__ == "__main__":
   contrib = sys.argv[1]
   headless = sys.argv[2]
+  ci_build = sys.argv[2]
 
   opencv_version = ""
   # dig out the version from OpenCV sources
@@ -51,4 +52,5 @@
   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 = {}".format(headless))
+      f.write("headless = {}\n".format(headless))
+      f.write("ci_build = {}".format(ci_build))
diff --git a/setup.py b/setup.py
index 6d9be880..4be1ebd8 100644
--- a/setup.py
+++ b/setup.py
@@ -52,8 +52,8 @@ def main():
                 ["submodule", "update", "--init", "--recursive", "opencv_contrib"]
             )
 
-    package_version, build_contrib, build_headless = get_opencv_version(
-        build_contrib, build_headless
+    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
@@ -153,31 +153,33 @@ def main():
                 "-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:
-            cmake_args.append("-DWITH_QT=5")
+            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")
 
-    if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv:
-        subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
+    # https://github.com/scikit-build/scikit-build/issues/479
+    if "CMAKE_ARGS" in os.environ:
+        import shlex
 
-    if (
-        sys.platform == "darwin"
-        and "bdist_wheel" in sys.argv
-        and ("WITH_QT=5" in sys.argv or "WITH_QT=5" in cmake_args)
-    ):
-        rearrange_cmake_output_data["cv2.qt.plugins.platforms"] = [
-            (r"lib/qt/plugins/platforms/libqcocoa\.dylib")
-        ]
-        subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
+        cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"]))
+        del shlex
 
     # works via side effect
     RearrangeCMakeOutput(
@@ -377,16 +379,17 @@ def _classify_installed_files_override(
         )
 
 
-def get_opencv_version(contrib, headless):
+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)]
+        sys.argv = ["", str(contrib), str(headless), str(ci_build)]
         runpy.run_path("find_version.py", run_name="__main__")
         sys.argv = old_args
 

From c2d177ea560e87dbf374bb2169580ec1bc0b41d1 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 17 Jul 2020 15:31:29 +0300
Subject: [PATCH 147/345] fix sdist upload

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a95fea50..26b345b4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -760,7 +760,7 @@ after_success: |
         pip install --user --upgrade six
 
         if [[ $SDIST == 1 ]]; then
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
+          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
@@ -775,7 +775,7 @@ 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
+          /usr/bin/python -m upload -u ${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*
         fi

From bf4e05620cf70123b4108f2069899c3347126c13 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 17 Jul 2020 15:33:05 +0300
Subject: [PATCH 148/345] fix sdist upload

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a95fea50..26b345b4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -760,7 +760,7 @@ after_success: |
         pip install --user --upgrade six
 
         if [[ $SDIST == 1 ]]; then
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist
+          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
@@ -775,7 +775,7 @@ 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
+          /usr/bin/python -m upload -u ${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*
         fi

From a464c98493e15da7aa84ff21ef72e4450a522bee Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 17 Jul 2020 23:18:32 +0300
Subject: [PATCH 149/345] fix find_version bug and clean up README

---
 README.md       | 8 ++++----
 find_version.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index cb79ea3e..c13b1b48 100644
--- a/README.md
+++ b/README.md
@@ -134,12 +134,12 @@ If some dependency is not enabled in the pre-built wheels, you can also run the
 
 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.
 
-You can also force ``pip`` to build the wheels from the source distribution for example with: 
+You can also force ``pip`` to build the wheels from the source distribution. Some examples: 
 
-``pip install --no-binary opencv-python opencv-python``
-``pip install --no-binary :all: opencv-python``
+- ``pip install --no-binary opencv-python opencv-python``
+- ``pip install --no-binary :all: opencv-python``
 
-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 and enable them. Headless distributions have hard coded CMake flags which disable all possible GUI dependencies. 
+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. 
 
diff --git a/find_version.py b/find_version.py
index 5210c8b1..76d9f86d 100644
--- a/find_version.py
+++ b/find_version.py
@@ -5,7 +5,7 @@
 if __name__ == "__main__":
   contrib = sys.argv[1]
   headless = sys.argv[2]
-  ci_build = sys.argv[2]
+  ci_build = sys.argv[3]
 
   opencv_version = ""
   # dig out the version from OpenCV sources

From f411d56c174c441164bacd2f47d814495929acbb Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 17 Jul 2020 23:18:32 +0300
Subject: [PATCH 150/345] fix find_version bug and clean up README

---
 README.md       | 8 ++++----
 find_version.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index cb79ea3e..c13b1b48 100644
--- a/README.md
+++ b/README.md
@@ -134,12 +134,12 @@ If some dependency is not enabled in the pre-built wheels, you can also run the
 
 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.
 
-You can also force ``pip`` to build the wheels from the source distribution for example with: 
+You can also force ``pip`` to build the wheels from the source distribution. Some examples: 
 
-``pip install --no-binary opencv-python opencv-python``
-``pip install --no-binary :all: opencv-python``
+- ``pip install --no-binary opencv-python opencv-python``
+- ``pip install --no-binary :all: opencv-python``
 
-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 and enable them. Headless distributions have hard coded CMake flags which disable all possible GUI dependencies. 
+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. 
 
diff --git a/find_version.py b/find_version.py
index 5210c8b1..76d9f86d 100644
--- a/find_version.py
+++ b/find_version.py
@@ -5,7 +5,7 @@
 if __name__ == "__main__":
   contrib = sys.argv[1]
   headless = sys.argv[2]
-  ci_build = sys.argv[2]
+  ci_build = sys.argv[3]
 
   opencv_version = ""
   # dig out the version from OpenCV sources

From 40042cd102c6874ffa0953c00a2d4419dd325d22 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 20 Jul 2020 15:39:53 +0300
Subject: [PATCH 151/345] update multibuild

---
 multibuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multibuild b/multibuild
index da36cd54..c2890dc8 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit da36cd5408e03cad504217de4a21bb8f19f2fb2f
+Subproject commit c2890dc8dc93f99b0eadd76f87aa181f6aea42da

From 0727f01375693a17b3c9c0f40d9a5fa22efbc79e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 20 Jul 2020 21:20:43 +0300
Subject: [PATCH 152/345] fix the CI build flag

---
 appveyor.yml | 2 +-
 setup.py     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 3a4fcb75..8b058c68 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -141,7 +141,7 @@ build_script:
 - cmd: |
     "%PYTHON%/python.exe" -m pip install --upgrade pip
     "%PYTHON%/python.exe" -m pip install --upgrade setuptools
-    set "CI_BUILD=True" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
+    set "CI_BUILD=1" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
 
 before_test:
 - ps: |
diff --git a/setup.py b/setup.py
index 4be1ebd8..64162d68 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ 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 == "True" else 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")

From 914404d62efacd8f3f84444c063555339ee7ef4d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 21 Jul 2020 18:47:46 +0300
Subject: [PATCH 153/345] fix typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index c13b1b48..ddb0104c 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ 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``
-3. Add custom Cmake flags if needed, for example: `export CMAKE_FLAGS="-DSOME_FLAG=ON -DSOME_OTHER_FLAG=OFF"` (in Windows you need to set environment variables differently depending on Command Line or PowerShell)
+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

From 61a4bf292aa10d947d417a2878bc33a79b952e3e Mon Sep 17 00:00:00 2001
From: Ted Strzalkowski <tstrzalkowski@linkedin.com>
Date: Sun, 2 Aug 2020 11:22:06 -0700
Subject: [PATCH 154/345] Disable Java wrapper build by default.

- Java wrapper build isn't necessary for all Python builds.
- Java wrapper build can now be enabled with ``ENABLE_JAVA`` environment
  variable.
---
 README.md | 1 +
 setup.py  | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/README.md b/README.md
index ddb0104c..13462507 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,7 @@ The build can be customized with environment variables. In addition to any varia
 
 - ``CI_BUILD``. Set to ``1`` to emulate the CI environment build behaviour. Used only in CI builds to force certain build flags on in ``setup.py``. Do not use this unless you know what you are doing.
 - ``ENABLE_CONTRIB`` and ``ENABLE_HEADLESS``. Set to ``1`` to build the contrib and/or headless version
+- ``ENABLE_JAVA``, Set to ``1`` to enable the Java client build.  This is disabled by default.
 - ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build. 
 
 See the next section for more info about manual builds outside the CI environment.
diff --git a/setup.py b/setup.py
index 64162d68..323efaab 100644
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,7 @@ def main():
     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"
@@ -121,6 +122,8 @@ def main():
             "-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.

From f2f717bc610b7f1ee5338a0c40c785aa1f0449e8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 29 Jul 2020 20:54:21 +0300
Subject: [PATCH 155/345] qt 5.13 test

---
 cv2/__init__.py                        |   8 +-
 cv2/data/__init__.py                   |   2 +-
 docker/manylinux2014/Dockerfile_i686   |  16 +++-
 docker/manylinux2014/Dockerfile_x86_64 |  16 +++-
 find_version.py                        | 114 ++++++++++++++-----------
 patches/patchQtPlugins                 |  13 ++-
 setup.py                               |  17 ++--
 tests/test.py                          |   1 +
 8 files changed, 118 insertions(+), 69 deletions(-)

diff --git a/cv2/__init__.py b/cv2/__init__.py
index b901c204..c7474d18 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -7,7 +7,7 @@
 
 # wildcard import above does not import "private" variables like __version__
 # this makes them available
-globals().update(importlib.import_module('cv2.cv2').__dict__)
+globals().update(importlib.import_module("cv2.cv2").__dict__)
 
 is_ci_build = False
 
@@ -18,7 +18,7 @@
     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'
+if (sys.platform == "darwin" or sys.platform.startswith("linux")) and is_ci_build:
+    os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = os.path.join(
+        os.path.dirname(os.path.abspath(__file__)), "qt", "plugins"
     )
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_i686 b/docker/manylinux2014/Dockerfile_i686
index c50a5018..4418bdac 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,6 +1,20 @@
 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 freetype-devel -y
+
+RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
+    tar -xf qt-everywhere-src-5.13.2.tar.xz && \
+    cd qt-everywhere* && \
+    export MAKEFLAGS=-j$(nproc) && \
+    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -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.13.2 && \
+    rm qt-everywhere-src-5.13.2.tar.xz
+
+ENV QTDIR /opt/Qt5.13.2
+ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index df7e106e..40bb529f 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,6 +1,20 @@
 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 freetype-devel -y
+
+RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
+    tar -xf qt-everywhere-src-5.13.2.tar.xz && \
+    cd qt-everywhere* && \
+    export MAKEFLAGS=-j$(nproc) && \
+    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -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.13.2 && \
+    rm qt-everywhere-src-5.13.2.tar.xz
+
+ENV QTDIR /opt/Qt5.13.2
+ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
diff --git a/find_version.py b/find_version.py
index 76d9f86d..80ae522b 100644
--- a/find_version.py
+++ b/find_version.py
@@ -3,54 +3,66 @@
 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 <tag>-<n>-g<shortened sha-1>
-  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))
+    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 <tag>-<n>-g<shortened sha-1>
+    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/patches/patchQtPlugins b/patches/patchQtPlugins
index c69ef795..4e272c31 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,12 +1,17 @@
 diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
-index 8ccad4d03a..0d5e2a79e9 100644
+index 4c0b3880fc..54da25f151 100644
 --- a/opencv/CMakeLists.txt
 +++ b/opencv/CMakeLists.txt
-@@ -1164,6 +1164,7 @@ if(WITH_QT OR HAVE_QT)
+@@ -1187,6 +1187,12 @@ 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.13.2/plugins 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/setup.py b/setup.py
index 323efaab..79246636 100644
--- a/setup.py
+++ b/setup.py
@@ -159,18 +159,21 @@ def main():
     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
+    # OS-specific components during CI build_headless
     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")
+        if not build_headless and "bdist_wheel" in sys.argv:
+            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")
+                ]
+            if sys.platform == "darwin":
                 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")
diff --git a/tests/test.py b/tests/test.py
index e520814f..54ee19dc 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -12,5 +12,6 @@ def test_import(self):
     def test_video_capture(self):
 
         import cv2
+
         cap = cv2.VideoCapture("SampleVideo_1280x720_1mb.mp4")
         self.assertTrue(cap.isOpened())

From 39198ec83399d7f403a3e6a11a6268e78c38ebca Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 29 Jul 2020 22:31:27 +0300
Subject: [PATCH 156/345] add ld lib path

---
 travis_config.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/travis_config.sh b/travis_config.sh
index 9e114b46..b6043d3a 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -24,6 +24,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.13.2/lib
   export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)"
 fi
 

From 5a8776ad18011a7be9cd5145c810e1ef7b45ade0 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 3 Aug 2020 12:54:44 +0300
Subject: [PATCH 157/345] fix typo, try without xcb helpers

---
 docker/manylinux2014/Dockerfile_i686   | 2 +-
 docker/manylinux2014/Dockerfile_x86_64 | 2 +-
 setup.py                               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 4418bdac..d8286b9a 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -6,7 +6,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt
     tar -xf qt-everywhere-src-5.13.2.tar.xz && \
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
-    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -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 && \
+    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -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 .. && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 40bb529f..7e25d671 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -6,7 +6,7 @@ RUN curl -O -L https://download.qt.io/official_releases/qt/5.13/5.13.2/single/qt
     tar -xf qt-everywhere-src-5.13.2.tar.xz && \
     cd qt-everywhere* && \
     export MAKEFLAGS=-j$(nproc) && \
-    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -qt-xcb -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 && \
+    ./configure -prefix /opt/Qt5.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -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 .. && \
diff --git a/setup.py b/setup.py
index 79246636..764c2617 100644
--- a/setup.py
+++ b/setup.py
@@ -159,7 +159,7 @@ def main():
     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 build_headless
+    # OS-specific components during CI builds
     if is_CI_build:
 
         if not build_headless and "bdist_wheel" in sys.argv:

From 19ecd1602719a09667628eef3b4b55c0d21c299e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 3 Aug 2020 22:54:43 +0300
Subject: [PATCH 158/345] qt5.15 again

---
 docker/manylinux2014/Dockerfile_i686   | 14 +++++++-------
 docker/manylinux2014/Dockerfile_x86_64 | 14 +++++++-------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index d8286b9a..8b217829 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,19 +1,19 @@
 FROM quay.io/pypa/manylinux2014_i686: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 freetype-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.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
-    tar -xf qt-everywhere-src-5.13.2.tar.xz && \
+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.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -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 && \
+    ./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.13.2 && \
-    rm qt-everywhere-src-5.13.2.tar.xz
+    rm -rf qt-everywhere-src-5.15.0 && \
+    rm qt-everywhere-src-5.15.0.tar.xz
 
-ENV QTDIR /opt/Qt5.13.2
+ENV QTDIR /opt/Qt5.15.0
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 7e25d671..cb14871c 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,19 +1,19 @@
 FROM quay.io/pypa/manylinux2014_x86_64: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 freetype-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.13/5.13.2/single/qt-everywhere-src-5.13.2.tar.xz && \
-    tar -xf qt-everywhere-src-5.13.2.tar.xz && \
+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.13.2 -release -opensource -confirm-license -qtnamespace QtOpenCVPython -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 && \
+    ./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.13.2 && \
-    rm qt-everywhere-src-5.13.2.tar.xz
+    rm -rf qt-everywhere-src-5.15.0 && \
+    rm qt-everywhere-src-5.15.0.tar.xz
 
-ENV QTDIR /opt/Qt5.13.2
+ENV QTDIR /opt/Qt5.15.0
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \

From 96be62b70347397c018716af62855e5a86e5f9db Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 3 Aug 2020 22:55:30 +0300
Subject: [PATCH 159/345] change path

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index b6043d3a..13299a4b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -24,7 +24,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.13.2/lib
+  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.15.0/lib
   export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)"
 fi
 

From 3a85591397da732f69124e7eead7cc93f4698acf Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 3 Aug 2020 23:46:30 +0300
Subject: [PATCH 160/345] fix patch

---
 patches/patchQtPlugins | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 4e272c31..e84aca44 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -10,7 +10,7 @@ index 4c0b3880fc..54da25f151 100644
 +      install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
 +    endif()
 +    if(UNIX AND NOT APPLE)
-+      install(DIRECTORY /opt/Qt5.13.2/plugins DESTINATION lib/qt)
++      install(DIRECTORY /opt/Qt5.15.0/plugins DESTINATION lib/qt)
 +    endif()
    elseif(HAVE_QT)
      status("    QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")

From 51520692f0daae66a9f94c637bf36b6b686fce8e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 5 Aug 2020 14:35:20 +0300
Subject: [PATCH 161/345] try to whitelist libxcb.so.1

---
 patch_auditwheel_whitelist.py | 16 ++++++++++++++++
 travis_config.sh              |  1 +
 2 files changed, 17 insertions(+)
 create mode 100644 patch_auditwheel_whitelist.py

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/travis_config.sh b/travis_config.sh
index 13299a4b..d1a80041 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -26,6 +26,7 @@ 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)"
+  python patch_auditwheel_whitelist.py
 fi
 
 if [ -n "$IS_OSX" ]; then

From aa791f185760607bc29790bea6789376c9eb8c2c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 5 Aug 2020 14:52:46 +0300
Subject: [PATCH 162/345] auditwheel is installed under py37

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index d1a80041..863423b3 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -26,7 +26,7 @@ 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)"
-  python patch_auditwheel_whitelist.py
+  /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
 fi
 
 if [ -n "$IS_OSX" ]; then

From b9b07a532d49fc93ff191569d2424a49ccaebda4 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 5 Aug 2020 15:23:06 +0300
Subject: [PATCH 163/345] fix patch location

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 863423b3..d80d7147 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -16,6 +16,7 @@ function bdist_wheel_cmd {
     local abs_wheelhouse=$1
     CI_BUILD=1 pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
+    /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 
@@ -26,7 +27,6 @@ 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)"
-  /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
 fi
 
 if [ -n "$IS_OSX" ]; then

From 9271f1a4f54761a897ae34f2bd0205472f5dc9ad Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Wed, 5 Aug 2020 16:13:17 +0300
Subject: [PATCH 164/345] Install azure-cli from Ubuntu repo because latest
 update broke batch upload

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 26b345b4..edbbbd72 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -787,7 +787,7 @@ after_success: |
     # Save to Azure storage always
 
     if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-      curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
+      sudo apt-get install -y azure-cli=2.0.81+ds-4
     else
       brew install azure-cli
     fi

From 2bcf6a4e191b03f77bad8e44d96f50e1a206fd61 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Wed, 5 Aug 2020 16:55:11 +0300
Subject: [PATCH 165/345] use pip

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index edbbbd72..07951314 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -787,7 +787,7 @@ after_success: |
     # Save to Azure storage always
 
     if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-      sudo apt-get install -y azure-cli=2.0.81+ds-4
+      pip install --user azure-cli==2.9.1
     else
       brew install azure-cli
     fi

From 3ec8958f321bc5e1c9c0e873413cfbba349d722a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Wed, 5 Aug 2020 17:39:19 +0300
Subject: [PATCH 166/345] use py27 compatible version

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 07951314..069e18a8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -787,7 +787,7 @@ after_success: |
     # Save to Azure storage always
 
     if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-      pip install --user azure-cli==2.9.1
+      pip install --user azure-cli==2.0.81
     else
       brew install azure-cli
     fi

From eaa3ca764aee622e63fdd678043f8ac6efbafca8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 6 Aug 2020 20:19:15 +0300
Subject: [PATCH 167/345] azure-cli should work now

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 069e18a8..26b345b4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -787,7 +787,7 @@ after_success: |
     # Save to Azure storage always
 
     if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-      pip install --user azure-cli==2.0.81
+      curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
     else
       brew install azure-cli
     fi

From 902a94edfd9533c892cd76cc785cf068787c143f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 00:38:54 +0300
Subject: [PATCH 168/345] add fonts to the package

---
 setup.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/setup.py b/setup.py
index 764c2617..cad0f141 100644
--- a/setup.py
+++ b/setup.py
@@ -170,6 +170,17 @@ def main():
                 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"/usr/share/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")

From fa463c13c2a17bfd07e053f40da29f9107ad2a5e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 00:47:35 +0300
Subject: [PATCH 169/345] set QT_QPA_FONTDIR

---
 cv2/__init__.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/cv2/__init__.py b/cv2/__init__.py
index c7474d18..7f7c1261 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -9,16 +9,25 @@
 # this makes them available
 globals().update(importlib.import_module("cv2.cv2").__dict__)
 
-is_ci_build = False
+ci_and_not_headless = False
 
 try:
-    from .version import ci_build
-    is_ci_build = ci_build
+    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 is_ci_build:
+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"
+    )

From 8ca25e7a0937707d56b8471fb0da33542545e94c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 01:22:13 +0300
Subject: [PATCH 170/345] copy fonts

---
 patches/patchQtPlugins | 1 +
 setup.py               | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index e84aca44..d8571414 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -11,6 +11,7 @@ index 4c0b3880fc..54da25f151 100644
 +    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})")
diff --git a/setup.py b/setup.py
index cad0f141..daa4387f 100644
--- a/setup.py
+++ b/setup.py
@@ -176,7 +176,7 @@ def main():
                 for file in os.listdir("/usr/share/fonts/dejavu"):
                     if file.endswith(".ttf"):
                         fonts.append(
-                            (r"/usr/share/fonts/dejavu/%s\.ttf" % file.split(".")[0])
+                            (r"lib/qt/fonts/dejavu/%s\.ttf" % file.split(".")[0])
                         )
 
                 rearrange_cmake_output_data["cv2.qt.fonts"] = fonts

From 98d210d4244e5de84388a124ccbafee76cfb3b32 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 14:10:36 +0300
Subject: [PATCH 171/345] update patch

---
 patches/patchQtPlugins | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index d8571414..221ab561 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,8 +1,7 @@
-diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
-index 4c0b3880fc..54da25f151 100644
---- a/opencv/CMakeLists.txt
-+++ b/opencv/CMakeLists.txt
-@@ -1187,6 +1187,12 @@ if(WITH_QT OR HAVE_QT)
+diff -ruN opencv/CMakeLists.txt opencv_patched/CMakeLists.txt
+--- opencv/CMakeLists.txt       2020-08-07 14:09:05.665876400 +0300
++++ opencv_patched/CMakeLists.txt       2020-08-07 14:05:31.738510600 +0300
+@@ -1187,6 +1187,13 @@
    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)

From e2f2a872e4a5e9a680b0ab6d2a405288c4640baf Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 11:44:10 +0000
Subject: [PATCH 172/345] update patch

---
 patches/patchQtPlugins | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 221ab561..6919520e 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,6 +1,5 @@
-diff -ruN opencv/CMakeLists.txt opencv_patched/CMakeLists.txt
---- opencv/CMakeLists.txt       2020-08-07 14:09:05.665876400 +0300
-+++ opencv_patched/CMakeLists.txt       2020-08-07 14:05:31.738510600 +0300
+--- opencv/CMakeLists.txt	2020-08-07 11:24:37.662215917 +0000
++++ opencv_patched/CMakeLists.txt	2020-08-07 11:24:25.684215910 +0000
 @@ -1187,6 +1187,13 @@
    if(HAVE_QT5)
      status("    QT:" "YES (ver ${Qt5Core_VERSION_STRING})")

From c7f3271fb503a1afea26a85d24f798dbbc677b8d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 11:51:13 +0000
Subject: [PATCH 173/345] update patch

---
 patches/patchQtPlugins | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 6919520e..246432d1 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,6 +1,8 @@
---- opencv/CMakeLists.txt	2020-08-07 11:24:37.662215917 +0000
-+++ opencv_patched/CMakeLists.txt	2020-08-07 11:24:25.684215910 +0000
-@@ -1187,6 +1187,13 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4c0b3880fc..dffa0a4caa 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -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)

From 6ef230bacaf16d443041a9af9d38aebe076ec5c7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 11:57:39 +0000
Subject: [PATCH 174/345] wrong dir

---
 patches/patchQtPlugins | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 246432d1..03560f17 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -1,7 +1,7 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
+diff --git a/opencv/CMakeLists.txt b/opencv/CMakeLists.txt
 index 4c0b3880fc..dffa0a4caa 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
+--- a/opencv/CMakeLists.txt
++++ b/opencv/CMakeLists.txt
 @@ -1187,6 +1187,13 @@ if(WITH_QT OR HAVE_QT)
    if(HAVE_QT5)
      status("    QT:" "YES (ver ${Qt5Core_VERSION_STRING})")

From a3f63146813b84c4cf1abbd44e339b81e656b2ac Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 15:41:31 +0300
Subject: [PATCH 175/345] update license info

---
 LICENSE-3RD-PARTY.txt | 3 +--
 README.md             | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index e5aaa258..1cbfd56f 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -81,7 +81,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,
@@ -549,7 +548,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.
diff --git a/README.md b/README.md
index 13462507..513520e4 100644
--- a/README.md
+++ b/README.md
@@ -154,9 +154,7 @@ Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/s
 
 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).
 

From a115f4bd2ae79107dd4735b1ac99f6c60fd84ed7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 7 Aug 2020 16:19:23 +0300
Subject: [PATCH 176/345] update licenses

---
 LICENSE-3RD-PARTY.txt | 514 +++++++++++++++++++-----------------------
 1 file changed, 231 insertions(+), 283 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 1cbfd56f..60c34bc0 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -81,7 +81,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ------------------------------------------------------------------------------
 FFmpeg is redistributed within all opencv-python 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.
@@ -891,33 +890,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
@@ -1278,261 +1251,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/.
@@ -2328,3 +2046,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 <bart@cs.pdx.edu>
+Copyright © 2008 Julien Danjou <julien@danjou.info>
+Copyright © 2008 Keith Packard <keithp@keithp.com>
+
+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 <bart@cs.pdx.edu>
+Copyright © 2008 Ian Osgood <iano@quirkster.com>
+Copyright © 2008 Jamey Sharp <jamey@minilop.net>
+Copyright © 2008 Josh Triplett <josh@freedesktop.org>
+Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
+
+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 <arnau@debian.org>
+Copyright © 2007-2008 Vincent Torri <vtorri@univ-evry.fr>
+
+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

From a49fdc600fe076d7729e15e97d3805e636eb1b73 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 8 Aug 2020 21:05:50 +0300
Subject: [PATCH 177/345] fix windows builds

---
 setup.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index fab105ef..f3b209b3 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ def main():
     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'
+    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"
@@ -162,7 +162,11 @@ def main():
     # OS-specific components during CI builds
     if is_CI_build:
 
-        if not build_headless and "bdist_wheel" in sys.argv:
+        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)
 

From 2ff5f257aa6128016ea8419d37e54c57b2efe230 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 8 Aug 2020 21:05:50 +0300
Subject: [PATCH 178/345] fix windows builds

---
 setup.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index daa4387f..432f01cc 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ def main():
     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'
+    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"
@@ -162,7 +162,11 @@ def main():
     # OS-specific components during CI builds
     if is_CI_build:
 
-        if not build_headless and "bdist_wheel" in sys.argv:
+        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)
 

From 2bc75407aab5e9ab4d6d1bc6f5f05d6c2545050b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 8 Aug 2020 23:49:13 +0300
Subject: [PATCH 179/345] patch only on linux

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index d80d7147..fe1b7865 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -16,7 +16,9 @@ function bdist_wheel_cmd {
     local abs_wheelhouse=$1
     CI_BUILD=1 pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
-    /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
+    if [ -z "$IS_OSX" ]; then
+      /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
+    fi
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 

From 70988b9e41a6e3a1833befb98775d09d3c85dd34 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 8 Aug 2020 23:49:13 +0300
Subject: [PATCH 180/345] patch only on linux

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index d80d7147..fe1b7865 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -16,7 +16,9 @@ function bdist_wheel_cmd {
     local abs_wheelhouse=$1
     CI_BUILD=1 pip wheel --wheel-dir="$PWD/dist" . --verbose $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
-    /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
+    if [ -z "$IS_OSX" ]; then
+      /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
+    fi
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 

From 689a9e10b734ea9891f9797ff3965bdd107a0aa1 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 14:35:05 +0300
Subject: [PATCH 181/345] reduce verbosity

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index fe1b7865..3cf99356 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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 --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
       /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py

From 8660b61dbc982049866b9fc08e8b35deba7e22b6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 14:35:05 +0300
Subject: [PATCH 182/345] reduce verbosity

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index fe1b7865..3cf99356 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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 --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
       /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py

From e0ff6f905e418eea1c3055a18aa1931806bc44af Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 16:08:04 +0300
Subject: [PATCH 183/345] fix min numpy version for 3.6

---
 .travis.yml | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 26b345b4..19072fca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,6 +119,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
@@ -159,6 +160,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
@@ -199,6 +201,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
@@ -239,6 +242,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
@@ -293,7 +297,7 @@ jobs:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.11.3
+        - TEST_DEPENDS=numpy==1.13.3
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -305,7 +309,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.11.3
+        - TEST_DEPENDS=numpy==1.13.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
@@ -389,7 +393,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 +405,7 @@ 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
@@ -483,7 +487,7 @@ jobs:
       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=0
       cache:
@@ -495,7 +499,7 @@ 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=0
         - USE_CCACHE=0
@@ -580,7 +584,7 @@ jobs:
       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,7 +596,7 @@ 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

From 52bc6985f9fcfccacd75fc6ae86c12dbba425150 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 16:08:04 +0300
Subject: [PATCH 184/345] fix min numpy version for 3.6

---
 .travis.yml | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 26b345b4..19072fca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,6 +119,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
@@ -159,6 +160,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
@@ -199,6 +201,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
@@ -239,6 +242,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
@@ -293,7 +297,7 @@ jobs:
         - MB_PYTHON_VERSION=3.6
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.11.3
+        - TEST_DEPENDS=numpy==1.13.3
       cache:
         directories: $HOME/.ccache
     - os: linux
@@ -305,7 +309,7 @@ jobs:
         - PLAT=i686
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.11.3
+        - TEST_DEPENDS=numpy==1.13.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
@@ -389,7 +393,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 +405,7 @@ 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
@@ -483,7 +487,7 @@ jobs:
       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=0
       cache:
@@ -495,7 +499,7 @@ 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=0
         - USE_CCACHE=0
@@ -580,7 +584,7 @@ jobs:
       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,7 +596,7 @@ 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

From 4049947cdac87c7c75126b0c0c5f93c44bbc9754 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 16:28:22 +0300
Subject: [PATCH 185/345] fix sdist upload

---
 .travis.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 19072fca..6355aaa0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -760,12 +760,12 @@ after_success: |
       fi
 
       if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-        pip install --user twine
-        pip install --user --upgrade six
-
         if [[ $SDIST == 1 ]]; then
+          pip install twine
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
+          pip install --user twine
+          pip install --user --upgrade six
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 

From bad5cb13d9f992bbce540b3bef9b33c512201be7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 16:28:22 +0300
Subject: [PATCH 186/345] fix sdist upload

---
 .travis.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 19072fca..6355aaa0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -760,12 +760,12 @@ after_success: |
       fi
 
       if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-        pip install --user twine
-        pip install --user --upgrade six
-
         if [[ $SDIST == 1 ]]; then
+          pip install twine
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
+          pip install --user twine
+          pip install --user --upgrade six
           twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 

From 469036736e22d2f1e6e08e5de096b74c64f4f794 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 19:21:00 +0300
Subject: [PATCH 187/345] fix twine upload command

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6355aaa0..4f77cd77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -779,9 +779,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 ${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 ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
       fi

From 8d5aa2b7e3243121acf1657491594b9a295ed963 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 9 Aug 2020 19:21:00 +0300
Subject: [PATCH 188/345] fix twine upload command

---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6355aaa0..4f77cd77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -779,9 +779,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 ${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 ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
       fi

From 80e63d48392bb86b2fe35fc8593a314fc239e34a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 16:50:22 +0300
Subject: [PATCH 189/345] fix the travis USER issue

---
 .travis.yml      | 8 ++++----
 travis_config.sh | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4f77cd77..81cc9d87 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -762,11 +762,11 @@ after_success: |
       if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
         if [[ $SDIST == 1 ]]; then
           pip install twine
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
+          twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
           pip install --user twine
           pip install --user --upgrade six
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
+          twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
       fi
@@ -779,9 +779,9 @@ after_success: |
         /usr/bin/python -m pip install --user -U -I twine
 
         if [[ $SDIST == 1 ]]; then
-          /usr/bin/python -m twine 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 twine 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/travis_config.sh b/travis_config.sh
index 3cf99356..59f82bbb 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -92,7 +92,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
-    export USER=travis
+
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update

From 54b7720b45cfc564201a73dc428efba6ffe3129f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 16:55:46 +0300
Subject: [PATCH 190/345] OpenCV 3.4.11

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index 1cc1e6fa..e8d4259f 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 1cc1e6fa563f160b54f9c62da965002cab55ca96
+Subproject commit e8d4259f9ab787b512b9aa1203fc816fb9f19231
diff --git a/opencv_contrib b/opencv_contrib
index 5d2cf95a..3ce9ec6c 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 5d2cf95afce53d1f742117ae39c9189a0ae4b4dd
+Subproject commit 3ce9ec6c827b7b715ba9f7282f5670925c903b56

From a70c89ab9d746bca6b14b3cfe53f59cc4a02054b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 16:57:02 +0300
Subject: [PATCH 191/345] add minimum supported Python version

---
 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index f3b209b3..54aa5988 100644
--- a/setup.py
+++ b/setup.py
@@ -220,6 +220,7 @@ def main():
         maintainer="Olli-Pekka Heinisuo",
         ext_modules=EmptyListWithLength(),
         install_requires=numpy_version,
+        python_requires=">=3.5",
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Environment :: Console",

From 8dc7a8db242cc98c0bfd7331cb03da467b995dbc Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 16:50:22 +0300
Subject: [PATCH 192/345] fix the travis USER issue

---
 .travis.yml      | 8 ++++----
 travis_config.sh | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4f77cd77..81cc9d87 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -762,11 +762,11 @@ after_success: |
       if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
         if [[ $SDIST == 1 ]]; then
           pip install twine
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
+          twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
         else
           pip install --user twine
           pip install --user --upgrade six
-          twine upload -u ${USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
+          twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
         fi
 
       fi
@@ -779,9 +779,9 @@ after_success: |
         /usr/bin/python -m pip install --user -U -I twine
 
         if [[ $SDIST == 1 ]]; then
-          /usr/bin/python -m twine 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 twine 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/travis_config.sh b/travis_config.sh
index 3cf99356..59f82bbb 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -92,7 +92,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
-    export USER=travis
+
     #after the cache stage, all bottles and Homebrew metadata should be already cached locally
     if [ -n "$CACHE_STAGE" ]; then
         brew update

From 633e1cf3851b96a7fecc9703d0fda66f001f908c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 16:57:02 +0300
Subject: [PATCH 193/345] add minimum supported Python version

---
 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index 432f01cc..23584249 100644
--- a/setup.py
+++ b/setup.py
@@ -220,6 +220,7 @@ def main():
         maintainer="Olli-Pekka Heinisuo",
         ext_modules=EmptyListWithLength(),
         install_requires=numpy_version,
+        python_requires=">=3.5",
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Environment :: Console",

From f073b0083541a90d53098c855bed9d6f3a879d65 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 10 Aug 2020 17:01:39 +0300
Subject: [PATCH 194/345] OpenCV 4.4.0

---
 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 f78c6a5160e00c085524f1bb3a98dc2b47f58767 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Tue, 11 Aug 2020 13:57:43 +0300
Subject: [PATCH 195/345] Add note about manylinux2014

---
 README.md | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 513520e4..e0caf36f 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,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 3.4.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 3.4.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/.
 

From 8a23c55330bf45ba03c821c527f2b5a96b14fc87 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Tue, 11 Aug 2020 13:57:43 +0300
Subject: [PATCH 196/345] Add note about manylinux2014

---
 README.md | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 513520e4..e0caf36f 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,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 3.4.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 3.4.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/.
 

From b68716e5b4276e2d057cee034c8716f1605d72df Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 11 Aug 2020 17:33:52 +0300
Subject: [PATCH 197/345] fix typo in version

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e0caf36f..5ba434bf 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ A: No, the packages are special wheel binary packages and they already contain s
 
 **Q: Pip install fails with ``ModuleNotFoundError: No module named 'skbuild'``?**
 
-Since ``opencv-python`` version 3.4.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 3.4.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``.
+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 3.4.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 ...``?**
 

From e29f6f4c8c9ec356aea5be9a620c8c3e2884ab24 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 11 Aug 2020 17:33:52 +0300
Subject: [PATCH 198/345] fix typo in version

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e0caf36f..5ba434bf 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ A: No, the packages are special wheel binary packages and they already contain s
 
 **Q: Pip install fails with ``ModuleNotFoundError: No module named 'skbuild'``?**
 
-Since ``opencv-python`` version 3.4.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 3.4.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``.
+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 3.4.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 ...``?**
 

From 3c332dfa4f613e3dc8cabd013b68c40243489198 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 11 Aug 2020 17:36:32 +0300
Subject: [PATCH 199/345] another typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5ba434bf..946880d6 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ A: No, the packages are special wheel binary packages and they already contain s
 
 **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 3.4.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``.
+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 ...``?**
 

From d356af12a31fbcb6b7a82372555a7569639bb483 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 11 Aug 2020 17:36:32 +0300
Subject: [PATCH 200/345] another typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5ba434bf..946880d6 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ A: No, the packages are special wheel binary packages and they already contain s
 
 **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 3.4.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``.
+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 ...``?**
 

From 0c349095f8f5263b277af407bae30ea0c864eb03 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 18:26:23 +0300
Subject: [PATCH 201/345] add aarch64 Dockerfile

---
 docker/manylinux2014/Dockerfile_aarch64 | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 docker/manylinux2014/Dockerfile_aarch64

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
new file mode 100644
index 00000000..77af8a8a
--- /dev/null
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -0,0 +1,66 @@
+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_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 && \
+    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
+
+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"

From 24d580492217ed83d9f364892cc5bd9ee4b6b38e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 18:34:28 +0300
Subject: [PATCH 202/345] force Qt 5.13

---
 travis_config.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 59f82bbb..ba183b3b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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" . $BDIST_PARAMS
+    CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
       /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
@@ -102,9 +102,9 @@ function pre_build {
 
     echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
+        echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt5
+        brew install qt@5.13
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 
@@ -114,7 +114,7 @@ function pre_build {
         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
 
     if [ -n "$CACHE_STAGE" ]; then

From a055e92a53b3d89c07050013c5563606e5d8b3d7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 18:26:23 +0300
Subject: [PATCH 203/345] add aarch64 Dockerfile

---
 docker/manylinux2014/Dockerfile_aarch64 | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 docker/manylinux2014/Dockerfile_aarch64

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
new file mode 100644
index 00000000..77af8a8a
--- /dev/null
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -0,0 +1,66 @@
+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_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 && \
+    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
+
+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"

From 207e183ceb0055e1437bfa79ad3823357373afb8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 18:34:28 +0300
Subject: [PATCH 204/345] force Qt 5.13

---
 travis_config.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 59f82bbb..ba183b3b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,7 @@ 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" . $BDIST_PARAMS
+    CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
       /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
@@ -102,9 +102,9 @@ function pre_build {
 
     echo 'Installing qt5'
     if [ -n "$CACHE_STAGE" ]; then
-        brew_install_and_cache_within_time_limit qt5 || { [ $? -gt 1 ] && return 2 || return 0; }
+        echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt5
+        brew install qt@5.13
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 
@@ -114,7 +114,7 @@ function pre_build {
         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
 
     if [ -n "$CACHE_STAGE" ]; then

From 436e8f2b6f8438f50a793fdc0be3f7d08bf1af31 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 21:11:45 +0300
Subject: [PATCH 205/345] 5.13.2

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index ba183b3b..e4f2c187 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,7 +104,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt@5.13
+        brew install qt@5.13.2
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 4e5ea42d32c77a8e58c0ca63c825a73be6c9c2a7 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 21:11:45 +0300
Subject: [PATCH 206/345] 5.13.2

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index ba183b3b..e4f2c187 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,7 +104,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt@5.13
+        brew install qt@5.13.2
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From f9b4c3ba9d5c7de596fa3625a2c14f423714f25c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 23:18:31 +0300
Subject: [PATCH 207/345] direct link

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index e4f2c187..10bea551 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,7 +104,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt@5.13.2
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 67699a29b960bbde451ad14e43b8cb20e414a71d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 14 Aug 2020 23:18:31 +0300
Subject: [PATCH 208/345] direct link

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index e4f2c187..10bea551 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -104,7 +104,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install qt@5.13.2
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 72f10b4c4a85bca743ca5844d38ef6307ace7964 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 15 Aug 2020 00:23:33 +0300
Subject: [PATCH 209/345] no auto update, use extract

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 10bea551..8f13ca2b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -92,6 +92,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
+    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
@@ -104,7 +105,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        brew extract qt --version=5.13.2
+        brew install qt@5.13.2
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 0fca5426aa7dd52d9d5b0ba6b00aa61c649299cb Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 15 Aug 2020 00:23:33 +0300
Subject: [PATCH 210/345] no auto update, use extract

---
 travis_config.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 10bea551..8f13ca2b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -92,6 +92,7 @@ function pre_build {
     echo "Running for OSX"
 
     local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
+    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
@@ -104,7 +105,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        brew extract qt --version=5.13.2
+        brew install qt@5.13.2
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 21be118bee9c3519cbb64aa5ef80dce7f3737f0b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 15 Aug 2020 01:13:26 +0300
Subject: [PATCH 211/345] just use the raw url directly

---
 travis_config.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 8f13ca2b..9913c87e 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -105,8 +105,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew extract qt --version=5.13.2
-        brew install qt@5.13.2
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From e3cc9a8f14473b7cdeac373429e15a8bc66d73ce Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 15 Aug 2020 01:13:26 +0300
Subject: [PATCH 212/345] just use the raw url directly

---
 travis_config.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 8f13ca2b..9913c87e 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -105,8 +105,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew extract qt --version=5.13.2
-        brew install qt@5.13.2
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From ebfac6b2034edc2b0e4de1746ddc0570a0d17ba2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 13:02:06 +0300
Subject: [PATCH 213/345] unlink and reinstall

---
 travis_config.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 9913c87e..ff07ae7d 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,14 +101,6 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    echo 'Installing qt5'
-    if [ -n "$CACHE_STAGE" ]; then
-        echo "Qt5 has bottle, no caching needed"
-    else
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
-        export PATH="/usr/local/opt/qt/bin:$PATH"
-    fi
-
     echo 'Installing FFmpeg'
 
     if [ -n "$CACHE_STAGE" ]; then
@@ -118,6 +110,16 @@ function pre_build {
         brew install ffmpeg_opencv
     fi
 
+    echo 'Installing qt5'
+    
+    if [ -n "$CACHE_STAGE" ]; then
+        echo "Qt5 has bottle, no caching needed"
+    else
+        brew unlink qt
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        export PATH="/usr/local/opt/qt/bin:$PATH"
+    fi
+
     if [ -n "$CACHE_STAGE" ]; then
         brew_go_bootstrap_mode 0
         return 0

From d53115c6848859005a7b3532b31473a95dd28b9f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 13:02:06 +0300
Subject: [PATCH 214/345] unlink and reinstall

---
 travis_config.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index 9913c87e..ff07ae7d 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -101,14 +101,6 @@ function pre_build {
         brew_add_local_bottles
     fi
 
-    echo 'Installing qt5'
-    if [ -n "$CACHE_STAGE" ]; then
-        echo "Qt5 has bottle, no caching needed"
-    else
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
-        export PATH="/usr/local/opt/qt/bin:$PATH"
-    fi
-
     echo 'Installing FFmpeg'
 
     if [ -n "$CACHE_STAGE" ]; then
@@ -118,6 +110,16 @@ function pre_build {
         brew install ffmpeg_opencv
     fi
 
+    echo 'Installing qt5'
+    
+    if [ -n "$CACHE_STAGE" ]; then
+        echo "Qt5 has bottle, no caching needed"
+    else
+        brew unlink qt
+        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        export PATH="/usr/local/opt/qt/bin:$PATH"
+    fi
+
     if [ -n "$CACHE_STAGE" ]; then
         brew_go_bootstrap_mode 0
         return 0

From 798a68964bc1953da8b6776b0c17ba3497c75666 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 14:17:18 +0300
Subject: [PATCH 215/345] force qt uninstall

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index ff07ae7d..d5a1989b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -115,7 +115,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew unlink qt
+        brew uninstall --force qt@5.15.0
         brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi

From b0225dd657ac94dfb9e549ca3d6dc574837a23a6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 14:17:18 +0300
Subject: [PATCH 216/345] force qt uninstall

---
 travis_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index ff07ae7d..d5a1989b 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -115,7 +115,7 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew unlink qt
+        brew uninstall --force qt@5.15.0
         brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi

From 8dc0f4d8b3f49f4bf5ada0fdeb048406fd0cc7f8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 16:17:17 +0300
Subject: [PATCH 217/345] use switch instead

---
 travis_config.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index d5a1989b..6f9f6511 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -115,8 +115,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew uninstall --force qt@5.15.0
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        brew switch qt 5.13.2
+        brew pin qt
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 97642d5a01c25aad40db0badfbe2c941ad931b38 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 16 Aug 2020 16:17:17 +0300
Subject: [PATCH 218/345] use switch instead

---
 travis_config.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/travis_config.sh b/travis_config.sh
index d5a1989b..6f9f6511 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -115,8 +115,8 @@ function pre_build {
     if [ -n "$CACHE_STAGE" ]; then
         echo "Qt5 has bottle, no caching needed"
     else
-        brew uninstall --force qt@5.15.0
-        brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/079ce55db79acc87b91bec950249595b1584e119/Formula/qt.rb
+        brew switch qt 5.13.2
+        brew pin qt
         export PATH="/usr/local/opt/qt/bin:$PATH"
     fi
 

From 6454d369fcc90b848d3b71d08cc7f4335c92c9ad Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:24:42 +0300
Subject: [PATCH 219/345] drop Python 3.5 support

---
 .travis.yml  | 121 +++------------------------------------------------
 appveyor.yml |  32 --------------
 setup.py     |   3 +-
 3 files changed, 6 insertions(+), 150 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 81cc9d87..f79e1907 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
@@ -144,15 +135,6 @@ jobs:
         use: brew_cache
 
     # headless builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -185,15 +167,6 @@ jobs:
         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
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -226,15 +199,6 @@ jobs:
         use: brew_cache
 
     # headless contrib builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -267,28 +231,6 @@ jobs:
         use: brew_cache
 
     # default builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -361,30 +303,21 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-
-    # headless builds for Linux
     - os: linux
       language: generic
       dist: xenial
       services: docker
       env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
+        - MB_PYTHON_VERSION=3.8
         - PLAT=i686
         - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.17.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
+
+    # headless builds for Linux
     - os: linux
       language: generic
       dist: xenial
@@ -459,28 +392,6 @@ jobs:
         directories: $HOME/.ccache
 
     # contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -556,28 +467,6 @@ jobs:
 
 
     # headless contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
diff --git a/appveyor.yml b/appveyor.yml
index 8b058c68..3dde3d23 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,14 +6,6 @@ environment:
     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
@@ -38,14 +30,6 @@ environment:
       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
@@ -70,14 +54,6 @@ environment:
       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
@@ -102,14 +78,6 @@ environment:
       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
diff --git a/setup.py b/setup.py
index 23584249..86a7667a 100644
--- a/setup.py
+++ b/setup.py
@@ -220,7 +220,7 @@ def main():
         maintainer="Olli-Pekka Heinisuo",
         ext_modules=EmptyListWithLength(),
         install_requires=numpy_version,
-        python_requires=">=3.5",
+        python_requires=">=3.6",
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Environment :: Console",
@@ -235,7 +235,6 @@ def main():
             "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",

From 928952d99a2be5c0c20e5a0de1df9b4ea3891ce2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:24:42 +0300
Subject: [PATCH 220/345] drop Python 3.5 support

---
 .travis.yml  | 121 +++------------------------------------------------
 appveyor.yml |  32 --------------
 setup.py     |   3 +-
 3 files changed, 6 insertions(+), 150 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 81cc9d87..f79e1907 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
@@ -144,15 +135,6 @@ jobs:
         use: brew_cache
 
     # headless builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -185,15 +167,6 @@ jobs:
         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
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -226,15 +199,6 @@ jobs:
         use: brew_cache
 
     # headless contrib builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      workspaces:
-        use: brew_cache
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -267,28 +231,6 @@ jobs:
         use: brew_cache
 
     # default builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -361,30 +303,21 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-
-    # headless builds for Linux
     - os: linux
       language: generic
       dist: xenial
       services: docker
       env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
+        - MB_PYTHON_VERSION=3.8
         - PLAT=i686
         - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.17.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
+
+    # headless builds for Linux
     - os: linux
       language: generic
       dist: xenial
@@ -459,28 +392,6 @@ jobs:
         directories: $HOME/.ccache
 
     # contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -556,28 +467,6 @@ jobs:
 
 
     # headless contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.5
-        - PLAT=i686
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
diff --git a/appveyor.yml b/appveyor.yml
index 8b058c68..3dde3d23 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,14 +6,6 @@ environment:
     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
@@ -38,14 +30,6 @@ environment:
       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
@@ -70,14 +54,6 @@ environment:
       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
@@ -102,14 +78,6 @@ environment:
       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
diff --git a/setup.py b/setup.py
index 54aa5988..212dbfcb 100644
--- a/setup.py
+++ b/setup.py
@@ -220,7 +220,7 @@ def main():
         maintainer="Olli-Pekka Heinisuo",
         ext_modules=EmptyListWithLength(),
         install_requires=numpy_version,
-        python_requires=">=3.5",
+        python_requires=">=3.6",
         classifiers=[
             "Development Status :: 5 - Production/Stable",
             "Environment :: Console",
@@ -235,7 +235,6 @@ def main():
             "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",

From a82d7dd005d316e9e56ff8778dff01aec9f2ecb6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:40:24 +0300
Subject: [PATCH 221/345] test aarch64 build

---
 .travis.yml | 14 ++++++++++++++
 README.md   |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index f79e1907..acddcd8c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -316,6 +316,20 @@ 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
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.17.3
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
 
     # headless builds for Linux
     - os: linux
diff --git a/README.md b/README.md
index 946880d6..9061185c 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,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/skvark/opencv-python.svg?maxAge=3600&label=Linux+macOS)](https://travis-ci.com/skvark/opencv-python.svg?branch=master)
 
 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.
 

From 5373fcc74fbad2ecde983a1ec568387ba9091896 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:49:27 +0300
Subject: [PATCH 222/345] aarch64 needs to be rebuilt with cmake

---
 .travis.yml | 14 --------------
 README.md   |  2 +-
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index acddcd8c..f79e1907 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -316,20 +316,6 @@ 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
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
 
     # headless builds for Linux
     - os: linux
diff --git a/README.md b/README.md
index 9061185c..b4ae108b 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,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.com/skvark/opencv-python.svg?branch=master)
+[![Travis CI test status (Linux and macOS)](https://img.shields.io/travis/skvark/opencv-python.svg?maxAge=3600&label=Linux+macOS)](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.
 

From ab3674510b99ea1508e532078de6b6a990e0ccf6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:51:45 +0300
Subject: [PATCH 223/345] add ccache and cmake to aarch64 Dockerfile (requires
 rebuild)

---
 docker/manylinux2014/Dockerfile_aarch64 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 77af8a8a..6d63116b 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -61,6 +61,23 @@ RUN cd ~/ffmpeg_sources && \
     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
+
+RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
+    tar -xf cmake-3.17.0.tar.gz && \
+    cd cmake-3.17.0 && \
+    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
+    ./configure --system-curl && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf cmake-3.17.0*
+
 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"

From e4893f2c66f9087921ca4f1ca17d15acd1cadb4e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 17 Aug 2020 19:54:47 +0300
Subject: [PATCH 224/345] update README [skip ci]

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index b4ae108b..787aea38 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,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.com/github/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.
 

From 099ed15c17810affaa42fcd8eb151222a141a31d Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Wed, 26 Aug 2020 22:24:41 +0300
Subject: [PATCH 225/345] Make the README more clear

---
 README.md | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 787aea38..6a32427b 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 at minimum 19.3: `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 expecially 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.)
 
-    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 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``
 

From 893430f3f88d9aaff6ab58e298ef66177708dde2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Sun, 6 Sep 2020 02:03:55 +0300
Subject: [PATCH 226/345] add more guidance, fix typos, drop Python 3.5

---
 README.md | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md
index 6a32427b..94a30d4b 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Check the manual build section if you wish to compile the bindings from source t
 ### 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. Make sure that your `pip` version is at minimum 19.3: `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 expecially with the `manylinux` format.
+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 (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.
@@ -19,9 +19,9 @@ Check the manual build section if you wish to compile the bindings from source t
     - 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 (such as Docker, cloud environments etc.)
+    **b.** Packages for server (headless) environments (such as Docker, cloud environments etc.), no GUI library dependencies
 
-    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 than OpenCV to create your GUI.
+    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.
 
     - 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/))
@@ -131,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: 
 
@@ -149,7 +151,7 @@ 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
 
@@ -187,17 +189,14 @@ 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).
+Python 3.x compatible pre-built wheels are provided for the officially supported Python versions (not in EOL):
 
-Currently, builds for following Python versions are provided:
-
-- 3.5 (EOL in 2020-09-13, builds for 3.5 will not be provided after this)
 - 3.6
 - 3.7
 - 3.8

From 4ee3929119e51245bf2a4f704c98716d4a2a6e02 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 20 Sep 2020 14:08:08 +0300
Subject: [PATCH 227/345] disable nodelete, see #381

---
 docker/manylinux2014/Dockerfile_aarch64 | 2 +-
 docker/manylinux2014/Dockerfile_i686    | 2 +-
 docker/manylinux2014/Dockerfile_x86_64  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 6d63116b..81823a1e 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -21,7 +21,7 @@ RUN mkdir ~/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 && \
+    ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib -DOPENSSL_USE_NODELETE=0 && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 8b217829..b1ad7739 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -23,7 +23,7 @@ RUN mkdir ~/ffmpeg_sources && \
     cd openssl-OpenSSL_1_1_1c && \
     # 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" --openssldir="$HOME/ffmpeg_build" shared zlib -DOPENSSL_USE_NODELETE=0 && \
     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 cb14871c..94583bc3 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -21,7 +21,7 @@ RUN mkdir ~/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 && \
+    ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib -DOPENSSL_USE_NODELETE=0 && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \

From c001042fefc533f7a68c24c249972dcb2596305b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 20 Sep 2020 17:00:13 +0300
Subject: [PATCH 228/345] update openssl, no-pinshared, see #381

---
 docker/manylinux2014/Dockerfile_aarch64 | 8 ++++----
 docker/manylinux2014/Dockerfile_i686    | 8 ++++----
 docker/manylinux2014/Dockerfile_x86_64  | 8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 81823a1e..5fb47264 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -18,10 +18,10 @@ 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 -DOPENSSL_USE_NODELETE=0 && \
+    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/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index b1ad7739..39fc1560 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -18,12 +18,12 @@ 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 -DOPENSSL_USE_NODELETE=0 && \
+    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 94583bc3..010120ca 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -18,10 +18,10 @@ 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 -DOPENSSL_USE_NODELETE=0 && \
+    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 && \

From 22086f8713c2114fc50c085e3fb7c60523868b27 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 22 Sep 2020 16:31:45 +0300
Subject: [PATCH 229/345] remove file

---
 docker/manylinux2014/Dockerfile_aarch64.orig | 93 --------------------
 1 file changed, 93 deletions(-)
 delete mode 100644 docker/manylinux2014/Dockerfile_aarch64.orig

diff --git a/docker/manylinux2014/Dockerfile_aarch64.orig b/docker/manylinux2014/Dockerfile_aarch64.orig
deleted file mode 100644
index 6edc4cef..00000000
--- a/docker/manylinux2014/Dockerfile_aarch64.orig
+++ /dev/null
@@ -1,93 +0,0 @@
-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 && \
-<<<<<<< HEAD
-    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 && \
->>>>>>> master
-    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
-
-<<<<<<< HEAD
-=======
-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
-
-RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
-    tar -xf cmake-3.17.0.tar.gz && \
-    cd cmake-3.17.0 && \
-    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
-    ./configure --system-curl && \
-    make && \
-    make install && \
-    cd .. && \
-    rm -rf cmake-3.17.0*
-
->>>>>>> master
-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"

From f179cd18e9d7d6e4b3c153238fef37e8994843a9 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 6 Oct 2020 17:36:15 +0300
Subject: [PATCH 230/345] Python 3.9 preparations

---
 .travis.yml    | 128 ++++++++++++++++++++++++++++++++++++++++++++++++-
 appveyor.yml   |  32 +++++++++++++
 multibuild     |   2 +-
 pyproject.toml |   4 +-
 setup.py       |   2 +
 5 files changed, 163 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f79e1907..9b583ed7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -133,6 +133,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=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # headless builds for MacOS
     - os: osx
@@ -165,6 +175,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=0
+        - ENABLE_HEADLESS=1
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # Contrib builds for MacOS
     - os: osx
@@ -197,6 +217,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=0
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # headless contrib builds for MacOS
     - os: osx
@@ -229,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
@@ -308,11 +348,23 @@ jobs:
       dist: xenial
       services: docker
       env:
-        - MB_PYTHON_VERSION=3.8
+        - MB_PYTHON_VERSION=3.9
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.19.3
+        - USE_CCACHE=0
+      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=0
-        - TEST_DEPENDS=numpy==1.17.3
+        - TEST_DEPENDS=numpy==1.19.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
@@ -390,6 +442,30 @@ jobs:
         - 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
 
     # contrib builds for Linux
     - os: linux
@@ -464,6 +540,30 @@ jobs:
         - 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
+      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=0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
 
 
     # headless contrib builds for Linux
@@ -539,6 +639,30 @@ jobs:
         - 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
 
 # The first line is printed in the folding header in Travis output
 before_install: |
diff --git a/appveyor.yml b/appveyor.yml
index 3dde3d23..d203b1cf 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -30,6 +30,14 @@ environment:
       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
@@ -54,6 +62,14 @@ environment:
       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
@@ -78,6 +94,14 @@ environment:
       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
@@ -102,6 +126,14 @@ environment:
       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
 
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/pyproject.toml b/pyproject.toml
index 7522b5ef..ba577535 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,8 +1,8 @@
 [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'"
+  "numpy==1.17.3; python_version>='3.8'",
+  "numpy==1.19.3; python_version>='3.8'"
 ]
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 86a7667a..7f52501f 100644
--- a/setup.py
+++ b/setup.py
@@ -235,9 +235,11 @@ def main():
             "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",

From b743f47af4127fb461cc390cba4c1977379c7c81 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 6 Oct 2020 17:38:06 +0300
Subject: [PATCH 231/345] fix typo

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index ba577535..e20c59a6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,5 +4,5 @@ requires = [
   "numpy==1.13.3; python_version=='3.6'",
   "numpy==1.14.5; python_version=='3.7'",
   "numpy==1.17.3; python_version>='3.8'",
-  "numpy==1.19.3; python_version>='3.8'"
+  "numpy==1.19.3; python_version>='3.9'"
 ]
\ No newline at end of file

From 5e46e96c92a0a76ba0f5169f728b89e823cdce87 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 7 Oct 2020 17:48:29 +0300
Subject: [PATCH 232/345] fix pyproject.toml

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index e20c59a6..b362f93f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,6 +3,6 @@ requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6'",
   "numpy==1.14.5; python_version=='3.7'",
-  "numpy==1.17.3; python_version>='3.8'",
+  "numpy==1.17.3; python_version=='3.8'",
   "numpy==1.19.3; python_version>='3.9'"
 ]
\ No newline at end of file

From 69a8f4c0bdab956bf3999196918396346e3619c4 Mon Sep 17 00:00:00 2001
From: Stefan Weil <sw@weilnetz.de>
Date: Sun, 11 Oct 2020 09:57:28 +0200
Subject: [PATCH 233/345] .gitignore: Ignore cv2/version.py

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

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/

From 58f0105b328ccd0f8fcc29529ab7e310fe47f98e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 6 Oct 2020 17:36:15 +0300
Subject: [PATCH 234/345] Python 3.9 preparations

---
 .travis.yml    | 128 ++++++++++++++++++++++++++++++++++++++++++++++++-
 appveyor.yml   |  32 +++++++++++++
 multibuild     |   2 +-
 pyproject.toml |   4 +-
 setup.py       |   2 +
 5 files changed, 163 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f79e1907..9b583ed7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -133,6 +133,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=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # headless builds for MacOS
     - os: osx
@@ -165,6 +175,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=0
+        - ENABLE_HEADLESS=1
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # Contrib builds for MacOS
     - os: osx
@@ -197,6 +217,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=0
+        - TEST_DEPENDS=numpy==1.19.3
+      workspaces:
+        use: brew_cache
 
     # headless contrib builds for MacOS
     - os: osx
@@ -229,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
@@ -308,11 +348,23 @@ jobs:
       dist: xenial
       services: docker
       env:
-        - MB_PYTHON_VERSION=3.8
+        - MB_PYTHON_VERSION=3.9
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.19.3
+        - USE_CCACHE=0
+      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=0
-        - TEST_DEPENDS=numpy==1.17.3
+        - TEST_DEPENDS=numpy==1.19.3
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
@@ -390,6 +442,30 @@ jobs:
         - 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
 
     # contrib builds for Linux
     - os: linux
@@ -464,6 +540,30 @@ jobs:
         - 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
+      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=0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
 
 
     # headless contrib builds for Linux
@@ -539,6 +639,30 @@ jobs:
         - 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
 
 # The first line is printed in the folding header in Travis output
 before_install: |
diff --git a/appveyor.yml b/appveyor.yml
index 3dde3d23..d203b1cf 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -30,6 +30,14 @@ environment:
       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
@@ -54,6 +62,14 @@ environment:
       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
@@ -78,6 +94,14 @@ environment:
       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
@@ -102,6 +126,14 @@ environment:
       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
 
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/pyproject.toml b/pyproject.toml
index 7522b5ef..ba577535 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,8 +1,8 @@
 [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'"
+  "numpy==1.17.3; python_version>='3.8'",
+  "numpy==1.19.3; python_version>='3.8'"
 ]
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 86a7667a..7f52501f 100644
--- a/setup.py
+++ b/setup.py
@@ -235,9 +235,11 @@ def main():
             "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",

From c4f8e26297b24c5f4294ea3be2d563a4058f8305 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 6 Oct 2020 17:38:06 +0300
Subject: [PATCH 235/345] fix typo

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index ba577535..e20c59a6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,5 +4,5 @@ requires = [
   "numpy==1.13.3; python_version=='3.6'",
   "numpy==1.14.5; python_version=='3.7'",
   "numpy==1.17.3; python_version>='3.8'",
-  "numpy==1.19.3; python_version>='3.8'"
+  "numpy==1.19.3; python_version>='3.9'"
 ]
\ No newline at end of file

From 2d445e7e8f8e8b21ac67e267b26c9c306908c9a1 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 7 Oct 2020 17:48:29 +0300
Subject: [PATCH 236/345] fix pyproject.toml

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index e20c59a6..b362f93f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,6 +3,6 @@ requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6'",
   "numpy==1.14.5; python_version=='3.7'",
-  "numpy==1.17.3; python_version>='3.8'",
+  "numpy==1.17.3; python_version=='3.8'",
   "numpy==1.19.3; python_version>='3.9'"
 ]
\ No newline at end of file

From 6ee82a398e1f4b02d86b8966c49f9278c348eaf8 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 11 Oct 2020 17:13:29 +0300
Subject: [PATCH 237/345] fix line endings

---
 appveyor.yml    | 382 ++++++++++----------
 cv2/__init__.py |  66 ++--
 find_version.py | 136 ++++----
 setup.py        | 900 ++++++++++++++++++++++++------------------------
 tests/test.py   |  34 +-
 5 files changed, 759 insertions(+), 759 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index d203b1cf..b658399a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,191 +1,191 @@
-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
-
-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
+
+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 7f7c1261..d665b75c 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -1,33 +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__)
-
-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"
-    )
+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/find_version.py b/find_version.py
index 80ae522b..6c676b23 100644
--- a/find_version.py
+++ b/find_version.py
@@ -1,68 +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 <tag>-<n>-g<shortened sha-1>
-    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 <tag>-<n>-g<shortened sha-1>
+    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/setup.py b/setup.py
index 7f52501f..3ba72442 100644
--- a/setup.py
+++ b/setup.py
@@ -1,450 +1,450 @@
-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/<arch>/; 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()
+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/<arch>/; 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 54ee19dc..6411ff39 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -1,17 +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())

From e225c615d8741dfd78cfae05470aa5af60cb7c8b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 30 Oct 2020 17:10:50 +0200
Subject: [PATCH 238/345] fix auditwheel patching

---
 travis_config.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 6f9f6511..910e365f 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -17,7 +17,11 @@ function bdist_wheel_cmd {
     CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
-      /opt/python/cp37-cp37m/bin/python patch_auditwheel_whitelist.py
+      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
 }

From ed8acbccb8a1c0dda9cb30de325fd86fe47105ef Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 30 Oct 2020 22:55:24 +0200
Subject: [PATCH 239/345] fix py39 entry

---
 .travis.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 9b583ed7..406a0797 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -352,7 +352,6 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.19.3
-        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux

From 649cfc1d98a30690acfd10a47b11f1ac8da21b51 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 30 Oct 2020 22:55:24 +0200
Subject: [PATCH 240/345] fix py39 entry

---
 .travis.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 9b583ed7..406a0797 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -352,7 +352,6 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.19.3
-        - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
     - os: linux

From 7e104646a3984b1d151781553240937947189212 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 16:06:27 +0200
Subject: [PATCH 241/345] fix min numpy version

---
 setup.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/setup.py b/setup.py
index 3ba72442..12f45c95 100644
--- a/setup.py
+++ b/setup.py
@@ -27,6 +27,8 @@ def main():
         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"
 
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 

From 285348bc19c7e31ec7974f9c8febbb6fbc12ef17 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 16:06:27 +0200
Subject: [PATCH 242/345] fix min numpy version

---
 setup.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/setup.py b/setup.py
index 55fcbccd..b58ea894 100644
--- a/setup.py
+++ b/setup.py
@@ -27,6 +27,8 @@ def main():
         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"
 
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 

From ea7c4164a5b1ae316a219935b69f24947ff7fd9f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 16:13:15 +0200
Subject: [PATCH 243/345] download Python 3.9 manually

---
 appveyor.yml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/appveyor.yml b/appveyor.yml
index b658399a..3e5d8053 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -137,6 +137,16 @@ environment:
 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

From 23d3a09dae68d6f99615bcac8b6bca60489967f0 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 16:13:15 +0200
Subject: [PATCH 244/345] download Python 3.9 manually

---
 appveyor.yml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/appveyor.yml b/appveyor.yml
index b658399a..3e5d8053 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -137,6 +137,16 @@ environment:
 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

From 86414ec4c72ee2d272e8d9a5a4500b869ddc6d9e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 18:43:24 +0200
Subject: [PATCH 245/345] fix slashes

---
 appveyor.yml | 78 ++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 3e5d8053..30646669 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,131 +6,131 @@ environment:
     secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
 
   matrix:
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
@@ -149,23 +149,23 @@ install:
 
 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
+    "%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")
+    &"${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
+    "%PYTHON%\python.exe" -m unittest test
 
 artifacts:
 - path: dist\opencv*.whl
@@ -193,8 +193,8 @@ deploy_script:
         }
       }
 
-      &"${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*
+      &"${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."

From 603e2a329cd0cc1ba0171999475c97d9e4dfcf8e Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 18:43:24 +0200
Subject: [PATCH 246/345] fix slashes

---
 appveyor.yml | 78 ++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 3e5d8053..30646669 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,131 +6,131 @@ environment:
     secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
 
   matrix:
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36"
+    - PYTHON: "C:\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python36-x64"
+    - PYTHON: "C:\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37"
+    - PYTHON: "C:\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python37-x64"
+    - PYTHON: "C:\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38"
+    - PYTHON: "C:\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python38-x64"
+    - PYTHON: "C:\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39"
+    - PYTHON: "C:\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:/Python39-x64"
+    - PYTHON: "C:\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
@@ -149,23 +149,23 @@ install:
 
 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
+    "%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")
+    &"${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
+    "%PYTHON%\python.exe" -m unittest test
 
 artifacts:
 - path: dist\opencv*.whl
@@ -193,8 +193,8 @@ deploy_script:
         }
       }
 
-      &"${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*
+      &"${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."

From 6f8c817a028264eed681ec8527f39bd276919324 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 19:12:54 +0200
Subject: [PATCH 247/345] another fix for slashes

---
 appveyor.yml | 78 ++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 30646669..c79e7de4 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,131 +6,131 @@ environment:
     secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
 
   matrix:
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
@@ -149,23 +149,23 @@ install:
 
 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
+    "%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")
+    &"${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
+    "%PYTHON%\\python.exe" -m unittest test
 
 artifacts:
 - path: dist\opencv*.whl
@@ -193,8 +193,8 @@ deploy_script:
         }
       }
 
-      &"${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*
+      &"${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."

From 6b377bade9e8127188ab748c1b8ac14efa87374a Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sun, 1 Nov 2020 19:12:54 +0200
Subject: [PATCH 248/345] another fix for slashes

---
 appveyor.yml | 78 ++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 30646669..c79e7de4 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,131 +6,131 @@ environment:
     secure: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
 
   matrix:
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 0
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 0
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36"
+    - PYTHON: "C:\\Python36"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python36-x64"
+    - PYTHON: "C:\\Python36-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37"
+    - PYTHON: "C:\\Python37"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python37-x64"
+    - PYTHON: "C:\\Python37-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38"
+    - PYTHON: "C:\\Python38"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python38-x64"
+    - PYTHON: "C:\\Python38-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39"
+    - PYTHON: "C:\\Python39"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
-    - PYTHON: "C:\Python39-x64"
+    - PYTHON: "C:\\Python39-x64"
       ENABLE_CONTRIB: 1
       ENABLE_HEADLESS: 1
 
@@ -149,23 +149,23 @@ install:
 
 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
+    "%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")
+    &"${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
+    "%PYTHON%\\python.exe" -m unittest test
 
 artifacts:
 - path: dist\opencv*.whl
@@ -193,8 +193,8 @@ deploy_script:
         }
       }
 
-      &"${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*
+      &"${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."

From e98379369e0dcf3f4b636d6b42b5a0815182416c Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 2 Nov 2020 18:15:44 +0200
Subject: [PATCH 249/345] update README

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 94a30d4b..98bbfa3b 100644
--- a/README.md
+++ b/README.md
@@ -200,6 +200,7 @@ Python 3.x compatible pre-built wheels are provided for the officially supported
 - 3.6
 - 3.7
 - 3.8
+- 3.9
 
 ### Backward compatibility
 

From 98fa4b18da0813c1a0ce6ea224485c724e50b60b Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 2 Nov 2020 18:15:44 +0200
Subject: [PATCH 250/345] update README

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 94a30d4b..98bbfa3b 100644
--- a/README.md
+++ b/README.md
@@ -200,6 +200,7 @@ Python 3.x compatible pre-built wheels are provided for the officially supported
 - 3.6
 - 3.7
 - 3.8
+- 3.9
 
 ### Backward compatibility
 

From 83ace3c0ce52bbc64292baaa7642ba99cdc7b221 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 21 Aug 2020 21:42:27 +0300
Subject: [PATCH 251/345] try with new images

---
 .travis.yml | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 406a0797..5cebcd93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -367,7 +367,21 @@ 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
+        - ENABLE_CONTRIB=0
+        - ENABLE_HEADLESS=0
+        - TEST_DEPENDS=numpy==1.17.3
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
+        
     # headless builds for Linux
     - os: linux
       language: generic

From 58920f641df7a0433a9773011956a23b6eaabe4f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 21 Aug 2020 22:00:16 +0300
Subject: [PATCH 252/345] add env markers for aarch64

---
 pyproject.toml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index b362f93f..4e53a159 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,8 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6'",
+  "numpy==1.19.0; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
   "numpy==1.14.5; python_version=='3.7'",
   "numpy==1.17.3; python_version=='3.8'",
   "numpy==1.19.3; python_version>='3.9'"
-]
\ No newline at end of file
+]

From 0fc0d4b5c80035949f6f0265b8dd4a4de811a6dd Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 21 Aug 2020 22:04:17 +0300
Subject: [PATCH 253/345] add numpy version to setup.py

---
 setup.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/setup.py b/setup.py
index 12f45c95..528019cd 100644
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,7 @@
 import subprocess
 import re
 import sysconfig
+import platform
 import skbuild
 from skbuild import cmaker
 
@@ -23,6 +24,8 @@ def main():
 
     if sys.version_info[:2] >= (3, 6):
         minimum_supported_numpy = "1.13.3"
+    if sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
+        minimum_supported_numpy = "1.19.0"
     if sys.version_info[:2] >= (3, 7):
         minimum_supported_numpy = "1.14.5"
     if sys.version_info[:2] >= (3, 8):

From 8cc5da85711a24a15715f93fb49ed532aef5a8e2 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Fri, 21 Aug 2020 22:14:01 +0300
Subject: [PATCH 254/345] test depends, more specific pyproject.toml

---
 .travis.yml    | 4 ++--
 pyproject.toml | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5cebcd93..c29a8d9d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -377,11 +377,11 @@ jobs:
         - PLAT=aarch64
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
+        - TEST_DEPENDS=numpy==1.19.0
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-        
+
     # headless builds for Linux
     - os: linux
       language: generic
diff --git a/pyproject.toml b/pyproject.toml
index 4e53a159..b2efd1bd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,9 +1,9 @@
 [build-system]
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
-  "numpy==1.13.3; python_version=='3.6'",
+  "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64'",
   "numpy==1.19.0; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
-  "numpy==1.14.5; python_version=='3.7'",
-  "numpy==1.17.3; python_version=='3.8'",
-  "numpy==1.19.3; python_version>='3.9'"
+  "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'"
 ]

From 16ac6e7655750ea23f7a756700be9262b6e912f0 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Thu, 12 Nov 2020 21:30:45 +0200
Subject: [PATCH 255/345] add test image

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index c29a8d9d..8c1c0b80 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -375,6 +375,7 @@ jobs:
       env:
         - MB_PYTHON_VERSION=3.8
         - PLAT=aarch64
+        - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.19.0

From 37a96dac620aa72751936560f430756a1a099451 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 16 Nov 2020 16:48:00 +0200
Subject: [PATCH 256/345] add arm64 matrix entries and update Dockerfile

---
 .travis.yml                             | 225 ++++++++++++++++++++++++
 docker/manylinux2014/Dockerfile_aarch64 |  10 --
 2 files changed, 225 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8c1c0b80..30a0ff0d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -295,6 +295,21 @@ jobs:
         - 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.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -319,6 +334,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=0
+        - TEST_DEPENDS=numpy==1.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -343,6 +373,21 @@ 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=0
+        - TEST_DEPENDS=numpy==1.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -408,6 +453,21 @@ jobs:
         - 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
     - os: linux
       language: generic
       dist: xenial
@@ -432,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
@@ -456,6 +531,21 @@ 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
@@ -480,6 +570,21 @@ jobs:
         - 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
@@ -506,6 +611,21 @@ jobs:
         - 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=0
+        - TEST_DEPENDS=numpy==1.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -530,6 +650,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=0
+        - TEST_DEPENDS=numpy==1.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -554,6 +689,21 @@ 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=0
+        - TEST_DEPENDS=numpy==1.19.0
+        - USE_CCACHE=0
+      cache:
+        directories: $HOME/.ccache
     - os: linux
       language: generic
       dist: xenial
@@ -578,6 +728,21 @@ jobs:
         - 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
@@ -605,6 +770,21 @@ jobs:
         - 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
@@ -629,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
@@ -653,6 +848,21 @@ 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
@@ -677,6 +887,21 @@ jobs:
         - 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: |
diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 5fb47264..e8920770 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -68,16 +68,6 @@ RUN curl -O -L https://github.com/ccache/ccache/releases/download/v3.7.9/ccache-
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
 
-RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
-    tar -xf cmake-3.17.0.tar.gz && \
-    cd cmake-3.17.0 && \
-    export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
-    ./configure --system-curl && \
-    make && \
-    make install && \
-    cd .. && \
-    rm -rf cmake-3.17.0*
-
 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"

From f76794273354b316195e3beac0a6216ff22445d6 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 16 Nov 2020 16:51:31 +0200
Subject: [PATCH 257/345] fix py version

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 30a0ff0d..a4c8227e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -418,7 +418,7 @@ jobs:
       dist: xenial
       services: docker
       env:
-        - MB_PYTHON_VERSION=3.8
+        - MB_PYTHON_VERSION=3.9
         - PLAT=aarch64
         - DOCKER_TEST_IMAGE=multibuild/xenial_arm64v8
         - ENABLE_CONTRIB=0

From 39ca0fdafb0e7ba9a34491a48e0eddc549e87491 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 16 Nov 2020 18:06:55 +0200
Subject: [PATCH 258/345] use numpy 1.19.3

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index b2efd1bd..d7c5527d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64'",
-  "numpy==1.19.0; python_version>='3.6' and sys_platform == 'linux' 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'"

From 7701ec78577301c235ad53ce613b4fa04a589963 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 16 Nov 2020 18:06:55 +0200
Subject: [PATCH 259/345] use numpy 1.19.3

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index b2efd1bd..d7c5527d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64'",
-  "numpy==1.19.0; python_version>='3.6' and sys_platform == 'linux' 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'"

From a5fc2953c61ebfd6c4b0b025abbe3890edbc5a3f Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 17 Nov 2020 16:27:53 +0200
Subject: [PATCH 260/345] fix min supported numpy

---
 setup.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index 528019cd..a4f9f729 100644
--- a/setup.py
+++ b/setup.py
@@ -17,15 +17,13 @@ def main():
     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"
+    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, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.19.0"
     if sys.version_info[:2] >= (3, 7):
         minimum_supported_numpy = "1.14.5"
     if sys.version_info[:2] >= (3, 8):
@@ -33,6 +31,10 @@ def main():
     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()

From 54294dda82192b40f85061e2f3c6733de17e62d0 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Tue, 17 Nov 2020 16:27:53 +0200
Subject: [PATCH 261/345] fix min supported numpy

---
 setup.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index 4ad06197..7b106847 100644
--- a/setup.py
+++ b/setup.py
@@ -17,15 +17,13 @@ def main():
     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"
+    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, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.19.0"
     if sys.version_info[:2] >= (3, 7):
         minimum_supported_numpy = "1.14.5"
     if sys.version_info[:2] >= (3, 8):
@@ -33,6 +31,10 @@ def main():
     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()

From 1e85f5e48571923bb8dcd417294a16898ab96b39 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Nov 2020 14:02:25 +0200
Subject: [PATCH 262/345] update OpenCV licensing

---
 LICENSE-3RD-PARTY.txt | 242 +++++++++++++++++++++++++++++++++++-------
 README.md             |   2 +-
 2 files changed, 202 insertions(+), 42 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 60c34bc0..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.
diff --git a/README.md b/README.md
index 98bbfa3b..6c6022ba 100644
--- a/README.md
+++ b/README.md
@@ -157,7 +157,7 @@ On slow systems such as Raspberry Pi the full build may take several hours. On a
 
 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).
 

From bb77a8a8f763a1ac7f12a7262397375e835a8ca5 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Nov 2020 14:03:46 +0200
Subject: [PATCH 263/345] OpenCV 3.4.12

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index e8d4259f..dc15187f 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit e8d4259f9ab787b512b9aa1203fc816fb9f19231
+Subproject commit dc15187f1b6784ef2ece30dae223570811eaddff
diff --git a/opencv_contrib b/opencv_contrib
index 3ce9ec6c..b8eca416 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 3ce9ec6c827b7b715ba9f7282f5670925c903b56
+Subproject commit b8eca4161439f361ae4d5a398aab1495136c704b

From f33e65ddfc206d9169136b99d972f3014ee1afdc Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Nov 2020 14:05:37 +0200
Subject: [PATCH 264/345] OpenCV 4.5.0

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index c3bb57af..d5fd2f01 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit c3bb57afeaf030f10939204d48d7c2a3842f4293
+Subproject commit d5fd2f0155ffad366f9ac912dfd6d189a7a6a98e
diff --git a/opencv_contrib b/opencv_contrib
index 5fae4082..37315bab 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 5fae4082cc493efa5cb7a7486f9e009618a5198b
+Subproject commit 37315babf9984a5b6aa981644a20dd8df1a5ff02

From 3137b3e570d2b78e16a2c2def094d125b16dadbd Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Sat, 28 Nov 2020 14:02:25 +0200
Subject: [PATCH 265/345] update OpenCV licensing

---
 LICENSE-3RD-PARTY.txt | 242 +++++++++++++++++++++++++++++++++++-------
 README.md             |   2 +-
 2 files changed, 202 insertions(+), 42 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 60c34bc0..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.
diff --git a/README.md b/README.md
index 98bbfa3b..6c6022ba 100644
--- a/README.md
+++ b/README.md
@@ -157,7 +157,7 @@ On slow systems such as Raspberry Pi the full build may take several hours. On a
 
 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).
 

From 9c8ebecac062befd1472fbc730296ac145e6c1fa Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 2 Dec 2020 17:11:52 +0200
Subject: [PATCH 266/345] check if there is enough time to build FFmpeg without
 cache

---
 .travis.yml      | 107 +++++++----------------------------------------
 README.md        |   4 --
 travis_config.sh |   1 +
 3 files changed, 17 insertions(+), 95 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a4c8227e..42623a59 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,32 +32,6 @@ jobs:
   exclude:
     - language: ruby
   include:
-    - os: osx
-      env:
-        - MB_PYTHON_VERSION=3.8
-      language: generic
-      osx_image: xcode9.4
-      stage: s1
-      workspaces:
-        create:
-          name: brew_cache
-          paths:
-            # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
-            - $HOME/Library/Caches/Homebrew
-            - /usr/local/Homebrew/
-            # used in OSX custom build script dealing with local bottle caching
-            - $HOME/local_bottle_metadata
-      #workspaces share within the same build, cache shares between builds
-      cache:
-        directories:
-          # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
-          - $HOME/.ccache
-          # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
-          - $HOME/Library/Caches/Homebrew
-          - /usr/local/Homebrew/
-          # used in OSX custom build script dealing with local bottle caching
-          - $HOME/local_bottle_metadata
-
     # source distributions
     - os: linux
       stage: s1
@@ -111,8 +85,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.13.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -121,8 +94,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -131,8 +103,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.17.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -141,8 +112,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.19.3
-      workspaces:
-        use: brew_cache
+
 
     # headless builds for MacOS
     - os: osx
@@ -153,8 +123,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.13.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -163,8 +132,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -173,8 +141,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.17.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -183,8 +150,7 @@ jobs:
         - ENABLE_CONTRIB=0
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.19.3
-      workspaces:
-        use: brew_cache
+
 
     # Contrib builds for MacOS
     - os: osx
@@ -195,8 +161,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.13.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -205,8 +170,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.14.5
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -215,8 +179,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.17.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -225,8 +188,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=0
         - TEST_DEPENDS=numpy==1.19.3
-      workspaces:
-        use: brew_cache
+
 
     # headless contrib builds for MacOS
     - os: osx
@@ -237,8 +199,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.13.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -247,8 +208,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.14.5
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -257,8 +217,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.17.3
-      workspaces:
-        use: brew_cache
+
     - os: osx
       language: generic
       osx_image: xcode9.4
@@ -267,8 +226,7 @@ jobs:
         - ENABLE_CONTRIB=1
         - ENABLE_HEADLESS=1
         - TEST_DEPENDS=numpy==1.19.3
-      workspaces:
-        use: brew_cache
+
 
     # default builds for Linux
     - os: linux
@@ -925,24 +883,6 @@ before_install: |
       echo $ENABLE_CONTRIB > contrib.enabled
       echo $ENABLE_HEADLESS > headless.enabled
 
-      if [ -n "$IS_OSX" ]; then
-        export PATH="/usr/local/sbin:$PATH"
-        TAPS="$(brew --repository)/Library/Taps"
-        if [ -e "$TAPS/caskroom/homebrew-cask" -a -e "$TAPS/homebrew/homebrew-cask" ]; then
-            rm -rf "$TAPS/caskroom/homebrew-cask"
-        fi
-        find "$TAPS" -type d -name .git -exec \
-                bash -xec '
-                    cd $(dirname '\''{}'\'') || echo "status: $?"
-                    git clean -fxd || echo "status: $?"
-                    sleep 1 || echo "status: $?"
-                    git status || echo "status: $?"' \; || echo "status: $?"
-        brew_cache_cleanup
-      fi
-      echo "end"
-      # Not interested in travis internal scripts' output
-    fi
-
     set +x
 
 install: |
@@ -975,21 +915,6 @@ script: |
     trap ERR
     test "$rc" -eq 0
 
-before_cache: |
-    # Cleanup dirs to be cached
-    set -e; set -x
-    if [ -n "$IS_OSX" ]; then
-
-      # When Taps is cached, this dir causes "Error: file exists" on `brew update`
-      if [ -e "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask" ]; then
-        rm -rf "$(brew --repository)/Library/Taps/homebrew/homebrew-cask/homebrew-cask"
-      fi
-
-      brew_cache_cleanup
-
-    fi
-    set +x; set +e
-
 after_success: |
     # Upload wheels to pypi if tag is set
 
diff --git a/README.md b/README.md
index 6c6022ba..2352d2e8 100644
--- a/README.md
+++ b/README.md
@@ -49,10 +49,6 @@ A: No, the packages are special wheel binary packages and they already contain s
 
 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/.
-
 **Q: Import fails on Windows: ``ImportError: DLL load failed: The specified module could not be found.``?**
 
 A: If the import fails on Windows, make sure you have [Visual C++ redistributable 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145) installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, [Universal C Runtime](https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows) might be also required.
diff --git a/travis_config.sh b/travis_config.sh
index 910e365f..063baf8a 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -111,6 +111,7 @@ function pre_build {
         brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
     else
         brew unlink python@2
+        generate_ffmpeg_formula
         brew install ffmpeg_opencv
     fi
 

From b023344cf6c64fe50d840c2c9b36cb1608e073ac Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Wed, 2 Dec 2020 17:17:09 +0200
Subject: [PATCH 267/345] fix syntax

---
 .travis.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 42623a59..531c2627 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -883,6 +883,10 @@ before_install: |
       echo $ENABLE_CONTRIB > contrib.enabled
       echo $ENABLE_HEADLESS > headless.enabled
 
+      echo "end"
+      # Not interested in travis internal scripts' output
+    fi
+
     set +x
 
 install: |

From e83bc139980262fcb09158a88597a66324ee447a Mon Sep 17 00:00:00 2001
From: Thomas Nyberg <twn@thomasnyberg.com>
Date: Fri, 11 Dec 2020 11:11:24 +0100
Subject: [PATCH 268/345] Add docs for debug build

---
 README.md | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/README.md b/README.md
index 6c6022ba..bc97db72 100644
--- a/README.md
+++ b/README.md
@@ -140,6 +140,24 @@ If some dependency is not enabled in the pre-built wheels, you can also run the
     - 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
 
+#### Manual debug builds
+
+In order to build `opencv-python` in an unoptimized debug build, you need to side-step the normal process a bit.
+
+1. Install the packages `scikit-build` and `numpy` via pip.
+2. Run the command `python setup.py bdist_wheel --build-type=Debug`.
+3. Install the generated wheel file in the `dist/` folder with `pip install dist/wheelname.whl`.
+
+If you would like the build produce all compiler commands, then the following combination of flags and environment variables has been tested to work on Linux:
+```
+export CMAKE_ARGS='-DCMAKE_VERBOSE_MAKEFILE=ON'
+export VERBOSE=1
+
+python3 setup.py bdist_wheel --build-type=Debug
+```
+
+See this issue for more discussion: https://github.com/skvark/opencv-python/issues/424
+
 #### 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. 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.

From 7d1e48ca7bcf651c7ddc13d30a452e14d06db0dc Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 28 Dec 2020 19:56:24 +0200
Subject: [PATCH 269/345] arm64 azure cli does not work

---
 .travis.yml | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 531c2627..3c2efde8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -971,18 +971,20 @@ after_success: |
 
     # Save to Azure storage always
 
-    if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-      curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
-    else
-      brew install azure-cli
-    fi
+    if [[ $TRAVIS_CPU_ARCH != "arm64" ]]; then
+      if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+        curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
+      else
+        brew install azure-cli
+      fi
 
-    az storage container create -n ${TRAVIS_COMMIT} --public-access blob
+      az storage container create -n ${TRAVIS_COMMIT} --public-access blob
 
-    if [[ $SDIST == 1 ]]; then
-      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
-    else
-      az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
+      if [[ $SDIST == 1 ]]; then
+        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
+      else
+        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
+      fi
     fi
 
     set +x

From fed2178dfc28dfb034e8111579293affb77b2cf1 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 28 Dec 2020 20:02:34 +0200
Subject: [PATCH 270/345] fix paths

---
 setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 7b106847..a4f9f729 100644
--- a/setup.py
+++ b/setup.py
@@ -93,7 +93,7 @@ def main():
     # Path regexes with forward slashes relative to CMake install dir.
     rearrange_cmake_output_data = {
         "cv2": (
-            [r"bin/opencv_ffmpeg\d{3,4}%s\.dll" % ("_64" if x64 else "")]
+            [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if x64 else "")]
             if os.name == "nt"
             else []
         )
@@ -106,7 +106,7 @@ def main():
             % {"ext": re.escape(sysconfig.get_config_var("EXT_SUFFIX"))}
         ],
         "cv2.data": [  # OPENCV_OTHER_INSTALL_PATH
-            ("etc" if os.name == "nt" else "share/OpenCV") + r"/haarcascades/.*\.xml"
+            ("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml"
         ],
     }
 

From 5f56caf2c33cca711ae5c361b78a684990f85aac Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 28 Dec 2020 20:05:41 +0200
Subject: [PATCH 271/345] OpenCV 4.5.1

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index d5fd2f01..1363496c 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit d5fd2f0155ffad366f9ac912dfd6d189a7a6a98e
+Subproject commit 1363496c1106606684d40447f5d1149b2c66a9f8
diff --git a/opencv_contrib b/opencv_contrib
index 37315bab..b91a781c 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 37315babf9984a5b6aa981644a20dd8df1a5ff02
+Subproject commit b91a781cbc1285d441aa682926d93d8c23678b0b

From fd4e6040af94d9db3da25874132ca092b4c9e3a1 Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <op.heinisuo@gmail.com>
Date: Mon, 28 Dec 2020 20:40:12 +0200
Subject: [PATCH 272/345] disable Qt on macOS for now due to multiple issues

---
 cv2/__init__.py  |  4 +---
 setup.py         |  2 +-
 travis_config.sh | 16 ++++++++--------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/cv2/__init__.py b/cv2/__init__.py
index d665b75c..0c080d52 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -19,9 +19,7 @@
     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:
+if 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"
     )
diff --git a/setup.py b/setup.py
index a4f9f729..67f22c60 100644
--- a/setup.py
+++ b/setup.py
@@ -172,7 +172,7 @@ def main():
         if (
             not build_headless
             and "bdist_wheel" in sys.argv
-            and (sys.platform == "darwin" or sys.platform.startswith("linux"))
+            and sys.platform.startswith("linux")
         ):
             cmake_args.append("-DWITH_QT=5")
             subprocess.check_call("patch -p1 < patches/patchQtPlugins", shell=True)
diff --git a/travis_config.sh b/travis_config.sh
index 063baf8a..9ba0bb11 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -115,15 +115,15 @@ function pre_build {
         brew install ffmpeg_opencv
     fi
 
-    echo 'Installing qt5'
+    # 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
+    #    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
         brew_go_bootstrap_mode 0

From 89ca6a4ac9079c72d4d86d1c0f3141eeb0ca1bd6 Mon Sep 17 00:00:00 2001
From: Grigory Serebryakov <sergregory@users.noreply.github.com>
Date: Fri, 30 Apr 2021 20:16:59 +0300
Subject: [PATCH 273/345] Add GitHub actions setup for CI instead of Travis &
 Appveyour (where possible) (#470)

* Add initial config for github actions

* Allow actions for all branches and PRs to master by default

* Fix typo

* Do not set docker image info for multibuild, as we do it in github actions

* Do not run github action in docker as multiduild will do it for us

* Remove error steps - somehow I've missed them when cleaned for the build

* Merge all build logic into one step as somehow build wheel is not known when sourced and used in different steps

* Debug: try to change directory to get inside the repo sources

* Adjust env variables to enable build

* Specify docker image to use in github builds

* Enable back all python versions in build matrix

* Remove numpy as build dependency as prebuilt docker should handle it for us

* Make linux build matrix wider - enable contrib, headless/gui, source/binary distribution

* Fix return code setting for skipped tests in case of sdist

* Build source distribution with only one version of python - as we do not care abnout python version when doing the source distribution

* Try to fix config

* Try to fix config

* Enable OSX builds

* Quickfix to enable OSX build

* Temporary disable linux and all pythons execpt one to reduce the build matrix size

* Disable cache stage that was implemented for travis

* Do not unlink python2 for github osx builds

* Fix ffmpeg bottle build command

* Disable travis cache stage

* Changed build_wheels to Windows platform

* Try new pipeline

* Try windows with a new configuration

* Try bash on Windows

* Added ubuntu and macos into pipeline

* Fix if condition for windows

* Turned on all python versions, uploading artifacts

* Fixed Windows and created Release job

* Add missed source distribution build

* Move x86 python builds to github actions. Travis does only aarch64 now

* Split linux and OSX builds to exclude x86 OSX builds from build matrix

* Reduce architectures to x64 for both OSX and Ubuntu as x86 is supported for windows only

* Add PyPI secrets usage

* Publish packages built in PRs to testPyPI

* Push to test PyPI on each package build. Remove unneded build on push to master

* Apply review comments

* Combine all release steps into one job

Co-authored-by: Andrey Senyaev <andrey.senyaev@xperience.ai>
Co-authored-by: Andrey Senyaev <76472231+asenyaev@users.noreply.github.com>
---
 .github/workflows/build_wheels.yml | 279 +++++++++++++
 .travis.yml                        | 609 +----------------------------
 opencv                             |   2 +-
 travis_config.sh                   |  29 +-
 travis_osx_brew_cache.sh           |  95 ++---
 5 files changed, 359 insertions(+), 655 deletions(-)
 create mode 100644 .github/workflows/build_wheels.yml

diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml
new file mode 100644
index 00000000..cbed8b6c
--- /dev/null
+++ b/.github/workflows/build_wheels.yml
@@ -0,0 +1,279 @@
+name: Build PYPI wheels for opencv-python
+
+on:
+  pull_request:
+    branches:
+      - master
+  release:
+    types: [published, edited]
+
+
+jobs:
+  build-windows-x86_64:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: powershell
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [windows-latest]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x86, x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Update submodules
+      run: |
+        git submodule update --remote
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup MSBuild.exe
+      uses: warrenbuckley/Setup-MSBuild@v1
+
+    - name: build script
+      run: |
+        python --version
+        python -m pip install --upgrade pip
+        python -m pip install --upgrade setuptools
+        set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
+      shell: cmd
+
+    - name: before test
+      run: |
+        cd ${{ github.workspace }}/tests
+        &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
+        if ($LastExitCode -ne 0) {throw $LastExitCode}
+      shell: powershell
+
+    - name: run test
+      run: |
+        cd ${{ github.workspace }}/tests
+        python -m unittest test
+      shell: cmd
+
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+  build:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, macos-latest]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      REPO_DIR: .
+      BUILD_COMMIT: master
+      PROJECT_SPEC: opencv-python
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
+      MB_ML_VER: 2014
+      NP_TEST_DEP: numpy
+      TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      CONFIG_PATH: travis_config.sh
+      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      USE_CCACHE: 1
+      UNICODE_WIDTH: 32
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Update submodules
+      run: |
+        git submodule update --remote
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      if: ${{ 'macos-latest' == matrix.os }}
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup Environment variables
+      run: |
+        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
+        if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
+        if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
+        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
+        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+
+    - name: before install
+      run: |
+        set -e
+        # Check out and prepare the source
+        # Multibuild doesn't have releases, so --depth would break eventually (see
+        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+        git submodule update --init multibuild
+        source multibuild/common_utils.sh
+        # https://github.com/matthew-brett/multibuild/issues/116
+        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+        source multibuild/travis_steps.sh
+        # This sets -x
+        # source travis_multibuild_customize.sh
+        echo $ENABLE_CONTRIB > contrib.enabled
+        echo $ENABLE_HEADLESS > headless.enabled
+        set -x
+        build_wheel $REPO_DIR $PLAT
+        install_run $PLAT
+        set +x
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+
+  build_sdist:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest]
+        python-version: [3.8]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [1]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      REPO_DIR: .
+      BUILD_COMMIT: master
+      PROJECT_SPEC: opencv-python
+      PLAT: x86_64
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
+      MB_ML_VER: 2014
+      NP_TEST_DEP: numpy
+      TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      CONFIG_PATH: travis_config.sh
+      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      USE_CCACHE: 1
+      UNICODE_WIDTH: 32
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui || 0 }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib || 0}}
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Update submodules
+      run: |
+        git submodule update --remote
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup Environment variables
+      run: |
+        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
+        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
+        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+
+    - name: before install
+      run: |
+        set -e
+        # Build and package
+        set -x
+          python -m pip install --upgrade pip
+          python -m pip install scikit-build
+          python setup.py sdist
+        set +x
+        # Install and run tests
+        set -x
+        echo "skipping tests because of sdist"
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: dist/opencv*.tar.gz
+
+  release_opencv_python:
+    if: startsWith(github.ref, 'refs/tags/v')
+    needs: [build, build-windows-x86_64, build_sdist]
+    runs-on: ubuntu-latest
+    environment: opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+      - name: Upload wheels for opencv_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+
+      - name: Upload wheels for opencv_contrib_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+
+      - name: Upload wheels for opencv_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+
+      - name: Upload wheels for opencv_contrib_python_headless
+
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*
diff --git a/.travis.yml b/.travis.yml
index 3c2efde8..6ba06d4c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,7 +23,6 @@ cache:
 # Add more cache stages (s2 etc) and corresponding OSX jobs like s1
 # if brew builds start to take longer than one Travis time limit
 stages:
-  - s1
   - final
 
 jobs:
@@ -32,227 +31,7 @@ jobs:
   exclude:
     - language: ruby
   include:
-    # source distributions
-    - os: linux
-      stage: s1
-      script: skip
-      env:
-        - SDIST=1
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-      python: "3.8"
-      language: python
-      dist: xenial
-    - os: linux
-      stage: s1
-      script: skip
-      env:
-        - SDIST=1
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-      python: "3.8"
-      language: python
-      dist: xenial
-    - os: linux
-      stage: s1
-      script: skip
-      env:
-        - SDIST=1
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      python: "3.8"
-      language: python
-      dist: xenial
-    - os: linux
-      stage: s1
-      script: skip
-      env:
-        - SDIST=1
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      python: "3.8"
-      language: python
-      dist: xenial
-
-    # 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.6
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.13.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.14.5
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.9
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.19.3
-
-
-    # headless builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.13.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.14.5
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.17.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.9
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.19.3
-
-
-    # Contrib builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.13.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.14.5
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.9
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.19.3
-
-
-    # headless contrib builds for MacOS
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.13.3
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.14.5
-
-    - os: osx
-      language: generic
-      osx_image: xcode9.4
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.17.3
-
-    - 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
-
-
     # default builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.13.3
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - 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
@@ -268,30 +47,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.14.5
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      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
@@ -307,30 +62,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.17.3
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -346,30 +77,6 @@ jobs:
         - 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
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.9
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.19.3
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -387,30 +94,6 @@ jobs:
         directories: $HOME/.ccache
 
     # headless builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.13.3
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.13.3
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -426,30 +109,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.14.5
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.14.5
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -465,30 +124,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.17.3
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - PLAT=i686
-        - ENABLE_CONTRIB=0
-        - ENABLE_HEADLESS=1
-        - TEST_DEPENDS=numpy==1.17.3
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -504,30 +139,6 @@ jobs:
         - 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
@@ -545,30 +156,6 @@ jobs:
         directories: $HOME/.ccache
 
     # contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - TEST_DEPENDS=numpy==1.13.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - 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
@@ -584,30 +171,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - TEST_DEPENDS=numpy==1.14.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      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
@@ -623,30 +186,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - TEST_DEPENDS=numpy==1.17.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - PLAT=i686
-        - TEST_DEPENDS=numpy==1.17.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -662,30 +201,6 @@ jobs:
         - 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
-      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=0
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -704,30 +219,6 @@ jobs:
 
 
     # headless contrib builds for Linux
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - TEST_DEPENDS=numpy==1.13.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.6
-        - PLAT=i686
-        - 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
@@ -743,30 +234,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - TEST_DEPENDS=numpy==1.14.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.7
-        - PLAT=i686
-        - TEST_DEPENDS=numpy==1.14.5
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -782,30 +249,6 @@ jobs:
         - USE_CCACHE=0
       cache:
         directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - TEST_DEPENDS=numpy==1.17.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-      cache:
-        directories: $HOME/.ccache
-    - os: linux
-      language: generic
-      dist: xenial
-      services: docker
-      env:
-        - MB_PYTHON_VERSION=3.8
-        - PLAT=i686
-        - TEST_DEPENDS=numpy==1.17.3
-        - ENABLE_CONTRIB=1
-        - ENABLE_HEADLESS=1
-        - USE_CCACHE=0
-      cache:
-        directories: $HOME/.ccache
     - os: linux
       arch: arm64
       language: generic
@@ -821,30 +264,6 @@ jobs:
         - 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
@@ -969,23 +388,23 @@ after_success: |
 
     fi
 
-    # Save to Azure storage always
+    # # Save to Azure storage always
 
-    if [[ $TRAVIS_CPU_ARCH != "arm64" ]]; then
-      if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-        curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
-      else
-        brew install azure-cli
-      fi
+    # if [[ $TRAVIS_CPU_ARCH != "arm64" ]]; then
+    #   if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+    #     curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
+    #   else
+    #     brew install azure-cli
+    #   fi
 
-      az storage container create -n ${TRAVIS_COMMIT} --public-access blob
+    #   az storage container create -n ${TRAVIS_COMMIT} --public-access blob
 
-      if [[ $SDIST == 1 ]]; then
-        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
-      else
-        az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
-      fi
-    fi
+    #   if [[ $SDIST == 1 ]]; then
+    #     az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
+    #   else
+    #     az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
+    #   fi
+    # fi
 
     set +x
 
diff --git a/opencv b/opencv
index 1363496c..b19f8603 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 1363496c1106606684d40447f5d1149b2c66a9f8
+Subproject commit b19f8603843ac63274379c9e36331db6d4917001
diff --git a/travis_config.sh b/travis_config.sh
index 9ba0bb11..aac66317 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -95,28 +95,31 @@ function pre_build {
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
 
-    local CACHE_STAGE; (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
+    local CACHE_STAGE;# (echo "$TRAVIS_BUILD_STAGE_NAME" | grep -qiF "final") || CACHE_STAGE=1
+    CACHE_STAGE=
     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
-        generate_ffmpeg_formula
-        brew_add_local_bottles
-    fi
+    # if [ -n "$CACHE_STAGE" ]; then
+    #     brew update
+    #     generate_ffmpeg_formula
+    #     brew_add_local_bottles
+    # 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
+    # if [ -n "$CACHE_STAGE" ]; then
+    #     brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
+    # else
+        brew update
         generate_ffmpeg_formula
-        brew install ffmpeg_opencv
-    fi
+        brew_add_local_bottles
+        # brew unlink python@2
+        brew install --build-bottle ffmpeg_opencv
+    # fi
 
     # echo 'Installing qt5'
-    
+
     # if [ -n "$CACHE_STAGE" ]; then
     #    echo "Qt5 has bottle, no caching needed"
     # else
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index e3a69cc3..401265f2 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -4,6 +4,9 @@
 #Should be in Travis' cache
 BREW_LOCAL_BOTTLE_METADATA="$HOME/local_bottle_metadata"
 
+#FIXME: temporary fix to enable the build, should be replaced with the proper path to the cache dir
+mkdir -p $BREW_LOCAL_BOTTLE_METADATA
+
 # Starting reference point for elapsed build time; seconds since the epoch.
 #TRAVIS_TIMER_START_TIME is set at the start of a log fold, in nanoseconds since the epoch
 BREW_TIME_START=$(($TRAVIS_TIMER_START_TIME/10**9))
@@ -48,33 +51,33 @@ function brew_add_local_bottles {
     #  so that `brew` commands can find them.
     # If the package was updated, removes the corresponding files
     #  and the bottle's entry in the formula, if any.
-    
-    # Bottle entry in formula: 
+
+    # Bottle entry in formula:
     #   bottle do
     #     <...>
     #     sha256 "<sha256>" => :<os_codename>
     #     <...>
-    #   end 
-    
+    #   end
+
     echo "Cached bottles:"
     ls "$(brew --cache)/downloads" || true  #may not exist initially since it's "$(brew --cache)" that is in Travis cache
     echo "Saved .json's and links:"
     ls "$BREW_LOCAL_BOTTLE_METADATA"
-    
+
     for JSON in "$BREW_LOCAL_BOTTLE_METADATA"/*.json; do
         [ -e "$JSON" ] || break    # OSX 10.11 bash has no nullglob
         local PACKAGE JSON_VERSION JSON_REBUILD OS_CODENAME BOTTLE_HASH
-        
+
         _brew_parse_bottle_json "$JSON" PACKAGE JSON_VERSION JSON_REBUILD OS_CODENAME BOTTLE_HASH
 
         echo "Adding local bottle: $PACKAGE ${JSON_VERSION}_${JSON_REBUILD}"
-        
+
         local FORMULA_VERSION FORMULA_REBUILD FORMULA_BOTTLE_HASH
-        
+
         _brew_parse_package_info "$PACKAGE" "$OS_CODENAME" FORMULA_VERSION FORMULA_REBUILD FORMULA_BOTTLE_HASH
 
         local FORMULA_HAS_BOTTLE; [ -n "$FORMULA_BOTTLE_HASH" ] && FORMULA_HAS_BOTTLE=1 || true
-        
+
 
         local BOTTLE_LINK BOTTLE=""; BOTTLE_LINK="${JSON}.bottle.lnk";
         local BOTTLE_EXISTS= BOTTLE_MISMATCH= VERSION_MISMATCH=
@@ -88,10 +91,10 @@ function brew_add_local_bottles {
         if [ -f "$BOTTLE_LINK" ]; then
             BOTTLE=$(cat "$BOTTLE_LINK");
             BOTTLE=$(cd "$(dirname "$BOTTLE")"; pwd)/$(basename "$BOTTLE")
-            
+
             if [ -e "$BOTTLE" ]; then
                 BOTTLE_EXISTS=1;
-                
+
                 # The hash in `brew --cache $PACKAGE` entry is generated from download URL,
                 #  which itself is generated from base URL and version
                 # (see Homebrew/Library/Homebrew/download_strategy.rb:cached_location).
@@ -110,7 +113,7 @@ function brew_add_local_bottles {
         else
             echo "Link file is missing or of invalid type!" >&2
         fi
-                    
+
         # Delete cached bottle and all metadata if invalid
         if [[ -z "$BOTTLE_EXISTS" || -n "$VERSION_MISMATCH" || -n "$BOTTLE_MISMATCH" ]]; then
             echo "Deleting the cached bottle and all metadata"
@@ -133,11 +136,11 @@ function brew_add_local_bottles {
                     git commit -m "Removed obsolete local bottle ${JSON_VERSION}_${JSON_REBUILD} :${OS_CODENAME}" "$FORMULA"
                 )
             fi
-            
+
             if [ -n "$BOTTLE" -a -n "$BOTTLE_EXISTS" ]; then rm "$BOTTLE"; fi
             rm -f "$BOTTLE_LINK"
             rm "$JSON"
-            
+
         #(Re)add metadata to the formula otherwise
         else
             if [ "$FORMULA_BOTTLE_HASH" == "$BOTTLE_HASH" ]; then
@@ -156,7 +159,7 @@ function brew_cache_cleanup {
 
     #Lefovers from some failure probably
     rm -f "$BREW_LOCAL_BOTTLE_METADATA"/*.tar.gz
-    
+
     #`brew cleanup` may delete locally-built bottles that weren't needed this time
     # so we're saving and restoring them
     local BOTTLE_LINK BOTTLE
@@ -187,16 +190,16 @@ function brew_go_bootstrap_mode {
     local EXIT_CODE=${1:-1}
 
     echo "Going into cache bootstrap mode"
-    
+
     BREW_BOOTSTRAP_MODE=1
-        
+
     #Can't just `exit` because that would terminate the build without saving the cache
     #Have to replace further actions with no-ops
-    
+
     local MESSAGE=""; if [ "$EXIT_CODE" -ne 0 ]; then
         MESSAGE='Building dependencies took too long. Restart the build in Travis UI to continue from cache.';
     fi
-    
+
     eval '
     function '"$cmd"' { return 0; }
     function repair_wheelhouse { return 0; }
@@ -205,11 +208,11 @@ function brew_go_bootstrap_mode {
             echo \
         '        echo -e "\n'"$MESSAGE"'\n"'
         fi)"\
-    '    
+    '
         # Travis runs user scripts via `eval` i.e. in the same shell process.
         # So have to unset errexit in order to get to cache save stage
         set +e; return '"$EXIT_CODE"'
-    }'    
+    }'
 }
 
 
@@ -228,15 +231,15 @@ function _brew_install_and_cache_within_time_limit {
     if grep -qxFf <(cat <<<"$_BREW_ALREADY_INSTALLED") <<<"$PACKAGE"; then
         MARKED_INSTALLED=1
     fi
-        
+
     if [ -n "$MARKED_INSTALLED" ] || (brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE")); then
         echo "Already installed and the latest version: $PACKAGE"
         if [ -z "$MARKED_INSTALLED" ]; then _brew_mark_installed "$PACKAGE"; fi
         return 0
     fi
-    
+
     local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
-    
+
     _brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
     [ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
 
@@ -254,7 +257,7 @@ function _brew_install_and_cache_within_time_limit {
     _brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || return 2
     _brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || return $?
 }
-    
+
 
 function _brew_parse_bottle_json {
     # Parse JSON file resulting from `brew bottle --json`
@@ -271,9 +274,9 @@ function _brew_parse_bottle_json {
     print tag_name
     print tag_dict["sha256"]
     ' "$JSON")
-    
+
     unset JSON
-    
+
     { local i v; for i in {1..5}; do
         read -r v
         eval "${1:?}=\"$v\""
@@ -284,7 +287,7 @@ function _brew_parse_bottle_json {
 function _brew_parse_package_info {
     # Get and parse `brew info --json` about a package
     # and save data into specified variables
-    
+
     local PACKAGE OS_CODENAME
     PACKAGE="${1:?}"; shift
     OS_CODENAME="${1:?}"; shift
@@ -300,9 +303,9 @@ function _brew_parse_package_info {
     print bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"]     #prevent losing trailing blank line to command substitution
     ' \
     "$PACKAGE" "$OS_CODENAME"); JSON_DATA="${JSON_DATA%\!\?}"  #!? can't occur in a hash
-    
+
     unset PACKAGE OS_CODENAME
-    
+
     { local i v; for i in {1..3}; do
         read -r v
         eval "${1:?}=\"$v\""
@@ -346,13 +349,13 @@ function _brew_install_and_cache {
     # Install bottle or make and cache bottle.
     # assumes that deps were already installed
     # and not already the latest version
-    
+
     local PACKAGE USE_BOTTLE KEG_ONLY
     PACKAGE="${1:?}"
     USE_BOTTLE="${2:?}"
     KEG_ONLY="${3:?}"
     local VERB
-    
+
     if brew list --versions "$PACKAGE"; then
         # Install alongside the old version to avoid to have to update "runtime dependents"
         # https://discourse.brew.sh/t/can-i-install-a-new-version-without-having-to-upgrade-runtime-dependents/4443
@@ -363,7 +366,7 @@ function _brew_install_and_cache {
     else
         VERB=install
     fi
-    
+
     if [[ "$USE_BOTTLE" -gt 0 ]]; then
         echo "Installing bottle for: $PACKAGE"
         brew $VERB "$PACKAGE"
@@ -380,12 +383,12 @@ function _brew_install_and_cache {
         #proper procedure as per https://discourse.brew.sh/t/how-are-bottle-and-postinstall-related-is-it-safe-to-run-bottle-after-postinstall/3410/4
         brew uninstall --ignore-dependencies "$PACKAGE"
         brew $VERB "$BOTTLE"
-        
+
         local JSON; JSON=$(sed -E 's/bottle(.[[:digit:]]+)?\.tar\.gz$/bottle.json/' <<<"$BOTTLE")
-        
+
         #`brew bottle --merge` doesn't return nonzero on nonexisting json file
         test -f "$JSON" -a -f "$BOTTLE"
-        
+
         brew bottle --merge --write "$JSON"
         local CACHED_BOTTLE; CACHED_BOTTLE="$(brew --cache "$PACKAGE")"
         mv "$BOTTLE" "$CACHED_BOTTLE";
@@ -394,9 +397,9 @@ function _brew_install_and_cache {
         #Symlinks aren't cached by Travis. Will just save paths in files then.
         local BOTTLE_LINK; BOTTLE_LINK="${CACHED_JSON}.bottle.lnk"
         echo "$CACHED_BOTTLE" >"$BOTTLE_LINK"
-        
+
     fi
-    
+
     _brew_mark_installed "$PACKAGE"
 }
 
@@ -411,11 +414,11 @@ function _brew_check_elapsed_build_time {
     local TIME_START TIME_LIMIT ELAPSED_TIME
     TIME_START="${1:?}"
     TIME_LIMIT="${2:?}"
-    
+
     ELAPSED_TIME=$(($(date +%s) - $TIME_START))
     echo "Elapsed time: "$(($ELAPSED_TIME/60))"m (${ELAPSED_TIME}s)"
-    
-    if [[ "$ELAPSED_TIME" -gt $TIME_LIMIT ]]; then 
+
+    if [[ "$ELAPSED_TIME" -gt $TIME_LIMIT ]]; then
         brew_go_bootstrap_mode
         return 1
     fi
@@ -426,19 +429,19 @@ function _brew_check_slow_building_ahead {
 
     #If the package's projected build completion is higher than hard limit,
     # skip it and arrange for further build to be skipped and return 1
-    
+
     local PACKAGE TIME_START TIME_HARD_LIMIT
     PACKAGE="${1:?}"
     TIME_START="${2:?}"
     TIME_HARD_LIMIT="${3:?}"
-    
-    local PROJECTED_BUILD_TIME 
+
+    local PROJECTED_BUILD_TIME
     PROJECTED_BUILD_TIME=$(echo "$BREW_SLOW_BUILIDING_PACKAGES" | awk '$1=="'"$PACKAGE"'"{print $2}')
     [ -z "$PROJECTED_BUILD_TIME" ] && return 0 || true
-    
+
     local PROJECTED_BUILD_END_ELAPSED_TIME
     PROJECTED_BUILD_END_ELAPSED_TIME=$(( $(date +%s) - TIME_START + PROJECTED_BUILD_TIME * 60))
-    
+
     if [[ "$PROJECTED_BUILD_END_ELAPSED_TIME" -ge "$TIME_HARD_LIMIT" ]]; then
         echo -e "\nProjected build end elapsed time for $PACKAGE: $((PROJECTED_BUILD_END_ELAPSED_TIME/60))m ($PROJECTED_BUILD_END_ELAPSED_TIMEs)"
         brew_go_bootstrap_mode

From 4262df8adb5074ee03309fd7541fb1b12b99da66 Mon Sep 17 00:00:00 2001
From: Grigory Serebryakov <serebryakovgr@gmail.com>
Date: Fri, 30 Apr 2021 20:49:24 +0300
Subject: [PATCH 274/345] Update opencv to 4.5.2

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opencv b/opencv
index b19f8603..69357b1e 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit b19f8603843ac63274379c9e36331db6d4917001
+Subproject commit 69357b1e88680658a07cffde7678a4d697469f03
diff --git a/opencv_contrib b/opencv_contrib
index b91a781c..f5d7f671 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit b91a781cbc1285d441aa682926d93d8c23678b0b
+Subproject commit f5d7f6712d4ff229ba4f45cf79dfd11c557d56fd

From aa26990977aa021b7d9559666b5674b5ca76c2ec Mon Sep 17 00:00:00 2001
From: Olli-Pekka Heinisuo <skvark@users.noreply.github.com>
Date: Sat, 1 May 2021 23:40:51 +0300
Subject: [PATCH 275/345] make it possible to compile from sources against
 numpy on macOS aarch64 (#475)

---
 pyproject.toml | 1 +
 setup.py       | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index d7c5527d..07bcc4bb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,6 +3,7 @@ requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "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.20.1; python_version>='3.6' and sys_platform == 'darwin' 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 67f22c60..a3265206 100644
--- a/setup.py
+++ b/setup.py
@@ -31,10 +31,14 @@ def main():
     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":
+    # linux arm64 is a special case
+    if sys.platform.startswith("linux") and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
         minimum_supported_numpy = "1.19.3"
 
+    # macos arm64 is a special case
+    if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
+        minimum_supported_numpy = "1.20.1"
+
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 
     python_version = cmaker.CMaker.get_python_version()

From 42baf3cc06df377c63393a0e204be2e18ec69cb2 Mon Sep 17 00:00:00 2001
From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
Date: Thu, 6 May 2021 10:27:20 +0300
Subject: [PATCH 276/345] Documentation update after migration to OpenCV
 organization on Github.

---
 CONTRIBUTING.md |  7 +++++--
 README.md       | 28 ++++++++++++++++------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6a843f0e..07ac1259 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,9 +6,12 @@ Thank you for considering contributing to opencv-python.
 
 If you've noticed a bug or have a question that doesn't belong on
 [Stack Overflow](http://stackoverflow.com/questions/tagged/opencv-python),
-[search the issue tracker](https://github.com/skvark/opencv-python/issues?q=something)
+[search the project issue tracker](https://github.com/opencv/opencv-python/issues?q=something) or
+[search OpenCV issue tracker](https://github.com/opencv/opencv/issues?q=is%3Aissue+is%3Aopen+label%3A%22category%3A+python+bindings%22)
 to see if someone else in the community has already created a ticket.
-If not, go ahead and [make one](https://github.com/skvark/opencv-python/issues/new)!
+If not, go ahead and:
+- [make new one for opencv-python](https://github.com/opencv/opencv-python/issues/new) if you cannot load package or some functionality is not available!
+- [make new one for OpenCV](https://github.com/opencv/opencv-python/issues/new) if something went wrong with some function, class  or method in code!
 
 ### 2. Fork & create a branch
 
diff --git a/README.md b/README.md
index 232aa318..9629aae0 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
 
 ## OpenCV on Wheels
 
-**Unofficial** pre-built CPU-only OpenCV packages for Python.
+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. 
+Check the manual build section if you wish to compile the bindings from source to enable additional modules such as CUDA.
 
 ### Installation and Usage
 
@@ -30,7 +30,7 @@ Check the manual build section if you wish to compile the bindings from source t
 
     ``import cv2``
 
-    All packages contain haarcascade files. ``cv2.data.haarcascades`` can be used as a shortcut to the data folder. For example:
+    All packages contain Haar cascade files. ``cv2.data.haarcascades`` can be used as a shortcut to the data folder. For example:
 
     ``cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")``
 
@@ -57,7 +57,7 @@ Windows N and KN editions do not include Media Feature Pack which is required by
 
 If you have Windows Server 2012+, media DLLs are probably missing too; please install the Feature called "Media Foundation" in the Server Manager. Beware, some posts advise to install "Windows Server Essentials Media Pack", but this one requires the "Windows Server Essentials Experience" role, and this role will deeply affect your Windows Server configuration (by enforcing active directory integration etc.); so just installing the "Media Foundation" should be a safer choice.
 
-If the above does not help, check if you are using Anaconda. Old Anaconda versions have a bug which causes the error, see [this issue](https://github.com/skvark/opencv-python/issues/36) for a manual fix.
+If the above does not help, check if you are using Anaconda. Old Anaconda versions have a bug which causes the error, see [this issue](https://github.com/opencv/opencv-python/issues/36) for a manual fix.
 
 If you still encounter the error after you have checked all the previous solutions, download [Dependencies](https://github.com/lucasg/Dependencies) and open the ``cv2.pyd`` (located usually at ``C:\Users\username\AppData\Local\Programs\Python\PythonXX\Lib\site-packages\cv2``) file with it to debug missing DLL issues.
 
@@ -65,6 +65,10 @@ If you still encounter the error after you have checked all the previous solutio
 
 A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
 
+**Q: Function foo() or method bar() returns wrong result, throws exception or crashes interpriter. What should I do?**
+
+A: The repository contains only OpenCV-Python package build scripts, but not OpenCV itself. Python bindings for OpenCV are developed in official OpenCV repository and it's the best place to report issues. Also please check {OpenCV wiki](https://github.com/opencv/opencv/wiki) and [the fficial OpenCV forum](https://forum.opencv.org/) before file new bugs.
+
 **Q: Why the packages do not include non-free algorithms?**
 
 A: Non-free algorithms such as SURF are not included in these packages because they are patented / non-free and therefore cannot be distributed as built binaries. Note that SIFT is included in the builds due to patent expiration since OpenCV versions 4.3.0 and 3.4.10. See this issue for more info: https://github.com/skvark/opencv-python/issues/126
@@ -100,7 +104,7 @@ The build process for a single entry in the build matrices is as follows (see fo
    -  tests are disabled, otherwise build time increases too much
    -  there are 4 build matrix entries for each build combination: with and without contrib modules, with and without GUI (headless)
    -  Linux builds run in manylinux Docker containers (CentOS 5)
-   -  source distributions are separate entries in the build matrix 
+   -  source distributions are separate entries in the build matrix
 
 4. Rearrange OpenCV's build result, add our custom files and generate wheel
 
@@ -117,7 +121,7 @@ The build can be customized with environment variables. In addition to any varia
 - ``CI_BUILD``. Set to ``1`` to emulate the CI environment build behaviour. Used only in CI builds to force certain build flags on in ``setup.py``. Do not use this unless you know what you are doing.
 - ``ENABLE_CONTRIB`` and ``ENABLE_HEADLESS``. Set to ``1`` to build the contrib and/or headless version
 - ``ENABLE_JAVA``, Set to ``1`` to enable the Java client build.  This is disabled by default.
-- ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build. 
+- ``CMAKE_ARGS``. Additional arguments for OpenCV's CMake invocation. You can use this to make a custom build.
 
 See the next section for more info about manual builds outside the CI environment.
 
@@ -125,7 +129,7 @@ See the next section for more info about manual builds outside the CI environmen
 
 If some dependency is not enabled in the pre-built wheels, you can also run the build locally to create a custom wheel.
 
-1. Clone this repository: `git clone --recursive https://github.com/skvark/opencv-python.git`
+1. Clone this repository: `git clone --recursive https://github.com/opencv/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)
@@ -152,18 +156,18 @@ export VERBOSE=1
 python3 setup.py bdist_wheel --build-type=Debug
 ```
 
-See this issue for more discussion: https://github.com/skvark/opencv-python/issues/424
+See this issue for more discussion: https://github.com/opencv/opencv-python/issues/424
 
 #### 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. 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: 
+You can also force ``pip`` to build the wheels from the source distribution. Some examples:
 
 - ``pip install --no-binary opencv-python opencv-python``
 - ``pip install --no-binary :all: opencv-python``
 
-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. 
+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.
 
 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.
 
@@ -173,13 +177,13 @@ Opencv-python package (scripts in this repository) is available under MIT licens
 
 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).
+Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/opencv/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 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).
+The packages include also other binaries. Full list of licenses can be found from [LICENSE-3RD-PARTY.txt](https://github.com/opencv/opencv-python/blob/master/LICENSE-3RD-PARTY.txt).
 
 ### Versioning
 

From 88c1735deff42f2b2eacf66bf59aafc5c0f25763 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <76472231+asenyaev@users.noreply.github.com>
Date: Thu, 6 May 2021 22:37:49 +0300
Subject: [PATCH 277/345] Fixed if condition for release job (#478)

* Fixed if condition for release job

* Added the test release job, changed if condition

* Merged all upload steps into one for pre-release
---
 .github/workflows/build_wheels.yml | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml
index cbed8b6c..67f7ad8d 100644
--- a/.github/workflows/build_wheels.yml
+++ b/.github/workflows/build_wheels.yml
@@ -244,8 +244,27 @@ jobs:
         name: wheels
         path: dist/opencv*.tar.gz
 
+  test_release_opencv_python:
+    if: github.event_name == 'release' && github.event.release.prerelease
+    needs: [build, build-windows-x86_64, build_sdist]
+    runs-on: ubuntu-latest
+    environment: test-opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload all wheels
+        run: |
+          python -m pip install twine
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+
   release_opencv_python:
-    if: startsWith(github.ref, 'refs/tags/v')
+    if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build, build-windows-x86_64, build_sdist]
     runs-on: ubuntu-latest
     environment: opencv-python-release
@@ -257,6 +276,7 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
+
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
@@ -273,7 +293,6 @@ jobs:
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
 
       - name: Upload wheels for opencv_contrib_python_headless
-
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*

From c34cbfa3cb627ee40d83e719a539369645015356 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Tue, 11 May 2021 18:38:41 +0300
Subject: [PATCH 278/345] Added arm build

---
 .github/workflows/build_wheels.yml | 110 ++++++++++++++++++++++++++++-
 .gitmodules                        |   3 +
 opencv_extra                       |   1 +
 travis_config.sh                   |  15 ++--
 4 files changed, 123 insertions(+), 6 deletions(-)
 create mode 160000 opencv_extra

diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml
index 67f7ad8d..8d368f22 100644
--- a/.github/workflows/build_wheels.yml
+++ b/.github/workflows/build_wheels.yml
@@ -159,6 +159,7 @@ jobs:
         build_wheel $REPO_DIR $PLAT
         install_run $PLAT
         set +x
+
     - name: saving artifacts
       uses: actions/upload-artifact@v2
       with:
@@ -238,15 +239,120 @@ jobs:
         # Install and run tests
         set -x
         echo "skipping tests because of sdist"
+
     - name: saving artifacts
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: dist/opencv*.tar.gz
 
+  build_arm:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [jetson]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      REPO_DIR: .
+      BUILD_COMMIT: master
+      PROJECT_SPEC: opencv-python
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
+      PLAT: aarch64
+      MB_ML_VER: 2014
+      NP_TEST_DEP: numpy
+      TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      CONFIG_PATH: travis_config.sh
+      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
+      USE_CCACHE: 0
+      UNICODE_WIDTH: 32
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Cleanup
+      if: always()
+      uses: AutoModality/action-clean@v1
+
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Setup Environment variables
+      run: |
+        if [ "jetson" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
+        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
+        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+
+    - name: before install
+      run: |
+        set -e
+        if [[ $SDIST == 0 ]]; then
+          # Check out and prepare the source
+          # Multibuild doesn't have releases, so --depth would break eventually (see
+          # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+          git submodule update --init multibuild
+          source multibuild/common_utils.sh
+          # https://github.com/matthew-brett/multibuild/issues/116
+          if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+          source multibuild/travis_steps.sh
+          # This sets -x
+          # source travis_multibuild_customize.sh
+          echo $ENABLE_CONTRIB > contrib.enabled
+          echo $ENABLE_HEADLESS > headless.enabled
+          echo "end"
+          # Not interested in travis internal scripts' output
+        fi
+        set +x
+        # Build and package
+        set -x
+        ls
+        if [[ $SDIST == 1 ]]; then
+          python -m pip install --upgrade pip
+          python -m pip install scikit-build
+          python setup.py sdist
+        else
+          build_wheel $REPO_DIR $PLAT
+        fi
+        set +x
+        # Install and run tests
+        set -x
+        if [[ $SDIST == 1 ]]; then
+          echo "skipping tests because of sdist"
+          rc=0
+        else
+          install_run $PLAT && rc=$? || rc=$?
+        fi
+        set +x
+        #otherwise, Travis logic terminates prematurely
+        #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
+        trap ERR
+        test "$rc" -eq 0
+
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build, build-windows-x86_64, build_sdist]
+    needs: [build, build-windows-x86_64, build_sdist, build_arm]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -265,7 +371,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build, build-windows-x86_64, build_sdist]
+    needs: [build, build-windows-x86_64, build_sdist, build_arm]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.gitmodules b/.gitmodules
index f2e0d283..655467e8 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,3 +7,6 @@
 [submodule "multibuild"]
 	path = multibuild
 	url = https://github.com/matthew-brett/multibuild.git
+[submodule "opencv_extra"]
+	path = opencv_extra
+	url = https://github.com/opencv/opencv_extra.git
diff --git a/opencv_extra b/opencv_extra
new file mode 160000
index 00000000..3b033d09
--- /dev/null
+++ b/opencv_extra
@@ -0,0 +1 @@
+Subproject commit 3b033d09cab1894d6452707df723789fe98c8663
diff --git a/travis_config.sh b/travis_config.sh
index aac66317..b1a991a4 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -146,24 +146,31 @@ function run_tests {
     echo "Run tests..."
     echo $PWD
 
+    PYTHON=python$PYTHON_VERSION
+
     if [ -n "$IS_OSX" ]; then
       echo "Running for OS X"
-      cd ../tests/
+      cd ../opencv/
+      export OPENCV_TEST_DATA_PATH=../opencv_extra/testdata
     else
       echo "Running for linux"
-      cd /io/tests/
+
+      if [ $PYTHON == "python3.6" ]; then
+        $PYTHON -m pip install -U numpy==1.19.4
+      fi
+      cd /io/opencv
+      export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata
     fi
 
     test_wheels
 }
 
 function test_wheels {
-    PYTHON=python$PYTHON_VERSION
 
     echo "Starting tests..."
 
     #Test package
-    $PYTHON -m unittest test
+    $PYTHON modules/python/test/test.py -v --repo .
 }
 
 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'

From 5d274516839ae170bd863773155ba154894e41fc Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 12 May 2021 09:58:59 +0300
Subject: [PATCH 279/345] Changed the label for a runner

---
 .github/workflows/build_wheels.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml
index 8d368f22..e13e803e 100644
--- a/.github/workflows/build_wheels.yml
+++ b/.github/workflows/build_wheels.yml
@@ -255,7 +255,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [jetson]
+        os: [ARM64]
         python-version: [3.6, 3.7, 3.8, 3.9]
         platform: [x64]
         with_contrib: [0, 1]
@@ -295,7 +295,7 @@ jobs:
 
     - name: Setup Environment variables
       run: |
-        if [ "jetson" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
+        if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
         echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
         echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
 

From 6336ca866644dc5daf64831a4352c23479e1d248 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Tue, 18 May 2021 17:24:18 +0300
Subject: [PATCH 280/345] Split workflows according to platforms

---
 ...uild_wheels.yml => build_wheels_linux.yml} | 181 +-----------------
 .github/workflows/build_wheels_linux_arm.yml  | 167 ++++++++++++++++
 .github/workflows/build_wheels_macos.yml      | 151 +++++++++++++++
 .github/workflows/build_wheels_windows.yml    | 132 +++++++++++++
 4 files changed, 454 insertions(+), 177 deletions(-)
 rename .github/workflows/{build_wheels.yml => build_wheels_linux.yml} (59%)
 create mode 100644 .github/workflows/build_wheels_linux_arm.yml
 create mode 100644 .github/workflows/build_wheels_macos.yml
 create mode 100644 .github/workflows/build_wheels_windows.yml

diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels_linux.yml
similarity index 59%
rename from .github/workflows/build_wheels.yml
rename to .github/workflows/build_wheels_linux.yml
index e13e803e..c371b774 100644
--- a/.github/workflows/build_wheels.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -1,4 +1,4 @@
-name: Build PYPI wheels for opencv-python
+name: Build PYPI wheels for opencv-python on Linux x86_64
 
 on:
   pull_request:
@@ -9,75 +9,6 @@ on:
 
 
 jobs:
-  build-windows-x86_64:
-    runs-on: ${{ matrix.os }}
-    defaults:
-      run:
-        shell: powershell
-
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [windows-latest]
-        python-version: [3.6, 3.7, 3.8, 3.9]
-        platform: [x86, x64]
-        with_contrib: [0, 1]
-        without_gui: [0, 1]
-        build_sdist: [0]
-
-    env:
-      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
-      SDIST: ${{ matrix.build_sdist || 0}}
-      ENABLE_HEADLESS: ${{ matrix.without_gui }}
-      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
-    steps:
-    - name: Checkout
-      uses: actions/checkout@v2
-      with:
-        submodules: true
-        fetch-depth: 0
-
-    - name: Update submodules
-      run: |
-        git submodule update --remote
-
-    - name: Set up Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
-      with:
-        python-version: ${{ matrix.python-version }}
-        architecture: ${{ matrix.platform }}
-
-    - name: Setup MSBuild.exe
-      uses: warrenbuckley/Setup-MSBuild@v1
-
-    - name: build script
-      run: |
-        python --version
-        python -m pip install --upgrade pip
-        python -m pip install --upgrade setuptools
-        set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
-      shell: cmd
-
-    - name: before test
-      run: |
-        cd ${{ github.workspace }}/tests
-        &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
-        if ($LastExitCode -ne 0) {throw $LastExitCode}
-      shell: powershell
-
-    - name: run test
-      run: |
-        cd ${{ github.workspace }}/tests
-        python -m unittest test
-      shell: cmd
-
-    - name: saving artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        name: wheels
-        path: wheelhouse/opencv*.whl
-
   build:
     runs-on: ${{ matrix.os }}
     defaults:
@@ -87,7 +18,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest, macos-latest]
+        os: [ubuntu-latest]
         python-version: [3.6, 3.7, 3.8, 3.9]
         platform: [x64]
         with_contrib: [0, 1]
@@ -246,113 +177,9 @@ jobs:
         name: wheels
         path: dist/opencv*.tar.gz
 
-  build_arm:
-    runs-on: ${{ matrix.os }}
-    defaults:
-      run:
-        shell: bash
-
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [ARM64]
-        python-version: [3.6, 3.7, 3.8, 3.9]
-        platform: [x64]
-        with_contrib: [0, 1]
-        without_gui: [0, 1]
-        build_sdist: [0]
-
-    env:
-      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
-      REPO_DIR: .
-      BUILD_COMMIT: master
-      PROJECT_SPEC: opencv-python
-      MB_PYTHON_VERSION: ${{ matrix.python-version }}
-      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
-      PLAT: aarch64
-      MB_ML_VER: 2014
-      NP_TEST_DEP: numpy
-      TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
-      DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
-      USE_CCACHE: 0
-      UNICODE_WIDTH: 32
-      SDIST: ${{ matrix.build_sdist || 0}}
-      ENABLE_HEADLESS: ${{ matrix.without_gui }}
-      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
-    steps:
-    - name: Cleanup
-      if: always()
-      uses: AutoModality/action-clean@v1
-
-    - name: Checkout
-      uses: actions/checkout@v2
-      with:
-        submodules: true
-        fetch-depth: 0
-
-    - name: Setup Environment variables
-      run: |
-        if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
-        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
-        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
-
-    - name: before install
-      run: |
-        set -e
-        if [[ $SDIST == 0 ]]; then
-          # Check out and prepare the source
-          # Multibuild doesn't have releases, so --depth would break eventually (see
-          # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-          git submodule update --init multibuild
-          source multibuild/common_utils.sh
-          # https://github.com/matthew-brett/multibuild/issues/116
-          if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-          source multibuild/travis_steps.sh
-          # This sets -x
-          # source travis_multibuild_customize.sh
-          echo $ENABLE_CONTRIB > contrib.enabled
-          echo $ENABLE_HEADLESS > headless.enabled
-          echo "end"
-          # Not interested in travis internal scripts' output
-        fi
-        set +x
-        # Build and package
-        set -x
-        ls
-        if [[ $SDIST == 1 ]]; then
-          python -m pip install --upgrade pip
-          python -m pip install scikit-build
-          python setup.py sdist
-        else
-          build_wheel $REPO_DIR $PLAT
-        fi
-        set +x
-        # Install and run tests
-        set -x
-        if [[ $SDIST == 1 ]]; then
-          echo "skipping tests because of sdist"
-          rc=0
-        else
-          install_run $PLAT && rc=$? || rc=$?
-        fi
-        set +x
-        #otherwise, Travis logic terminates prematurely
-        #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
-        trap ERR
-        test "$rc" -eq 0
-
-    - name: saving artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        name: wheels
-        path: wheelhouse/opencv*.whl
-
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build, build-windows-x86_64, build_sdist, build_arm]
+    needs: [build, build_sdist]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -371,7 +198,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build, build-windows-x86_64, build_sdist, build_arm]
+    needs: [build, build_sdist]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
new file mode 100644
index 00000000..de444d90
--- /dev/null
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -0,0 +1,167 @@
+name: Build PYPI wheels for opencv-python on Linux ARM
+
+on:
+  pull_request:
+    branches:
+      - master
+  release:
+    types: [published, edited]
+
+
+jobs:
+  build_arm:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ARM64]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      REPO_DIR: .
+      BUILD_COMMIT: master
+      PROJECT_SPEC: opencv-python
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
+      PLAT: aarch64
+      MB_ML_VER: 2014
+      NP_TEST_DEP: numpy
+      TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      CONFIG_PATH: travis_config.sh
+      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
+      USE_CCACHE: 0
+      UNICODE_WIDTH: 32
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Cleanup
+      if: always()
+      uses: AutoModality/action-clean@v1
+
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Setup Environment variables
+      run: |
+        if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
+        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
+        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+
+    - name: before install
+      run: |
+        set -e
+        if [[ $SDIST == 0 ]]; then
+          # Check out and prepare the source
+          # Multibuild doesn't have releases, so --depth would break eventually (see
+          # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+          git submodule update --init multibuild
+          source multibuild/common_utils.sh
+          # https://github.com/matthew-brett/multibuild/issues/116
+          if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+          source multibuild/travis_steps.sh
+          # This sets -x
+          # source travis_multibuild_customize.sh
+          echo $ENABLE_CONTRIB > contrib.enabled
+          echo $ENABLE_HEADLESS > headless.enabled
+          echo "end"
+          # Not interested in travis internal scripts' output
+        fi
+        set +x
+        # Build and package
+        set -x
+        ls
+        if [[ $SDIST == 1 ]]; then
+          python -m pip install --upgrade pip
+          python -m pip install scikit-build
+          python setup.py sdist
+        else
+          build_wheel $REPO_DIR $PLAT
+        fi
+        set +x
+        # Install and run tests
+        set -x
+        if [[ $SDIST == 1 ]]; then
+          echo "skipping tests because of sdist"
+          rc=0
+        else
+          install_run $PLAT && rc=$? || rc=$?
+        fi
+        set +x
+        #otherwise, Travis logic terminates prematurely
+        #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
+        trap ERR
+        test "$rc" -eq 0
+
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+  test_release_opencv_python:
+    if: github.event_name == 'release' && github.event.release.prerelease
+    needs: [build_arm]
+    runs-on: ubuntu-latest
+    environment: test-opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload all wheels
+        run: |
+          python -m pip install twine
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+
+  release_opencv_python:
+    if: github.event_name == 'release' && !github.event.release.prerelease
+    needs: [build_arm]
+    runs-on: ubuntu-latest
+    environment: opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload wheels for opencv_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+
+      - name: Upload wheels for opencv_contrib_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+
+      - name: Upload wheels for opencv_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+
+      - name: Upload wheels for opencv_contrib_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
new file mode 100644
index 00000000..d540f6c1
--- /dev/null
+++ b/.github/workflows/build_wheels_macos.yml
@@ -0,0 +1,151 @@
+name: Build PYPI wheels for opencv-python on Macos
+
+on:
+  pull_request:
+    branches:
+      - master
+  release:
+    types: [published, edited]
+
+
+jobs:
+  build:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macos-latest]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      REPO_DIR: .
+      BUILD_COMMIT: master
+      PROJECT_SPEC: opencv-python
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
+      MB_ML_VER: 2014
+      NP_TEST_DEP: numpy
+      TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      CONFIG_PATH: travis_config.sh
+      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      USE_CCACHE: 1
+      UNICODE_WIDTH: 32
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Update submodules
+      run: |
+        git submodule update --remote
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      if: ${{ 'macos-latest' == matrix.os }}
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup Environment variables
+      run: |
+        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
+        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
+        if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
+        if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
+        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
+        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+
+    - name: before install
+      run: |
+        set -e
+        # Check out and prepare the source
+        # Multibuild doesn't have releases, so --depth would break eventually (see
+        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+        git submodule update --init multibuild
+        source multibuild/common_utils.sh
+        # https://github.com/matthew-brett/multibuild/issues/116
+        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+        source multibuild/travis_steps.sh
+        # This sets -x
+        # source travis_multibuild_customize.sh
+        echo $ENABLE_CONTRIB > contrib.enabled
+        echo $ENABLE_HEADLESS > headless.enabled
+        set -x
+        build_wheel $REPO_DIR $PLAT
+        install_run $PLAT
+        set +x
+
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+  test_release_opencv_python:
+    if: github.event_name == 'release' && github.event.release.prerelease
+    needs: [build]
+    runs-on: ubuntu-latest
+    environment: test-opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload all wheels
+        run: |
+          python -m pip install twine
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+
+  release_opencv_python:
+    if: github.event_name == 'release' && !github.event.release.prerelease
+    needs: [build]
+    runs-on: ubuntu-latest
+    environment: opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload wheels for opencv_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+
+      - name: Upload wheels for opencv_contrib_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+
+      - name: Upload wheels for opencv_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+
+      - name: Upload wheels for opencv_contrib_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
new file mode 100644
index 00000000..76e6c35e
--- /dev/null
+++ b/.github/workflows/build_wheels_windows.yml
@@ -0,0 +1,132 @@
+name: Build PYPI wheels for opencv-python on Windows
+
+on:
+  pull_request:
+    branches:
+      - master
+  release:
+    types: [published, edited]
+
+
+jobs:
+  build-windows-x86_64:
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: powershell
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [windows-latest]
+        python-version: [3.6, 3.7, 3.8, 3.9]
+        platform: [x86, x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      SDIST: ${{ matrix.build_sdist || 0}}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Update submodules
+      run: |
+        git submodule update --remote
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup MSBuild.exe
+      uses: warrenbuckley/Setup-MSBuild@v1
+
+    - name: build script
+      run: |
+        python --version
+        python -m pip install --upgrade pip
+        python -m pip install --upgrade setuptools
+        set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
+      shell: cmd
+
+    - name: before test
+      run: |
+        cd ${{ github.workspace }}/tests
+        &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
+        if ($LastExitCode -ne 0) {throw $LastExitCode}
+      shell: powershell
+
+    - name: run test
+      run: |
+        cd ${{ github.workspace }}/tests
+        python -m unittest test
+      shell: cmd
+
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+  test_release_opencv_python:
+    if: github.event_name == 'release' && github.event.release.prerelease
+    needs: [build-windows-x86_64]
+    runs-on: ubuntu-latest
+    environment: test-opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload all wheels
+        run: |
+          python -m pip install twine
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+
+  release_opencv_python:
+    if: github.event_name == 'release' && !github.event.release.prerelease
+    needs: [build-windows-x86_64]
+    runs-on: ubuntu-latest
+    environment: opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload wheels for opencv_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+
+      - name: Upload wheels for opencv_contrib_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+
+      - name: Upload wheels for opencv_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+
+      - name: Upload wheels for opencv_contrib_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*

From 2bab1f58c70371b6f2e3108eebeb27311050aaea Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Thu, 27 May 2021 09:45:26 +0300
Subject: [PATCH 281/345] Split builds and tests for linux, update submodules
 only when a PR, turned off freetype because of issues, added get_build_info
 script

---
 .github/workflows/build_wheels_linux.yml     | 42 ++++++++++++--------
 .github/workflows/build_wheels_linux_arm.yml |  2 +-
 .github/workflows/build_wheels_macos.yml     |  6 +--
 .github/workflows/build_wheels_windows.yml   | 12 +++---
 setup.py                                     |  1 +
 tests/get_build_info.py                      |  3 ++
 travis_config.sh                             |  7 ++++
 7 files changed, 48 insertions(+), 25 deletions(-)
 create mode 100644 tests/get_build_info.py

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index c371b774..2b6f8efe 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -39,7 +39,7 @@ jobs:
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
-      SDIST: ${{ matrix.build_sdist || 0}}
+      SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
 
@@ -47,19 +47,12 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: true
+        submodules: false
         fetch-depth: 0
 
     - name: Update submodules
-      run: |
-        git submodule update --remote
-
-    - name: Set up Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
-      if: ${{ 'macos-latest' == matrix.os }}
-      with:
-        python-version: ${{ matrix.python-version }}
-        architecture: ${{ matrix.platform }}
+      if: github.event_name == 'pull_request'
+      run: git submodule update --remote
 
     - name: Setup Environment variables
       run: |
@@ -71,7 +64,7 @@ jobs:
         echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
         echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
 
-    - name: before install
+    - name: build
       run: |
         set -e
         # Check out and prepare the source
@@ -88,6 +81,23 @@ jobs:
         echo $ENABLE_HEADLESS > headless.enabled
         set -x
         build_wheel $REPO_DIR $PLAT
+
+    - name: install and test
+      run: |
+        set -e
+        # Check out and prepare the source
+        # Multibuild doesn't have releases, so --depth would break eventually (see
+        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+        git submodule update --init --recursive
+        source multibuild/common_utils.sh
+        # https://github.com/matthew-brett/multibuild/issues/116
+        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+        source multibuild/travis_steps.sh
+        # This sets -x
+        # source travis_multibuild_customize.sh
+        echo $ENABLE_CONTRIB > contrib.enabled
+        echo $ENABLE_HEADLESS > headless.enabled
+        set -x
         install_run $PLAT
         set +x
 
@@ -129,9 +139,9 @@ jobs:
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
-      SDIST: ${{ matrix.build_sdist || 0}}
+      SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui || 0 }}
-      ENABLE_CONTRIB: ${{ matrix.with_contrib || 0}}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib || 0 }}
 
     steps:
     - name: Checkout
@@ -141,8 +151,8 @@ jobs:
         fetch-depth: 0
 
     - name: Update submodules
-      run: |
-        git submodule update --remote
+      if: github.event_name == 'pull_request'
+      run: git submodule update --remote
 
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index de444d90..a680401a 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -41,7 +41,7 @@ jobs:
       DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
-      SDIST: ${{ matrix.build_sdist || 0}}
+      SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
 
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index d540f6c1..bfce806f 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -39,7 +39,7 @@ jobs:
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
-      SDIST: ${{ matrix.build_sdist || 0}}
+      SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
 
@@ -51,8 +51,8 @@ jobs:
         fetch-depth: 0
 
     - name: Update submodules
-      run: |
-        git submodule update --remote
+      if: github.event_name == 'pull_request'
+      run: git submodule update --remote
 
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 76e6c35e..03a341e4 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -27,9 +27,10 @@ jobs:
 
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
-      SDIST: ${{ matrix.build_sdist || 0}}
+      SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
 
     steps:
     - name: Checkout
@@ -39,8 +40,8 @@ jobs:
         fetch-depth: 0
 
     - name: Update submodules
-      run: |
-        git submodule update --remote
+      if: github.event_name == 'pull_request'
+      run: git submodule update --remote
 
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
@@ -64,12 +65,13 @@ jobs:
         cd ${{ github.workspace }}/tests
         &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
         if ($LastExitCode -ne 0) {throw $LastExitCode}
+        python get_build_info.py
       shell: powershell
 
     - name: run test
       run: |
-        cd ${{ github.workspace }}/tests
-        python -m unittest test
+        cd ${{ github.workspace }}/opencv
+        python modules\python\test\test.py -v --repo .
       shell: cmd
 
     - name: saving artifacts
diff --git a/setup.py b/setup.py
index a3265206..a14825da 100644
--- a/setup.py
+++ b/setup.py
@@ -145,6 +145,7 @@ def main():
             "-DINSTALL_CREATE_DISTRIB=ON",
             # See opencv/CMakeLists.txt for options and defaults
             "-DBUILD_opencv_apps=OFF",
+            "-DBUILD_opencv_freetype=OFF",
             "-DBUILD_SHARED_LIBS=OFF",
             "-DBUILD_TESTS=OFF",
             "-DBUILD_PERF_TESTS=OFF",
diff --git a/tests/get_build_info.py b/tests/get_build_info.py
new file mode 100644
index 00000000..4714f2f4
--- /dev/null
+++ b/tests/get_build_info.py
@@ -0,0 +1,3 @@
+import cv2 as cv
+
+print(cv.getBuildInformation())
diff --git a/travis_config.sh b/travis_config.sh
index b1a991a4..a83fe141 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -150,6 +150,10 @@ function run_tests {
 
     if [ -n "$IS_OSX" ]; then
       echo "Running for OS X"
+
+      cd ../tests
+      $PYTHON get_build_info.py
+
       cd ../opencv/
       export OPENCV_TEST_DATA_PATH=../opencv_extra/testdata
     else
@@ -158,6 +162,9 @@ function run_tests {
       if [ $PYTHON == "python3.6" ]; then
         $PYTHON -m pip install -U numpy==1.19.4
       fi
+      cd /io/tests
+      $PYTHON get_build_info.py
+
       cd /io/opencv
       export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata
     fi

From 83deed818f0f83fd193eb1d5bace23fac0f1eba0 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Thu, 3 Jun 2021 13:20:20 +0300
Subject: [PATCH 282/345] Extracted build and install+test steps into two
 different scripts and fixed issues

---
 .github/workflows/build_wheels_linux.yml     | 44 ++--------------
 .github/workflows/build_wheels_linux_arm.yml | 53 +++-----------------
 .github/workflows/build_wheels_macos.yml     |  5 +-
 .github/workflows/build_wheels_windows.yml   |  3 +-
 scripts/build.sh                             | 17 +++++++
 scripts/install.sh                           | 18 +++++++
 6 files changed, 52 insertions(+), 88 deletions(-)
 create mode 100755 scripts/build.sh
 create mode 100755 scripts/install.sh

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 2b6f8efe..c9307d74 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -33,7 +33,7 @@ jobs:
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy
+      NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
@@ -56,50 +56,17 @@ jobs:
 
     - name: Setup Environment variables
       run: |
-        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
-        if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
         echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
         echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
 
     - name: build
-      run: |
-        set -e
-        # Check out and prepare the source
-        # Multibuild doesn't have releases, so --depth would break eventually (see
-        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-        git submodule update --init multibuild
-        source multibuild/common_utils.sh
-        # https://github.com/matthew-brett/multibuild/issues/116
-        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-        source multibuild/travis_steps.sh
-        # This sets -x
-        # source travis_multibuild_customize.sh
-        echo $ENABLE_CONTRIB > contrib.enabled
-        echo $ENABLE_HEADLESS > headless.enabled
-        set -x
-        build_wheel $REPO_DIR $PLAT
+      run: source scripts/build.sh
 
     - name: install and test
-      run: |
-        set -e
-        # Check out and prepare the source
-        # Multibuild doesn't have releases, so --depth would break eventually (see
-        # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-        git submodule update --init --recursive
-        source multibuild/common_utils.sh
-        # https://github.com/matthew-brett/multibuild/issues/116
-        if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-        source multibuild/travis_steps.sh
-        # This sets -x
-        # source travis_multibuild_customize.sh
-        echo $ENABLE_CONTRIB > contrib.enabled
-        echo $ENABLE_HEADLESS > headless.enabled
-        set -x
-        install_run $PLAT
-        set +x
+      run: source scripts/install.sh
 
     - name: saving artifacts
       uses: actions/upload-artifact@v2
@@ -133,7 +100,7 @@ jobs:
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy
+      NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
@@ -147,7 +114,7 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: true
+        submodules: false
         fetch-depth: 0
 
     - name: Update submodules
@@ -162,7 +129,6 @@ jobs:
 
     - name: Setup Environment variables
       run: |
-        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index a680401a..7ad52cda 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -34,7 +34,7 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       PLAT: aarch64
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy
+      NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
@@ -53,7 +53,7 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: true
+        submodules: false
         fetch-depth: 0
 
     - name: Setup Environment variables
@@ -62,50 +62,11 @@ jobs:
         echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
         echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
 
-    - name: before install
-      run: |
-        set -e
-        if [[ $SDIST == 0 ]]; then
-          # Check out and prepare the source
-          # Multibuild doesn't have releases, so --depth would break eventually (see
-          # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-          git submodule update --init multibuild
-          source multibuild/common_utils.sh
-          # https://github.com/matthew-brett/multibuild/issues/116
-          if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-          source multibuild/travis_steps.sh
-          # This sets -x
-          # source travis_multibuild_customize.sh
-          echo $ENABLE_CONTRIB > contrib.enabled
-          echo $ENABLE_HEADLESS > headless.enabled
-          echo "end"
-          # Not interested in travis internal scripts' output
-        fi
-        set +x
-        # Build and package
-        set -x
-        ls
-        if [[ $SDIST == 1 ]]; then
-          python -m pip install --upgrade pip
-          python -m pip install scikit-build
-          python setup.py sdist
-        else
-          build_wheel $REPO_DIR $PLAT
-        fi
-        set +x
-        # Install and run tests
-        set -x
-        if [[ $SDIST == 1 ]]; then
-          echo "skipping tests because of sdist"
-          rc=0
-        else
-          install_run $PLAT && rc=$? || rc=$?
-        fi
-        set +x
-        #otherwise, Travis logic terminates prematurely
-        #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
-        trap ERR
-        test "$rc" -eq 0
+    - name: build
+      run: source scripts/build.sh
+
+    - name: install and test
+      run: source scripts/install.sh
 
     - name: saving artifacts
       uses: actions/upload-artifact@v2
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index bfce806f..c2dc073f 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -33,7 +33,7 @@ jobs:
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy
+      NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
@@ -47,7 +47,7 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: true
+        submodules: false
         fetch-depth: 0
 
     - name: Update submodules
@@ -88,6 +88,7 @@ jobs:
         echo $ENABLE_HEADLESS > headless.enabled
         set -x
         build_wheel $REPO_DIR $PLAT
+        git submodule update --init --recursive
         install_run $PLAT
         set +x
 
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 03a341e4..c8811083 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -36,7 +36,7 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: true
+        submodules: false
         fetch-depth: 0
 
     - name: Update submodules
@@ -62,6 +62,7 @@ jobs:
 
     - name: before test
       run: |
+        git submodule update --init --recursive
         cd ${{ github.workspace }}/tests
         &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
         if ($LastExitCode -ne 0) {throw $LastExitCode}
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 00000000..f48ca066
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+# Check out and prepare the source
+# Multibuild doesn't have releases, so --depth would break eventually (see
+# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+git submodule update --init multibuild
+source multibuild/common_utils.sh
+# https://github.com/matthew-brett/multibuild/issues/116
+if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+source multibuild/travis_steps.sh
+# This sets -x
+# source travis_multibuild_customize.sh
+echo $ENABLE_CONTRIB > contrib.enabled
+echo $ENABLE_HEADLESS > headless.enabled
+set -x
+build_wheel $REPO_DIR $PLAT
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 00000000..6e019d1c
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+# Check out and prepare the source
+# Multibuild doesn't have releases, so --depth would break eventually (see
+# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
+git submodule update --init --recursive
+source multibuild/common_utils.sh
+# https://github.com/matthew-brett/multibuild/issues/116
+if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
+source multibuild/travis_steps.sh
+# This sets -x
+# source travis_multibuild_customize.sh
+echo $ENABLE_CONTRIB > contrib.enabled
+echo $ENABLE_HEADLESS > headless.enabled
+set -x
+install_run $PLAT
+set +x

From 4fe9a58b2e7f317838c3a21cf1a1f065bdc72695 Mon Sep 17 00:00:00 2001
From: William Jackson <william@subtlecoolness.com>
Date: Wed, 9 Jun 2021 09:49:38 -0500
Subject: [PATCH 283/345] Include software distributions when uploading to PyPI

---
 .github/workflows/build_wheels_linux.yml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index c9307d74..8ff86b1b 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -170,7 +170,7 @@ jobs:
       - name: Upload all wheels
         run: |
           python -m pip install twine
-          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_* wheelhouse/opencv-*
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
@@ -189,19 +189,19 @@ jobs:
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
-          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* wheelhouse/opencv-python-[^h]*
 
       - name: Upload wheels for opencv_contrib_python
         run: |
           python -m pip install twine
-          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* wheelhouse/opencv-contrib-python-[^h]*
 
       - name: Upload wheels for opencv_python_headless
         run: |
           python -m pip install twine
-          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* wheelhouse/opencv-python-headless-*
 
       - name: Upload wheels for opencv_contrib_python_headless
         run: |
           python -m pip install twine
-          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-* wheelhouse/opencv-contrib-python-headless-*

From 9136e869fae07f086aa1dfaa202051e26b3ef1a0 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 30 Jun 2021 18:17:33 +0300
Subject: [PATCH 284/345] Added MacOS with M1 build

---
 .github/workflows/build_wheels_linux.yml     |   4 +
 .github/workflows/build_wheels_linux_arm.yml |   4 +
 .github/workflows/build_wheels_macos.yml     |   4 +
 .github/workflows/build_wheels_macos_m1.yml  | 117 +++++++++++++++++++
 .github/workflows/build_wheels_windows.yml   |   3 +
 pyproject.toml                               |  10 +-
 setup.py                                     |   4 +-
 7 files changed, 139 insertions(+), 7 deletions(-)
 create mode 100644 .github/workflows/build_wheels_macos_m1.yml

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index c9307d74..af8f1a06 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -4,6 +4,10 @@ on:
   pull_request:
     branches:
       - master
+    paths-ignore:
+      - '.github/workflows/build_wheels_linux_arm.yml'
+      - '.github/workflows/build_wheels_windows*'
+      - '.github/workflows/build_wheels_macos*'
   release:
     types: [published, edited]
 
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index 7ad52cda..d71db231 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -4,6 +4,10 @@ on:
   pull_request:
     branches:
       - master
+    paths-ignore:
+      - '.github/workflows/build_wheels_linux.yml'
+      - '.github/workflows/build_wheels_windows*'
+      - '.github/workflows/build_wheels_macos*'
   release:
     types: [published, edited]
 
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index c2dc073f..5b2b8066 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -4,6 +4,10 @@ on:
   pull_request:
     branches:
       - master
+    paths-ignore:
+      - '.github/workflows/build_wheels_linux*'
+      - '.github/workflows/build_wheels_windows*'
+      - '.github/workflows/build_wheels_macos_m1.yml'
   release:
     types: [published, edited]
 
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
new file mode 100644
index 00000000..d3018497
--- /dev/null
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -0,0 +1,117 @@
+name: Build PYPI wheels for opencv-python on Macos M1
+
+on:
+  pull_request:
+    branches:
+      - master
+    paths-ignore:
+      - '.github/workflows/build_wheels_linux*'
+      - '.github/workflows/build_wheels_windows*'
+      - '.github/workflows/build_wheels_macos.yml'
+  release:
+    types: [published, edited]
+
+
+jobs:
+  build:
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macOS-M1]
+        python-version: [3.7, 3.8, 3.9]
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      SDIST: ${{ matrix.build_sdist || 0 }}
+      ENABLE_HEADLESS: ${{ matrix.without_gui }}
+      ENABLE_CONTRIB: ${{ matrix.with_contrib }}
+      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: false
+        fetch-depth: 0
+
+    - name: Update submodules
+      if: github.event_name == 'pull_request'
+      run: git submodule update --remote
+
+    - name: build script
+      run: |
+        git submodule update --init multibuild
+        echo $ENABLE_CONTRIB > contrib.enabled
+        echo $ENABLE_HEADLESS > headless.enabled
+        export MACOSX_DEPLOYMENT_TARGET=11.0
+        arch -arm64 python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
+    - name: before test
+      run: |
+        git submodule update --init --recursive
+        arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl
+        cd ${{ github.workspace }}/tests
+        arch -arm64 python${{ matrix.python-version }} get_build_info.py
+    - name: run test
+      run: |
+        cd ${{ github.workspace }}/opencv
+        arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
+    - name: saving artifacts
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+  test_release_opencv_python:
+    if: github.event_name == 'release' && github.event.release.prerelease
+    needs: [build]
+    runs-on: ubuntu-latest
+    environment: test-opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload all wheels
+        run: |
+          python -m pip install twine
+          python -m twine upload --repository testpypi -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --skip-existing wheelhouse/opencv_*
+
+  release_opencv_python:
+    if: github.event_name == 'release' && !github.event.release.prerelease
+    needs: [build]
+    runs-on: ubuntu-latest
+    environment: opencv-python-release
+    defaults:
+      run:
+        shell: bash
+    steps:
+      - uses: actions/download-artifact@v2
+        with:
+          name: wheels
+          path: wheelhouse/
+
+      - name: Upload wheels for opencv_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
+      - name: Upload wheels for opencv_contrib_python
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
+      - name: Upload wheels for opencv_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
+      - name: Upload wheels for opencv_contrib_python_headless
+        run: |
+          python -m pip install twine
+          python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python_headless-*
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index c8811083..554f684c 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -4,6 +4,9 @@ on:
   pull_request:
     branches:
       - master
+    paths-ignore:
+      - '.github/workflows/build_wheels_linux*'
+      - '.github/workflows/build_wheels_macos*'
   release:
     types: [published, edited]
 
diff --git a/pyproject.toml b/pyproject.toml
index 07bcc4bb..5a2849f3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,10 +1,10 @@
 [build-system]
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
-  "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64'",
+  "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.19.3; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
-  "numpy==1.20.1; python_version>='3.6' and sys_platform == 'darwin' 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'"
+  "numpy==1.21.0; python_version>='3.6' and sys_platform == 'darwin' and platform_machine == 'arm64'",
+  "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
+  "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
+  "numpy==1.19.3; python_version>='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'"
 ]
diff --git a/setup.py b/setup.py
index a14825da..612a080c 100644
--- a/setup.py
+++ b/setup.py
@@ -36,8 +36,8 @@ def main():
         minimum_supported_numpy = "1.19.3"
 
     # macos arm64 is a special case
-    if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.20.1"
+    if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":
+        minimum_supported_numpy = "1.21.0"
 
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 

From 2ff0d0e3a4b2152214f4f1fd8d0ee0f40497e6c7 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 7 Jul 2021 15:12:11 +0300
Subject: [PATCH 285/345] Updated submodules to 4.5.3 release

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 opencv_extra   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opencv b/opencv
index 69357b1e..ad6e8294 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 69357b1e88680658a07cffde7678a4d697469f03
+Subproject commit ad6e82942b37be8ee2c71c1d9bc7fe79cd16f7ab
diff --git a/opencv_contrib b/opencv_contrib
index f5d7f671..d5317d62 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit f5d7f6712d4ff229ba4f45cf79dfd11c557d56fd
+Subproject commit d5317d6297a8129b66dba1a1f7cc784e94639da9
diff --git a/opencv_extra b/opencv_extra
index 3b033d09..d5c7212d 160000
--- a/opencv_extra
+++ b/opencv_extra
@@ -1 +1 @@
-Subproject commit 3b033d09cab1894d6452707df723789fe98c8663
+Subproject commit d5c7212d53f097c9fdf5e72c598ad051660599e8

From eb0efe2fa05e4ef1e596bad2509e870fc2c5377f Mon Sep 17 00:00:00 2001
From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
Date: Fri, 16 Jul 2021 15:58:54 +0300
Subject: [PATCH 286/345] Readme update after migration to Github Actions for
 CI.

---
 README.md | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 9629aae0..38789a8b 100644
--- a/README.md
+++ b/README.md
@@ -79,15 +79,16 @@ 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/com/skvark/opencv-python/master?label=Linux%20%26%20macOS)](https://travis-ci.com/github/skvark/opencv-python/)
+[![Windows Buld Status](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml)
+[![(Linux Build status)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_linux.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_linux.yml)
+[![(Mac OS Build status)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_macos.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_macos.yml)
 
 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.
 
 ### CI build process
 
 The project is structured like a normal Python package with a standard ``setup.py`` file.
-The build process for a single entry in the build matrices is as follows (see for example ``appveyor.yml`` file):
+The build process for a single entry in the build matrices is as follows (see for example `.github/workflows/build_wheels_linux.yml` file):
 
 0. In Linux and MacOS build: get OpenCV's optional C dependencies that we compile against
 
@@ -181,7 +182,7 @@ Third party package licenses are at [LICENSE-3RD-PARTY.txt](https://github.com/o
 
 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 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).
+Non-headless Linux 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/opencv/opencv-python/blob/master/LICENSE-3RD-PARTY.txt).
 

From ecd163ddef981f28278e7a1cd4a9056da204dd19 Mon Sep 17 00:00:00 2001
From: Aaron Gokaslan <aaronGokaslan@gmail.com>
Date: Fri, 17 Sep 2021 13:04:41 -0400
Subject: [PATCH 287/345] fix typo in Readme

Fixes a typo in Readme
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 38789a8b..bb43bb99 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ A: Make sure you have removed old manual installations of OpenCV Python bindings
 
 **Q: Function foo() or method bar() returns wrong result, throws exception or crashes interpriter. What should I do?**
 
-A: The repository contains only OpenCV-Python package build scripts, but not OpenCV itself. Python bindings for OpenCV are developed in official OpenCV repository and it's the best place to report issues. Also please check {OpenCV wiki](https://github.com/opencv/opencv/wiki) and [the fficial OpenCV forum](https://forum.opencv.org/) before file new bugs.
+A: The repository contains only OpenCV-Python package build scripts, but not OpenCV itself. Python bindings for OpenCV are developed in official OpenCV repository and it's the best place to report issues. Also please check {OpenCV wiki](https://github.com/opencv/opencv/wiki) and [the official OpenCV forum](https://forum.opencv.org/) before file new bugs.
 
 **Q: Why the packages do not include non-free algorithms?**
 

From 5fedf828ee2b985351747c8f6485475e033074b9 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <76472231+asenyaev@users.noreply.github.com>
Date: Tue, 21 Sep 2021 12:19:00 +0300
Subject: [PATCH 288/345] Added the lapack installation

---
 travis_config.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/travis_config.sh b/travis_config.sh
index a83fe141..7026a021 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -26,6 +26,13 @@ function bdist_wheel_cmd {
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 
+if [ -n "$IS_OSX" ]; then
+  brew install lapack
+else
+  yum install -y atlas-devel blas-devel lapack-devel
+  cp /usr/include/lapacke/lapacke*.h /usr/include/
+fi
+
 if [ -n "$IS_OSX" ]; then
   echo "    > OSX environment "
   export MAKEFLAGS="-j$(sysctl -n hw.ncpu)"

From 3c1ea4402db35fa51c6804db7424bd30d561a51c Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 1 Oct 2021 11:35:33 +0300
Subject: [PATCH 289/345] Changed blas to openblas and fixed flow to a proper
 installation

---
 scripts/build.sh |  1 +
 travis_config.sh | 15 ++++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/scripts/build.sh b/scripts/build.sh
index f48ca066..aa9ff968 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -15,3 +15,4 @@ echo $ENABLE_CONTRIB > contrib.enabled
 echo $ENABLE_HEADLESS > headless.enabled
 set -x
 build_wheel $REPO_DIR $PLAT
+rm wheelhouse/numpy*
diff --git a/travis_config.sh b/travis_config.sh
index 7026a021..28fbb96f 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -26,13 +26,6 @@ function bdist_wheel_cmd {
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
 }
 
-if [ -n "$IS_OSX" ]; then
-  brew install lapack
-else
-  yum install -y atlas-devel blas-devel lapack-devel
-  cp /usr/include/lapacke/lapacke*.h /usr/include/
-fi
-
 if [ -n "$IS_OSX" ]; then
   echo "    > OSX environment "
   export MAKEFLAGS="-j$(sysctl -n hw.ncpu)"
@@ -99,6 +92,14 @@ function pre_build {
   echo "Starting pre-build"
   set -e -o pipefail
 
+  if [ -n "$IS_OSX" ]; then
+    brew install lapack
+  else
+    yum install -y lapack-devel openblas-devel
+    cp /usr/include/lapacke/lapacke*.h /usr/include/
+    curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h
+  fi
+
   if [ -n "$IS_OSX" ]; then
     echo "Running for OSX"
 

From 40e0e3b8c235386c003f8ea5d0a9d9ea968a06cd Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 1 Oct 2021 13:51:43 +0300
Subject: [PATCH 290/345] Fixed aarch64 openblas installation

---
 travis_config.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/travis_config.sh b/travis_config.sh
index 28fbb96f..a387966c 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -95,7 +95,8 @@ function pre_build {
   if [ -n "$IS_OSX" ]; then
     brew install lapack
   else
-    yum install -y lapack-devel openblas-devel
+    # epel-release need for aarch64 to get openblas packages
+    yum install -y lapack-devel epel-release && yum install -y openblas-devel
     cp /usr/include/lapacke/lapacke*.h /usr/include/
     curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h
   fi

From 1d6e03459e32a5effd27b7b86186b418f2bde437 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 1 Oct 2021 19:11:37 +0300
Subject: [PATCH 291/345] Fixed an issue when machine:X86 was defined on
 Windows x64

---
 setup.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/setup.py b/setup.py
index 612a080c..22b6561d 100644
--- a/setup.py
+++ b/setup.py
@@ -151,6 +151,12 @@ def main():
             "-DBUILD_PERF_TESTS=OFF",
             "-DBUILD_DOCS=OFF",
         ]
+        + (
+            # If it is not defined 'linker flags: /machine:X86' on Windows x64
+            ["-DCMAKE_GENERATOR_PLATFORM=x64"]
+            if x64 and sys.platform == "win32"
+            else []
+          )
         + (
             ["-DOPENCV_EXTRA_MODULES_PATH=" + os.path.abspath("opencv_contrib/modules")]
             if build_contrib

From 76a6fb2476b0f4610d6b8a827d3201cacab7daae Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 6 Oct 2021 19:52:12 +0300
Subject: [PATCH 292/345] Added fix for MacOS with M1

---
 .github/workflows/build_wheels_macos_m1.yml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index d3018497..fb4b7d1b 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -49,17 +49,21 @@ jobs:
         echo $ENABLE_CONTRIB > contrib.enabled
         echo $ENABLE_HEADLESS > headless.enabled
         export MACOSX_DEPLOYMENT_TARGET=11.0
-        arch -arm64 python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
+        arch -arm64 -e SDIST=${{ matrix.build_sdist }} -e ENABLE_HEADLESS=${{ matrix.without_gui }} -e ENABLE_CONTRIB=${{ matrix.with_contrib }} python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
+        delocate-wheel ${{ github.workspace }}/wheelhouse/opencv*
+
     - name: before test
       run: |
         git submodule update --init --recursive
         arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl
         cd ${{ github.workspace }}/tests
         arch -arm64 python${{ matrix.python-version }} get_build_info.py
+
     - name: run test
       run: |
         cd ${{ github.workspace }}/opencv
         arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
+
     - name: saving artifacts
       uses: actions/upload-artifact@v2
       with:

From 3f010892e3c7b947c6afba6af3b05c2cfca3515b Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 6 Oct 2021 22:45:47 +0300
Subject: [PATCH 293/345] Removed env variables and defined CI_BUILD variable
 globally

---
 .github/workflows/build_wheels_macos_m1.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index fb4b7d1b..2c855874 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -27,6 +27,7 @@ jobs:
         build_sdist: [0]
 
     env:
+      CI_BUILD: 1
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
@@ -49,7 +50,7 @@ jobs:
         echo $ENABLE_CONTRIB > contrib.enabled
         echo $ENABLE_HEADLESS > headless.enabled
         export MACOSX_DEPLOYMENT_TARGET=11.0
-        arch -arm64 -e SDIST=${{ matrix.build_sdist }} -e ENABLE_HEADLESS=${{ matrix.without_gui }} -e ENABLE_CONTRIB=${{ matrix.with_contrib }} python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
+        arch -arm64 python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
         delocate-wheel ${{ github.workspace }}/wheelhouse/opencv*
 
     - name: before test

From d82a270ecfda961d1a9a12e525aac773b4dda234 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 8 Oct 2021 00:08:49 +0300
Subject: [PATCH 294/345] Updated Github Actions to python 3.10 and fixed
 following issues

---
 .github/workflows/build_wheels_linux.yml     | 12 ++++----
 .github/workflows/build_wheels_linux_arm.yml |  8 +++---
 .github/workflows/build_wheels_macos.yml     | 30 +++++++++++---------
 .github/workflows/build_wheels_macos_m1.yml  |  2 +-
 .github/workflows/build_wheels_windows.yml   |  2 +-
 docker/manylinux2014/Dockerfile_aarch64      | 10 +++----
 docker/manylinux2014/Dockerfile_i686         | 10 +++----
 docker/manylinux2014/Dockerfile_x86_64       | 10 +++----
 multibuild                                   |  2 +-
 pyproject.toml                               |  7 +++--
 scripts/build.sh                             |  1 -
 setup.py                                     |  8 ++++--
 travis_config.sh                             |  5 +++-
 travis_multibuild_customize.sh               |  2 +-
 14 files changed, 58 insertions(+), 51 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 526049ff..5c562d44 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest]
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -38,9 +38,10 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_3_10: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
@@ -63,8 +64,7 @@ jobs:
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
-        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
-        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: build
       run: source scripts/build.sh
@@ -107,7 +107,7 @@ jobs:
       NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
@@ -135,8 +135,6 @@ jobs:
       run: |
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
-        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
-        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
 
     - name: before install
       run: |
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index d71db231..310b3ee5 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ARM64]
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -39,9 +39,10 @@ jobs:
       PLAT: aarch64
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_3_10: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
@@ -63,8 +64,7 @@ jobs:
     - name: Setup Environment variables
       run: |
         if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
-        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
-        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: build
       run: source scripts/build.sh
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index 5b2b8066..aca84ae6 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -22,12 +22,23 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [macos-latest]
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        os: [macos-10.15, macos-11]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
+        exclude:
+          - os: macos-10.15
+            python-version: '3.10'
+          - os: macos-11
+            python-version: '3.6'
+          - os: macos-11
+            python-version: '3.7'
+          - os: macos-11
+            python-version: '3.8'
+          - os: macos-11
+            python-version: '3.9'
 
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
@@ -38,9 +49,11 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_3_10: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
+      TRAVIS_OS_NAME: osx
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/skvark/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
@@ -58,22 +71,13 @@ jobs:
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
 
-    - name: Set up Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v2
-      if: ${{ 'macos-latest' == matrix.os }}
-      with:
-        python-version: ${{ matrix.python-version }}
-        architecture: ${{ matrix.platform }}
-
     - name: Setup Environment variables
       run: |
-        if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
         if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
-        echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
-        echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: before install
       run: |
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 2c855874..79164dcf 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -20,7 +20,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [macOS-M1]
-        python-version: [3.7, 3.8, 3.9]
+        python-version: ['3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 554f684c..3eb13086 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -22,7 +22,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [windows-latest]
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x86, x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index e8920770..c76ccec4 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -28,8 +28,8 @@ RUN mkdir ~/ffmpeg_sources && \
     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 && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
+    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -50,9 +50,9 @@ RUN cd ~/ffmpeg_sources && \
     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 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
+    tar -xf ffmpeg-4.3.2.tar.bz2 && \
+    cd ffmpeg-4.3.2 && \
     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) && \
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 39fc1560..6a60a073 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -30,8 +30,8 @@ RUN mkdir ~/ffmpeg_sources && \
     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 && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
+    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
     linux32 ./configure && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -52,9 +52,9 @@ RUN cd ~/ffmpeg_sources && \
     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 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
+    tar -xf ffmpeg-4.3.2.tar.bz2 && \
+    cd ffmpeg-4.3.2 && \
     PATH=~/bin:$PATH && \
     PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" linux32 ./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) && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 010120ca..49622378 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -28,8 +28,8 @@ RUN mkdir ~/ffmpeg_sources && \
     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 && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
+    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -50,9 +50,9 @@ RUN cd ~/ffmpeg_sources && \
     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 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
+    tar -xf ffmpeg-4.3.2.tar.bz2 && \
+    cd ffmpeg-4.3.2 && \
     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) && \
diff --git a/multibuild b/multibuild
index 8882150d..b89bb903 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit 8882150df6529658700b66bec124dfb77eefca26
+Subproject commit b89bb903e94308be79abefa4f436bf123ebb1313
diff --git a/pyproject.toml b/pyproject.toml
index 5a2849f3..ec63b351 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,9 +2,10 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.19.3; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
-  "numpy==1.21.0; python_version>='3.6' and sys_platform == 'darwin' and platform_machine == 'arm64'",
+  "numpy==1.21.2; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
+  "numpy==1.21.2; python_version>='3.6' and sys_platform == 'darwin' and platform_machine == 'arm64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.19.3; python_version>='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'"
+  "numpy==1.21.2; python_version>='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
+  "numpy==1.21.2; python_version>='3.10' and platform_machine != 'aarch64' and platform_machine != 'arm64'"
 ]
diff --git a/scripts/build.sh b/scripts/build.sh
index aa9ff968..f48ca066 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -15,4 +15,3 @@ echo $ENABLE_CONTRIB > contrib.enabled
 echo $ENABLE_HEADLESS > headless.enabled
 set -x
 build_wheel $REPO_DIR $PLAT
-rm wheelhouse/numpy*
diff --git a/setup.py b/setup.py
index 22b6561d..f4e0a100 100644
--- a/setup.py
+++ b/setup.py
@@ -29,15 +29,17 @@ def main():
     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"
+        minimum_supported_numpy = "1.21.2"
+    if sys.version_info[:2] >= (3, 10):
+        minimum_supported_numpy = "1.21.2"
 
     # linux arm64 is a special case
     if sys.platform.startswith("linux") and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.19.3"
+        minimum_supported_numpy = "1.21.2"
 
     # macos arm64 is a special case
     if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":
-        minimum_supported_numpy = "1.21.0"
+        minimum_supported_numpy = "1.21.2"
 
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 
diff --git a/travis_config.sh b/travis_config.sh
index a387966c..937e5a2d 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -20,7 +20,10 @@ function bdist_wheel_cmd {
       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
+      python$PYTHON_VERSION -m pip install auditwheel==3.2.0
+      python$PYTHON_VERSION patch_auditwheel_whitelist.py
+      # to avoid issues with numpy wheels
+      rm /io/wheelhouse/numpy*
       deactivate
     fi
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
diff --git a/travis_multibuild_customize.sh b/travis_multibuild_customize.sh
index 5a9451be..178fd6ec 100644
--- a/travis_multibuild_customize.sh
+++ b/travis_multibuild_customize.sh
@@ -3,4 +3,4 @@
 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
 set -x
 REPO_DIR=$(dirname "${BASH_SOURCE[0]}")
-DOCKER_IMAGE='quay.io/skvark/manylinux2014_$plat'
+DOCKER_IMAGE='quay.io/asenyaev/manylinux2014_$plat'

From 0114953aaeafb56ef3b9584555bb1119583468f0 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 8 Oct 2021 12:19:31 +0300
Subject: [PATCH 295/345] Fixed the version of numpy for linux aarch64 and
 python3.6

---
 pyproject.toml | 3 ++-
 setup.py       | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index ec63b351..7e887c41 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,8 +2,9 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.21.2; python_version>='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
+  "numpy==1.19.3; python_version=='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
   "numpy==1.21.2; python_version>='3.6' and sys_platform == 'darwin' and platform_machine == 'arm64'",
+  "numpy==1.21.2; python_version>='3.7' and sys_platform == 'linux' and platform_machine == 'aarch64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.21.2; python_version>='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
diff --git a/setup.py b/setup.py
index f4e0a100..7c3f610c 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,7 @@ def main():
 
     # linux arm64 is a special case
     if sys.platform.startswith("linux") and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.21.2"
+        minimum_supported_numpy = "1.19.3"
 
     # macos arm64 is a special case
     if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":

From 9f43c0b2fd3c7ee745d11982ebabf65ad41f013a Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Fri, 8 Oct 2021 17:38:57 +0300
Subject: [PATCH 296/345] Changed the image for tests on linux arm

---
 .github/workflows/build_wheels_linux_arm.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index 310b3ee5..c2982e50 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -43,7 +43,7 @@ jobs:
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
-      DOCKER_TEST_IMAGE: multibuild/xenial_arm64v8
+      DOCKER_TEST_IMAGE: multibuild/focal_arm64v8
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}

From 4d0f6d2e17a8ded22cfe500be19617370f038a92 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Sat, 9 Oct 2021 12:31:06 +0300
Subject: [PATCH 297/345] Fixed if condition for numpy test version on linux
 arm and renamed numpy variable

---
 .github/workflows/build_wheels_linux.yml     | 4 ++--
 .github/workflows/build_wheels_linux_arm.yml | 4 ++--
 .github/workflows/build_wheels_macos.yml     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 5c562d44..7ff34a18 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -38,7 +38,7 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_3_10: numpy==1.21.2
+      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
@@ -64,7 +64,7 @@ jobs:
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: build
       run: source scripts/build.sh
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index c2982e50..8108c85f 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -39,7 +39,7 @@ jobs:
       PLAT: aarch64
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_3_10: numpy==1.21.2
+      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
@@ -64,7 +64,7 @@ jobs:
     - name: Setup Environment variables
       run: |
         if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+        if [ "3.6" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; fi
 
     - name: build
       run: source scripts/build.sh
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index aca84ae6..d4f10be0 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -49,7 +49,7 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
       NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_3_10: numpy==1.21.2
+      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       TRAVIS_OS_NAME: osx
       CONFIG_PATH: travis_config.sh
@@ -77,7 +77,7 @@ jobs:
         if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
         if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
         if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_3_10)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: before install
       run: |

From fdcbcb11ade547f1dde9116ddb5af925616be32c Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Sun, 10 Oct 2021 01:36:19 +0300
Subject: [PATCH 298/345] Added lowest numpy version support instead of latest

---
 .github/workflows/build_wheels_linux_arm.yml | 2 +-
 pyproject.toml                               | 9 ++++-----
 setup.py                                     | 4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index 8108c85f..89142a57 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -64,7 +64,7 @@ jobs:
     - name: Setup Environment variables
       run: |
         if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
-        if [ "3.6" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; fi
+        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
     - name: build
       run: source scripts/build.sh
diff --git a/pyproject.toml b/pyproject.toml
index 7e887c41..6aaab1d3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,11 +2,10 @@
 requires = [
   "setuptools", "wheel", "scikit-build", "cmake", "pip",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.19.3; python_version=='3.6' and sys_platform == 'linux' and platform_machine == 'aarch64'",
-  "numpy==1.21.2; python_version>='3.6' and sys_platform == 'darwin' and platform_machine == 'arm64'",
-  "numpy==1.21.2; python_version>='3.7' and sys_platform == 'linux' and platform_machine == 'aarch64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.21.2; python_version>='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
-  "numpy==1.21.2; python_version>='3.10' and platform_machine != 'aarch64' and platform_machine != 'arm64'"
+  "numpy==1.19.3; python_version<='3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
+  "numpy==1.21.0; python_version<='3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'",
+  "numpy==1.19.3; python_version=='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
+  "numpy==1.21.2; python_version>='3.10'"
 ]
diff --git a/setup.py b/setup.py
index 7c3f610c..b5ba5bf0 100644
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@ def main():
     if sys.version_info[:2] >= (3, 8):
         minimum_supported_numpy = "1.17.3"
     if sys.version_info[:2] >= (3, 9):
-        minimum_supported_numpy = "1.21.2"
+        minimum_supported_numpy = "1.19.3"
     if sys.version_info[:2] >= (3, 10):
         minimum_supported_numpy = "1.21.2"
 
@@ -39,7 +39,7 @@ def main():
 
     # macos arm64 is a special case
     if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":
-        minimum_supported_numpy = "1.21.2"
+        minimum_supported_numpy = "1.21.0"
 
     numpy_version = "numpy>=%s" % minimum_supported_numpy
 

From 51226a7f2e32805f7728793b7ae2704d41b6ab9d Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Mon, 11 Oct 2021 07:36:20 +0200
Subject: [PATCH 299/345] Travis CI seems to be on vacation

https://travis-ci.org/github/opencv
---
 .travis.yml | 410 ----------------------------------------------------
 1 file changed, 410 deletions(-)
 delete mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 6ba06d4c..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,410 +0,0 @@
-env:
-    global:
-        - "PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'"
-        # pip dependencies to _test_ your project
-        - TEST_DEPENDS="numpy==1.11.1"
-        # params to bdist_wheel. used to set osx build target.
-        - CONFIG_PATH="travis_config.sh"
-        - USE_CCACHE=1
-        - UNICODE_WIDTH=32
-        - SDIST=0
-
-# Save some time, we and setup check them out on demand instead
-# https://docs.travis-ci.com/user/customizing-the-build/#Git-Clone-Depth
-git:
-    submodules: false
-
-# https://docs.travis-ci.com/user/caching
-cache:
-  directories:
-    # `cache: ccache: true` has no effect if `language:` is not `c` or `cpp`
-    - $HOME/.ccache
-
-# Add more cache stages (s2 etc) and corresponding OSX jobs like s1
-# if brew builds start to take longer than one Travis time limit
-stages:
-  - final
-
-jobs:
-  fast_finish: true
-  # Travis exclude is buggy, this seems to be the only way to disable default build
-  exclude:
-    - language: ruby
-  include:
-    # default builds for Linux
-    - 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.19.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=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
-    - 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=0
-        - TEST_DEPENDS=numpy==1.19.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=0
-        - ENABLE_HEADLESS=0
-        - TEST_DEPENDS=numpy==1.19.0
-        - 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.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
-    - 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
-      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
-      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
-      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=0
-        - TEST_DEPENDS=numpy==1.19.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=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
-      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=0
-        - TEST_DEPENDS=numpy==1.19.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
-      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
-      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
-      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
-      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: |
-    set -e
-
-    if [[ $SDIST == 0 ]]; then
-      # Check out and prepare the source
-      # Multibuild doesn't have releases, so --depth would break eventually (see
-      # https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
-      git submodule update --init multibuild
-
-      source multibuild/common_utils.sh
-
-      # https://github.com/matthew-brett/multibuild/issues/116
-      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
-
-      source multibuild/travis_steps.sh
-      # This sets -x
-
-      source travis_multibuild_customize.sh
-      echo $ENABLE_CONTRIB > contrib.enabled
-      echo $ENABLE_HEADLESS > headless.enabled
-
-      echo "end"
-      # Not interested in travis internal scripts' output
-    fi
-
-    set +x
-
-install: |
-    # Build and package
-    set -x
-
-    if [[ $SDIST == 1 ]]; then
-      python -m pip install --upgrade pip
-      python -m pip install scikit-build
-      python setup.py sdist
-    else
-      build_wheel $REPO_DIR $PLAT
-    fi
-
-    set +x
-
-script: |
-    # Install and run tests
-    set -x
-    if [[ $SDIST == 1 ]]; then
-      echo "skipping tests because of sdist"
-    else
-      install_run $PLAT && rc=$? || rc=$?
-    fi
-
-    set +x
-
-    #otherwise, Travis logic terminates prematurely
-    #https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
-    trap ERR
-    test "$rc" -eq 0
-
-after_success: |
-    # Upload wheels to pypi if tag is set
-
-    set -x
-
-    if [ -n "$TRAVIS_TAG" ]; then
-
-      if [[ $ENABLE_CONTRIB == 0 ]]; then
-        if [[ $ENABLE_HEADLESS == 0 ]]; then
-          echo "This is default build. Deployment will be done to to PyPI entry opencv-python."
-        else
-          echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-python-headless."
-        fi
-      else
-        if [[ $ENABLE_HEADLESS == 0 ]]; then
-          echo "This is contrib build. Deployment will be done to to PyPI entry opencv-contrib-python."
-        else
-          echo "This is headless contrib build. Deployment will be done to to PyPI entry opencv-contrib-python-headless."
-        fi
-      fi
-
-      if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-        if [[ $SDIST == 1 ]]; then
-          pip install twine
-          twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
-        else
-          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
-
-      if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-        # macpython 3.5 doesn't support recent TLS protocols which causes twine
-        # upload to fail, so we use the system Python to run twine
-        /usr/bin/python -m ensurepip --user
-        /usr/bin/python -m pip install --user -U pip
-        /usr/bin/python -m pip install --user -U -I twine
-
-        if [[ $SDIST == 1 ]]; then
-          /usr/bin/python -m twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/dist/opencv*
-        else
-          /usr/bin/python -m twine upload -u ${PYPI_USER} -p ${PASS} --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/opencv*
-        fi
-
-      fi
-
-    fi
-
-    # # Save to Azure storage always
-
-    # if [[ $TRAVIS_CPU_ARCH != "arm64" ]]; then
-    #   if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
-    #     curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
-    #   else
-    #     brew install azure-cli
-    #   fi
-
-    #   az storage container create -n ${TRAVIS_COMMIT} --public-access blob
-
-    #   if [[ $SDIST == 1 ]]; then
-    #     az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/dist --pattern *.gz
-    #   else
-    #     az storage blob upload-batch -d ${TRAVIS_COMMIT} -s ${TRAVIS_BUILD_DIR}/wheelhouse --pattern opencv*.whl
-    #   fi
-    # fi
-
-    set +x
-

From 5c81cdaff33ac21022650cebf0b12bb974d555ca Mon Sep 17 00:00:00 2001
From: "Andrei V. Konstantinov" <andrue.konst@gmail.com>
Date: Wed, 13 Oct 2021 16:45:45 +0300
Subject: [PATCH 300/345] Fix typo in Readme

Fixes a typo in Readme
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index bb43bb99..d2831332 100644
--- a/README.md
+++ b/README.md
@@ -65,7 +65,7 @@ If you still encounter the error after you have checked all the previous solutio
 
 A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
 
-**Q: Function foo() or method bar() returns wrong result, throws exception or crashes interpriter. What should I do?**
+**Q: Function foo() or method bar() returns wrong result, throws exception or crashes interpreter. What should I do?**
 
 A: The repository contains only OpenCV-Python package build scripts, but not OpenCV itself. Python bindings for OpenCV are developed in official OpenCV repository and it's the best place to report issues. Also please check {OpenCV wiki](https://github.com/opencv/opencv/wiki) and [the official OpenCV forum](https://forum.opencv.org/) before file new bugs.
 

From 6a1f61b8d7e413059dbf0b9e897579c8305c327f Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 15 Oct 2021 19:35:51 +0300
Subject: [PATCH 301/345] Updated submodules to the release 4.5.4, added python
 loader support, updated Qt patch

---
 cv2/__init__.py        | 31 -------------------------------
 opencv                 |  2 +-
 opencv_contrib         |  2 +-
 opencv_extra           |  2 +-
 patches/patchQtPlugins | 19 +++++++++++++------
 scripts/__init__.py    | 23 +++++++++++++++++++++++
 setup.py               | 42 ++++++++++++++++++++++++++++++++++++++----
 7 files changed, 77 insertions(+), 44 deletions(-)
 create mode 100644 scripts/__init__.py

diff --git a/cv2/__init__.py b/cv2/__init__.py
index 0c080d52..e69de29b 100644
--- a/cv2/__init__.py
+++ b/cv2/__init__.py
@@ -1,31 +0,0 @@
-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.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/opencv b/opencv
index ad6e8294..39c33341 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit ad6e82942b37be8ee2c71c1d9bc7fe79cd16f7ab
+Subproject commit 39c3334147ec02761b117f180c9c4518be18d1fa
diff --git a/opencv_contrib b/opencv_contrib
index d5317d62..2bc3e1a1 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit d5317d6297a8129b66dba1a1f7cc784e94639da9
+Subproject commit 2bc3e1a169afd2675ef68221176f32cc0ea5427a
diff --git a/opencv_extra b/opencv_extra
index d5c7212d..822ee112 160000
--- a/opencv_extra
+++ b/opencv_extra
@@ -1 +1 @@
-Subproject commit d5c7212d53f097c9fdf5e72c598ad051660599e8
+Subproject commit 822ee11240b969e98e20546663bc481a5e7089cc
diff --git a/patches/patchQtPlugins b/patches/patchQtPlugins
index 03560f17..a05a5f83 100644
--- a/patches/patchQtPlugins
+++ b/patches/patchQtPlugins
@@ -3,9 +3,8 @@ index 4c0b3880fc..dffa0a4caa 100644
 --- a/opencv/CMakeLists.txt
 +++ b/opencv/CMakeLists.txt
 @@ -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)
+   if(HAVE_QT)
+     status("    QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")
 +    if(APPLE)
 +      install(DIRECTORY ${Qt5_DIR}/../../../plugins DESTINATION lib/qt)
 +    endif()
@@ -13,6 +12,14 @@ index 4c0b3880fc..dffa0a4caa 100644
 +      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)
+     if(HAVE_QT_OPENGL)
+       if(Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES)
+         status("      QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES} ${Qt${QT_VERSION_MAJOR}OpenGL_VERSION_STRING})" ELSE NO)
+       else()
+         status("      QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
+       endif()
+     else()
+       status("      QT OpenGL support:" "NO")
+     endif()
+   else()
+     status("    QT:" "NO")
diff --git a/scripts/__init__.py b/scripts/__init__.py
new file mode 100644
index 00000000..af17e205
--- /dev/null
+++ b/scripts/__init__.py
@@ -0,0 +1,23 @@
+from .cv2 import *
+from .data import *
+
+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.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/setup.py b/setup.py
index b5ba5bf0..dd1659d5 100644
--- a/setup.py
+++ b/setup.py
@@ -108,12 +108,32 @@ def main():
         # 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"))}
+            "python/cv2/python-%s.%s/cv2[^/]*%s"
+            % (sys.version_info[0], sys.version_info[1], re.escape(sysconfig.get_config_var("EXT_SUFFIX")))
+        ]
+        +
+        [
+            r"python/cv2/__init__.py"
+        ]
+        +
+        [
+            r"python/cv2/.*config.*.py"
         ],
         "cv2.data": [  # OPENCV_OTHER_INSTALL_PATH
             ("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml"
         ],
+        "cv2.gapi": [
+            "python/cv2" + r"/gapi/.*\.py"
+        ],
+        "cv2.mat_wrapper": [
+            "python/cv2" + r"/mat_wrapper/.*\.py"
+        ],
+        "cv2.misc": [
+            "python/cv2" + r"/misc/.*\.py"
+        ],
+        "cv2.utils": [
+            "python/cv2" + r"/utils/.*\.py"
+        ],
     }
 
     # Files in sourcetree outside package dir that should be copied to package.
@@ -137,8 +157,6 @@ def main():
             "-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",
@@ -358,6 +376,22 @@ def _classify_installed_files_override(
 
         print("Copying files from CMake output")
 
+        with open('%spython/cv2/__init__.py'
+         % cmake_install_dir, 'r') as opencv_init:
+            opencv_init_data = ""
+            for line in opencv_init:
+                opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
+                opencv_init_data = opencv_init_data + opencv_init_replacement
+        with open('%spython/cv2/__init__.py'
+        % cmake_install_dir, 'w') as opencv_python_init:
+            opencv_python_init.write(opencv_init_data)
+
+        with open('scripts/__init__.py', 'r') as custom_init:
+            custom_init_data = custom_init.read()
+        with open('%spython/cv2/config-%s.%s.py'
+        % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'a') as opencv_init_config:
+            opencv_init_config.write(custom_init_data)
+
         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:

From 545fe24728bfee7e0092d0e37dbdd0371bb1c2d8 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 15 Oct 2021 20:39:09 +0300
Subject: [PATCH 302/345] Added comments for new changes

---
 setup.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/setup.py b/setup.py
index dd1659d5..7766f96d 100644
--- a/setup.py
+++ b/setup.py
@@ -376,6 +376,7 @@ def _classify_installed_files_override(
 
         print("Copying files from CMake output")
 
+        # need for the proper import of a package
         with open('%spython/cv2/__init__.py'
          % cmake_install_dir, 'r') as opencv_init:
             opencv_init_data = ""
@@ -386,6 +387,7 @@ def _classify_installed_files_override(
         % cmake_install_dir, 'w') as opencv_python_init:
             opencv_python_init.write(opencv_init_data)
 
+        # add lines from the old __init__.py file to the config file
         with open('scripts/__init__.py', 'r') as custom_init:
             custom_init_data = custom_init.read()
         with open('%spython/cv2/config-%s.%s.py'

From 7e67ab5f10ae534d3902ff6883c4b1c9a4fccc02 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Sat, 16 Oct 2021 08:09:03 +0200
Subject: [PATCH 303/345] "Programming Language :: Python :: 3.10",

---
 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index b5ba5bf0..e4f2ee76 100644
--- a/setup.py
+++ b/setup.py
@@ -260,6 +260,7 @@ def main():
             "Programming Language :: Python :: 3.7",
             "Programming Language :: Python :: 3.8",
             "Programming Language :: Python :: 3.9",
+            "Programming Language :: Python :: 3.10",
             "Programming Language :: C++",
             "Programming Language :: Python :: Implementation :: CPython",
             "Topic :: Scientific/Engineering",

From 851182fbb01f1655fe5ca4da9ca24b917765758a Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 18 Oct 2021 17:38:58 +0300
Subject: [PATCH 304/345] Removed useless lines and added replacing lines into
 init file

---
 scripts/__init__.py |  5 +++--
 setup.py            | 13 +------------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/scripts/__init__.py b/scripts/__init__.py
index af17e205..587a42bf 100644
--- a/scripts/__init__.py
+++ b/scripts/__init__.py
@@ -1,5 +1,6 @@
-from .cv2 import *
-from .data import *
+PYTHON_EXTENSIONS_PATHS = [
+    LOADER_DIR
+] + PYTHON_EXTENSIONS_PATHS
 
 ci_and_not_headless = False
 
diff --git a/setup.py b/setup.py
index 7766f96d..6db572e3 100644
--- a/setup.py
+++ b/setup.py
@@ -376,22 +376,11 @@ def _classify_installed_files_override(
 
         print("Copying files from CMake output")
 
-        # need for the proper import of a package
-        with open('%spython/cv2/__init__.py'
-         % cmake_install_dir, 'r') as opencv_init:
-            opencv_init_data = ""
-            for line in opencv_init:
-                opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
-                opencv_init_data = opencv_init_data + opencv_init_replacement
-        with open('%spython/cv2/__init__.py'
-        % cmake_install_dir, 'w') as opencv_python_init:
-            opencv_python_init.write(opencv_init_data)
-
         # add lines from the old __init__.py file to the config file
         with open('scripts/__init__.py', 'r') as custom_init:
             custom_init_data = custom_init.read()
         with open('%spython/cv2/config-%s.%s.py'
-        % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'a') as opencv_init_config:
+        % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'w') as opencv_init_config:
             opencv_init_config.write(custom_init_data)
 
         for package_name, relpaths_re in cls.package_paths_re.items():

From 810ca4ecd3e694ed5d5506daadaec3d49bf49d93 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 1 Nov 2021 17:56:25 +0300
Subject: [PATCH 305/345] Fixed a build from the source

---
 MANIFEST.in | 1 +
 setup.py    | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index 45cb6c40..b429eae0 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -9,3 +9,4 @@ recursive-include docker *
 recursive-include opencv *
 recursive-include opencv_contrib *
 recursive-include patches *
+recursive-include scripts *.py
diff --git a/setup.py b/setup.py
index 1b1f59c7..cf95aca1 100644
--- a/setup.py
+++ b/setup.py
@@ -378,7 +378,8 @@ def _classify_installed_files_override(
         print("Copying files from CMake output")
 
         # add lines from the old __init__.py file to the config file
-        with open('scripts/__init__.py', 'r') as custom_init:
+        with open('%s/scripts/__init__.py'
+        % os.path.split(os.path.abspath(__file__))[0], 'r') as custom_init:
             custom_init_data = custom_init.read()
         with open('%spython/cv2/config-%s.%s.py'
         % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'w') as opencv_init_config:

From 28eb5bfd48c47f01d582d7a57382dc1095030046 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 1 Nov 2021 18:06:10 +0300
Subject: [PATCH 306/345] Updated attached commit for opencv repository

---
 opencv | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opencv b/opencv
index 39c33341..4223495e 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 39c3334147ec02761b117f180c9c4518be18d1fa
+Subproject commit 4223495e6cd67011f86b8ecd9be1fa105018f3b1

From 012f556411f9d63df169966b8e37e1065f6d5bc9 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 1 Nov 2021 18:07:48 +0300
Subject: [PATCH 307/345] Added 3.10 python version in the description

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index d2831332..bade5faf 100644
--- a/README.md
+++ b/README.md
@@ -220,6 +220,7 @@ Python 3.x compatible pre-built wheels are provided for the officially supported
 - 3.7
 - 3.8
 - 3.9
+- 3.10
 
 ### Backward compatibility
 

From a25a2a8e5847335f269949797cc9aa9fb68ad256 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Wed, 3 Nov 2021 17:24:14 +0300
Subject: [PATCH 308/345] Added lines for a proper work using pylint and an
 autocomplete in IDE

---
 setup.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/setup.py b/setup.py
index 1b1f59c7..a53d9911 100644
--- a/setup.py
+++ b/setup.py
@@ -377,6 +377,22 @@ def _classify_installed_files_override(
 
         print("Copying files from CMake output")
 
+        # lines for a proper work using pylint and an autocomplete in IDE
+        with open("%spython/cv2/__init__.py"
+        % cmake_install_dir, 'r') as opencv_init:
+            opencv_init_lines = opencv_init.readlines()
+            extra_imports = 'from .cv2 import *\nglobals().update(importlib.import_module("cv2.cv2").__dict__)'
+            free_line_after_imports = 6
+            opencv_init_lines.insert(free_line_after_imports, extra_imports)
+            opencv_init_data = ""
+            for line in opencv_init_lines:
+                opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
+                opencv_init_data = opencv_init_data + opencv_init_replacement
+
+        with open("%spython/cv2/__init__.py"
+        % cmake_install_dir, 'w') as opencv_final_init:
+            opencv_final_init.write(opencv_init_data)
+
         # add lines from the old __init__.py file to the config file
         with open('scripts/__init__.py', 'r') as custom_init:
             custom_init_data = custom_init.read()

From e7ce0519e3a2241719342bac65d9693e7b4c9e1d Mon Sep 17 00:00:00 2001
From: John Reese <jreese@fb.com>
Date: Wed, 3 Nov 2021 14:47:59 -0700
Subject: [PATCH 309/345] Use PEP-508 compliant dependency specifiers

This allows correctly resolving the numpy version requirement via PyPI metadata, using the same metadata regardless of what version of Python the package was built with or which wheel is uploaded to PyPI first.
---
 setup.py | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/setup.py b/setup.py
index 1b1f59c7..347cb5ba 100644
--- a/setup.py
+++ b/setup.py
@@ -22,26 +22,15 @@ def main():
     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"
-    if sys.version_info[:2] >= (3, 10):
-        minimum_supported_numpy = "1.21.2"
-
-    # linux arm64 is a special case
-    if sys.platform.startswith("linux") and sys.version_info[:2] >= (3, 6) and platform.machine() == "aarch64":
-        minimum_supported_numpy = "1.19.3"
-
-    # macos arm64 is a special case
-    if sys.platform == "darwin" and sys.version_info[:2] >= (3, 6) and platform.machine() == "arm64":
-        minimum_supported_numpy = "1.21.0"
-
-    numpy_version = "numpy>=%s" % minimum_supported_numpy
+    install_requires = [
+        'numpy>=1.13.3; python_version<"3.7"',
+        'numpy>=1.14.5; python_version>="3.7"',
+        'numpy>=1.17.3; python_version>="3.8"',
+        'numpy>=1.19.3; python_version>="3.9"',
+        'numpy>=1.21.2; python_version>="3.10"',
+        'numpy>=1.19.3; python_version>="3.6" and platform_system=="Linux" and platform_machine=="aarch64"',
+        'numpy>=1.21.2; python_version>="3.6" and platform_system=="Darwin" and platform_machine=="arm64"',
+    ]
 
     python_version = cmaker.CMaker.get_python_version()
     python_lib_path = cmaker.CMaker.get_python_library(python_version).replace(
@@ -257,7 +246,7 @@ def main():
         package_data=package_data,
         maintainer="Olli-Pekka Heinisuo",
         ext_modules=EmptyListWithLength(),
-        install_requires=numpy_version,
+        install_requires=install_requires,
         python_requires=">=3.6",
         classifiers=[
             "Development Status :: 5 - Production/Stable",

From f46eabba1258834cabe2df669fbc56e7ceaa16fd Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 8 Nov 2021 02:36:06 +0300
Subject: [PATCH 310/345] Moving to auditwheel==5.0.0 (default in the latest
 manylinux image)

---
 patch_auditwheel_whitelist.py | 7 +++----
 travis_config.sh              | 8 ++++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/patch_auditwheel_whitelist.py b/patch_auditwheel_whitelist.py
index d0cbf5b2..b32da17a 100644
--- a/patch_auditwheel_whitelist.py
+++ b/patch_auditwheel_whitelist.py
@@ -5,12 +5,11 @@
 
 policies = None
 
-with open(join(dirname(abspath(policy.__file__)), "policy.json")) as f:
+with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json")) as f:
     policies = json.load(f)
 
 for p in policies:
-    if p["name"] == "manylinux2014":
-        p["lib_whitelist"].append("libxcb.so.1")
+    p["lib_whitelist"].append("libxcb.so.1")
 
-with open(join(dirname(abspath(policy.__file__)), "policy.json"), "w") as f:
+with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json"), "w") as f:
     f.write(json.dumps(policies))
diff --git a/travis_config.sh b/travis_config.sh
index 937e5a2d..2eb81faa 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -17,11 +17,11 @@ function bdist_wheel_cmd {
     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
+      # this path can be changed in the latest manylinux image
+      TOOLS_PATH=/opt/_internal/pipx/venvs/auditwheel
+      /opt/python/cp39-cp39/bin/python -m venv $TOOLS_PATH
       source $TOOLS_PATH/bin/activate
-      python$PYTHON_VERSION -m pip install auditwheel==3.2.0
-      python$PYTHON_VERSION patch_auditwheel_whitelist.py
+      python patch_auditwheel_whitelist.py
       # to avoid issues with numpy wheels
       rm /io/wheelhouse/numpy*
       deactivate

From 2188a44884bdc232bac9f87109158a0b94928389 Mon Sep 17 00:00:00 2001
From: "Kian-Meng, Ang" <kianmeng@cpan.org>
Date: Mon, 8 Nov 2021 09:57:24 +0800
Subject: [PATCH 311/345] Fix typos

---
 LICENSE-3RD-PARTY.txt    | 6 +++---
 README.md                | 2 +-
 travis_config.sh         | 2 +-
 travis_osx_brew_cache.sh | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt
index 20f4fb37..caeffe51 100644
--- a/LICENSE-3RD-PARTY.txt
+++ b/LICENSE-3RD-PARTY.txt
@@ -1000,7 +1000,7 @@ This license applies to above binaries in the directory cv2/.
  * The implementation was written so as to conform with Netscapes SSL.
  *
  * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to.  The following conditions
+ * the following conditions are adhered to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
@@ -1025,7 +1025,7 @@ This license applies to above binaries in the directory cv2/.
  *    must display the following acknowledgement:
  *    "This product includes cryptographic software written by
  *     Eric Young (eay@cryptsoft.com)"
- *    The word 'cryptographic' can be left out if the rouines from the library
+ *    The word 'cryptographic' can be left out if the routines from the library
  *    being used are not cryptographic related :-).
  * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
@@ -1043,7 +1043,7 @@ This license applies to above binaries in the directory cv2/.
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * The licence and distribution terms for any publically available version or
+ * The licence and distribution terms for any publicly available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
  * [including the GNU Public Licence.]
diff --git a/README.md b/README.md
index d2831332..6844bd9f 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ A: It's easier for users to understand ``opencv-python`` than ``cv2`` and it mak
 
 ## Documentation for opencv-python
 
-[![Windows Buld Status](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml)
+[![Windows Build Status](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_windows.yml)
 [![(Linux Build status)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_linux.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_linux.yml)
 [![(Mac OS Build status)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_macos.yml/badge.svg)](https://github.com/opencv/opencv-python/actions/workflows/build_wheels_macos.yml)
 
diff --git a/travis_config.sh b/travis_config.sh
index 937e5a2d..75a22d26 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -12,7 +12,7 @@ function build_wheel {
 
 function bdist_wheel_cmd {
     # copied from multibuild's common_utils.sh
-    # add osx deployment target so it doesnt default to 10.6
+    # add osx deployment target so it doesn't default to 10.6
     local abs_wheelhouse=$1
     CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
     cp dist/*.whl $abs_wheelhouse
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 401265f2..1a2a1c6c 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -249,7 +249,7 @@ function _brew_install_and_cache_within_time_limit {
     for dep in $DEPS; do
         #TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
         #While we don't know that yet, we can make better use of Travis-given time with a laxer limit
-        #We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
+        #We still can't overrun TIME_HARD_LIMIT as that wouldn't leave time to save the cache
         _brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || return $?
     done
 

From 9a7af2aa4090d40a981cf91ef2b3c4c363e356de Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 8 Nov 2021 15:38:20 +0300
Subject: [PATCH 312/345] Changed defining path to scripts/__init__.py file

---
 setup.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index cf95aca1..87632fe9 100644
--- a/setup.py
+++ b/setup.py
@@ -378,8 +378,7 @@ def _classify_installed_files_override(
         print("Copying files from CMake output")
 
         # add lines from the old __init__.py file to the config file
-        with open('%s/scripts/__init__.py'
-        % os.path.split(os.path.abspath(__file__))[0], 'r') as custom_init:
+        with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
             custom_init_data = custom_init.read()
         with open('%spython/cv2/config-%s.%s.py'
         % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'w') as opencv_init_config:

From b6e1ec80d8a362ea967b52ad5d64b635f63b43cf Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@xperience.ai>
Date: Tue, 9 Nov 2021 18:17:51 +0300
Subject: [PATCH 313/345] Fixed imports for a proper package work

---
 setup.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index a53d9911..27e61933 100644
--- a/setup.py
+++ b/setup.py
@@ -381,7 +381,8 @@ def _classify_installed_files_override(
         with open("%spython/cv2/__init__.py"
         % cmake_install_dir, 'r') as opencv_init:
             opencv_init_lines = opencv_init.readlines()
-            extra_imports = 'from .cv2 import *\nglobals().update(importlib.import_module("cv2.cv2").__dict__)'
+            extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi'
+                             '\nfrom . import misc\nfrom . import utils\nfrom . import data\n')
             free_line_after_imports = 6
             opencv_init_lines.insert(free_line_after_imports, extra_imports)
             opencv_init_data = ""

From 8cb031a47fe8a9a9072723140f0c3ab2858ac751 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 12 Nov 2021 17:37:03 +0300
Subject: [PATCH 314/345] Changed a string substitution to os.path.join

---
 setup.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index 27e61933..2fe7fc21 100644
--- a/setup.py
+++ b/setup.py
@@ -378,8 +378,7 @@ def _classify_installed_files_override(
         print("Copying files from CMake output")
 
         # lines for a proper work using pylint and an autocomplete in IDE
-        with open("%spython/cv2/__init__.py"
-        % cmake_install_dir, 'r') as opencv_init:
+        with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'r') as opencv_init:
             opencv_init_lines = opencv_init.readlines()
             extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi'
                              '\nfrom . import misc\nfrom . import utils\nfrom . import data\n')
@@ -390,8 +389,7 @@ def _classify_installed_files_override(
                 opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
                 opencv_init_data = opencv_init_data + opencv_init_replacement
 
-        with open("%spython/cv2/__init__.py"
-        % cmake_install_dir, 'w') as opencv_final_init:
+        with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'w') as opencv_final_init:
             opencv_final_init.write(opencv_init_data)
 
         # add lines from the old __init__.py file to the config file

From 8f763b1ebcfa3f6dc62e226c61a5b8be7f141ec0 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Fri, 26 Nov 2021 11:45:37 +0100
Subject: [PATCH 315/345] Delete appveyor.yml

The last run was a year ago.  https://ci.appveyor.com/project/skvark/opencv-python/history
---
 appveyor.yml | 201 ---------------------------------------------------
 1 file changed, 201 deletions(-)
 delete mode 100644 appveyor.yml

diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index c79e7de4..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,201 +0,0 @@
-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."
-    }

From 040dc8d80fb3dffddc9bf235f0610f998d470a97 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Wed, 15 Dec 2021 15:58:12 +0300
Subject: [PATCH 316/345] Added python limited API support

---
 .github/workflows/build_wheels_linux.yml     | 123 ++++++++++---
 .github/workflows/build_wheels_linux_arm.yml | 121 +++++++++++--
 .github/workflows/build_wheels_macos.yml     | 144 +++++++++++++--
 .github/workflows/build_wheels_macos_m1.yml  | 109 ++++++++++--
 .github/workflows/build_wheels_windows.yml   | 174 +++++++++++++++++--
 setup.py                                     |   7 +-
 travis_config.sh                             |   6 +-
 7 files changed, 592 insertions(+), 92 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 7ff34a18..338673dc 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest]
-        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        python-version: ['3.6']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -37,13 +37,12 @@ jobs:
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
+      PLAT: x86_64
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
@@ -59,25 +58,108 @@ jobs:
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
 
-    - name: Setup Environment variables
-      run: |
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
-        if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
-    - name: build
+    - name: Build a package
       run: source scripts/build.sh
 
-    - name: install and test
-      run: source scripts/install.sh
-
-    - name: saving artifacts
+    - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
 
+    - name: Saving opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+  test:
+    needs: [build]
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_LATEST: numpy==1.21.2
+      CONFIG_PATH: travis_config.sh
+      PLAT: x86_64
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: false
+        fetch-depth: 0
+
+    - name: Setup Environment variables
+      run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+
+    - name: Download opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Package installation and run tests
+      run: source scripts/install.sh
 
   build_sdist:
     runs-on: ${{ matrix.os }}
@@ -131,12 +213,7 @@ jobs:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
 
-    - name: Setup Environment variables
-      run: |
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
-
-    - name: before install
+    - name: Build a package
       run: |
         set -e
         # Build and package
@@ -157,7 +234,7 @@ jobs:
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build, build_sdist]
+    needs: [build, build_sdist, test]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -176,7 +253,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build, build_sdist]
+    needs: [build, build_sdist, test]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index 89142a57..08badc5b 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ARM64]
-        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        python-version: ['3.6']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -38,12 +38,9 @@ jobs:
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       PLAT: aarch64
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
-      DOCKER_TEST_IMAGE: multibuild/focal_arm64v8
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
@@ -61,26 +58,118 @@ jobs:
         submodules: false
         fetch-depth: 0
 
-    - name: Setup Environment variables
-      run: |
-        if [ "ARM64" == "${{ matrix.os }}" ]; then echo "PLAT=aarch64" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
-    - name: build
+    - name: Build a package
       run: source scripts/build.sh
 
-    - name: install and test
-      run: source scripts/install.sh
-
-    - name: saving artifacts
+    - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
 
+    - name: Saving opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+  test:
+    needs: [build_arm]
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ARM64]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      PLAT: aarch64
+      NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_LATEST: numpy==1.21.4
+      CONFIG_PATH: travis_config.sh
+      DOCKER_TEST_IMAGE: multibuild/focal_arm64v8
+      UNICODE_WIDTH: 32
+
+    steps:
+    - name: Cleanup
+      if: always()
+      uses: AutoModality/action-clean@v1
+
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Setup Environment variables
+      run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+
+    - name: Download opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Package installation and run tests
+      run: source scripts/install.sh
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build_arm]
+    needs: [build_arm, test]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -99,7 +188,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build_arm]
+    needs: [build_arm, test]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index d4f10be0..0ff69ede 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [macos-10.15, macos-11]
-        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        python-version: ['3.6']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -48,14 +48,13 @@ jobs:
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
       TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
       MB_ML_VER: 2014
-      NP_TEST_DEP: numpy==1.19.4
-      NP_TEST_DEP_LATEST: numpy==1.21.2
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       TRAVIS_OS_NAME: osx
       CONFIG_PATH: travis_config.sh
       DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
+      PLAT: x86_64
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
@@ -71,15 +70,7 @@ jobs:
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
 
-    - name: Setup Environment variables
-      run: |
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
-        if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
-        if [ "x64" == "${{ matrix.platform }}" ]; then echo "PLAT=x86_64" >> $GITHUB_ENV; fi
-        if [ "x86" == "${{ matrix.platform }}" ]; then echo "PLAT=i686" >> $GITHUB_ENV; fi
-        if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
-    - name: before install
+    - name: Build a package
       run: |
         set -e
         # Check out and prepare the source
@@ -96,19 +87,136 @@ jobs:
         echo $ENABLE_HEADLESS > headless.enabled
         set -x
         build_wheel $REPO_DIR $PLAT
-        git submodule update --init --recursive
-        install_run $PLAT
-        set +x
 
-    - name: saving artifacts
+    - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
 
+    - name: Saving opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+  test:
+    needs: [build]
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macos-10.15, macos-11]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+        exclude:
+          - os: macos-10.15
+            python-version: '3.10'
+          - os: macos-11
+            python-version: '3.6'
+          - os: macos-11
+            python-version: '3.7'
+          - os: macos-11
+            python-version: '3.8'
+          - os: macos-11
+            python-version: '3.9'
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      MB_PYTHON_VERSION: ${{ matrix.python-version }}
+      NP_TEST_DEP: numpy==1.19.4
+      NP_TEST_DEP_LATEST: numpy==1.21.4
+      CONFIG_PATH: travis_config.sh
+      PLAT: x86_64
+      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Setup Environment variables
+      run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
+
+    - name: Download opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Package installation
+      run: |
+        python -m pip install wheelhouse/opencv*.whl
+        cd ${{ github.workspace }}/tests
+        python get_build_info.py
+
+    - name: Run tests
+      run: |
+        cd ${{ github.workspace }}/opencv
+        python modules/python/test/test.py -v --repo .
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build]
+    needs: [build, test]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -127,7 +235,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build]
+    needs: [build, test]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 79164dcf..cd183389 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -20,7 +20,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [macOS-M1]
-        python-version: ['3.7', '3.8', '3.9', '3.10']
+        python-version: ['3.7']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -31,7 +31,6 @@ jobs:
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
 
     steps:
     - name: Checkout
@@ -44,36 +43,116 @@ jobs:
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
 
-    - name: build script
+    - name: Build a package
       run: |
         git submodule update --init multibuild
         echo $ENABLE_CONTRIB > contrib.enabled
         echo $ENABLE_HEADLESS > headless.enabled
         export MACOSX_DEPLOYMENT_TARGET=11.0
-        arch -arm64 python${{ matrix.python-version }} -m pip wheel --wheel-dir=wheelhouse . --verbose
+        arch -arm64 python${{ matrix.python-version }} -m pip install toml && python${{ matrix.python-version }} -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | python${{ matrix.python-version }} -m pip install -r /dev/stdin
+        arch -arm64 python${{ matrix.python-version }} setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=wheelhouse -v
         delocate-wheel ${{ github.workspace }}/wheelhouse/opencv*
 
-    - name: before test
+    - name: Saving all wheels
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+    - name: Saving opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+  test:
+    needs: [build]
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macOS-M1]
+        python-version: ['3.7', '3.8', '3.9', '3.10']
+        platform: [x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Download opencv-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels
+        path: wheelhouse/
+
+    - name: Package installation
       run: |
-        git submodule update --init --recursive
         arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl
         cd ${{ github.workspace }}/tests
         arch -arm64 python${{ matrix.python-version }} get_build_info.py
 
-    - name: run test
+    - name: Run tests
       run: |
         cd ${{ github.workspace }}/opencv
         arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
 
-    - name: saving artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        name: wheels
-        path: wheelhouse/opencv*.whl
-
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build]
+    needs: [build, test]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -92,7 +171,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build]
+    needs: [build, test]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 3eb13086..ade90ead 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -22,7 +22,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [windows-latest]
-        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        python-version: ['3.6']
         platform: [x86, x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
@@ -55,38 +55,184 @@ jobs:
     - name: Setup MSBuild.exe
       uses: warrenbuckley/Setup-MSBuild@v1
 
-    - name: build script
+    - name: Build a package
       run: |
         python --version
         python -m pip install --upgrade pip
         python -m pip install --upgrade setuptools
-        set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
+        python -m pip install toml && python -c "import toml; c = toml.load('pyproject.toml'); print('\n'.join(c['build-system']['requires']))" >> requirements.txt | python -m pip install -r requirements.txt
+        set "CI_BUILD=1" && python setup.py bdist_wheel --py-limited-api=cp36 --dist-dir=%cd%\wheelhouse -v
       shell: cmd
 
-    - name: before test
+    - name: Saving all wheels
+      uses: actions/upload-artifact@v2
+      with:
+        name: wheels
+        path: wheelhouse/opencv*.whl
+
+    - name: Saving opencv-python x86 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels-x86
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python x64 wheels  
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-wheels-x64
+        path: wheelhouse/opencv_python-*.whl
+
+    - name: Saving opencv-python-headless x86 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels-x86
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-python-headless x64 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-python-headless-wheels-x64
+        path: wheelhouse/opencv_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python x86 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels-x86
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python x64 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels-x64
+        path: wheelhouse/opencv_contrib_python-*.whl
+
+    - name: Saving opencv-contrib-python-headless x86 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels-x86
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+    - name: Saving opencv-contrib-python-headless x64 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
+      uses: actions/upload-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels-x64
+        path: wheelhouse/opencv_contrib_python_headless-*.whl
+
+  test:
+    needs: [build-windows-x86_64]
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: powershell
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [windows-latest]
+        python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
+        platform: [x86, x64]
+        with_contrib: [0, 1]
+        without_gui: [0, 1]
+        build_sdist: [0]
+
+    env:
+      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+      OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
+
+    steps:
+    - name: Checkout
+      uses: actions/checkout@v2
+      with:
+        submodules: true
+        fetch-depth: 0
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+        architecture: ${{ matrix.platform }}
+
+    - name: Download opencv-python x86 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels-x86
+        path: wheelhouse/
+
+    - name: Download opencv-python x64 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-wheels-x64
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless x86 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels-x86
+        path: wheelhouse/
+
+    - name: Download opencv-python-headless x64 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-python-headless-wheels-x64
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python x86 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels-x86
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python x64 wheels
+      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-wheels-x64
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless x86 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels-x86
+        path: wheelhouse/
+
+    - name: Download opencv-contrib-python-headless x64 wheels
+      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
+      uses: actions/download-artifact@v2
+      with:
+        name: opencv-contrib-python-headless-wheels-x64
+        path: wheelhouse/
+
+    - name: Package installation
       run: |
-        git submodule update --init --recursive
         cd ${{ github.workspace }}/tests
         &python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
         if ($LastExitCode -ne 0) {throw $LastExitCode}
         python get_build_info.py
       shell: powershell
 
-    - name: run test
+    - name: Run tests
       run: |
         cd ${{ github.workspace }}/opencv
         python modules\python\test\test.py -v --repo .
       shell: cmd
 
-    - name: saving artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        name: wheels
-        path: wheelhouse/opencv*.whl
-
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
-    needs: [build-windows-x86_64]
+    needs: [build-windows-x86_64, test]
     runs-on: ubuntu-latest
     environment: test-opencv-python-release
     defaults:
@@ -105,7 +251,7 @@ jobs:
 
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
-    needs: [build-windows-x86_64]
+    needs: [build-windows-x86_64, test]
     runs-on: ubuntu-latest
     environment: opencv-python-release
     defaults:
diff --git a/setup.py b/setup.py
index a49fcc37..331631ea 100644
--- a/setup.py
+++ b/setup.py
@@ -97,8 +97,8 @@ def main():
         # Naming conventions vary so widely between versions and OSes
         # had to give up on checking them.
         [
-            "python/cv2/python-%s.%s/cv2[^/]*%s"
-            % (sys.version_info[0], sys.version_info[1], re.escape(sysconfig.get_config_var("EXT_SUFFIX")))
+            r"python/cv2/python-%s/cv2.*"
+            % (sys.version_info[0])
         ]
         +
         [
@@ -159,6 +159,7 @@ def main():
             "-DBUILD_TESTS=OFF",
             "-DBUILD_PERF_TESTS=OFF",
             "-DBUILD_DOCS=OFF",
+            "-DPYTHON3_LIMITED_API=ON",
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64
@@ -370,7 +371,7 @@ def _classify_installed_files_override(
         with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'r') as opencv_init:
             opencv_init_lines = opencv_init.readlines()
             extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi'
-                             '\nfrom . import misc\nfrom . import utils\nfrom . import data\n')
+                             '\nfrom . import misc\nfrom . import utils\nfrom . import data\nfrom . import version\n')
             free_line_after_imports = 6
             opencv_init_lines.insert(free_line_after_imports, extra_imports)
             opencv_init_data = ""
diff --git a/travis_config.sh b/travis_config.sh
index 6d6cc06b..7bbfec68 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -14,7 +14,9 @@ function bdist_wheel_cmd {
     # copied from multibuild's common_utils.sh
     # add osx deployment target so it doesn't default to 10.6
     local abs_wheelhouse=$1
-    CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
+    # install all required packages in pyproject.toml, because bdist_wheel does not do it
+    python${PYTHON_VERSION} -m pip install toml && python${PYTHON_VERSION} -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | python${PYTHON_VERSION} -m pip install -r /dev/stdin
+    CI_BUILD=1 python${PYTHON_VERSION} setup.py bdist_wheel --py-limited-api=cp36 -v
     cp dist/*.whl $abs_wheelhouse
     if [ -z "$IS_OSX" ]; then
       # this path can be changed in the latest manylinux image
@@ -22,8 +24,6 @@ function bdist_wheel_cmd {
       /opt/python/cp39-cp39/bin/python -m venv $TOOLS_PATH
       source $TOOLS_PATH/bin/activate
       python patch_auditwheel_whitelist.py
-      # to avoid issues with numpy wheels
-      rm /io/wheelhouse/numpy*
       deactivate
     fi
     if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi

From edd6b14d97c51f077f2fae37271db4f77841df2c Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Wed, 15 Dec 2021 21:04:34 +0300
Subject: [PATCH 317/345] Changed a path to config-X.py file after python
 limited API support, optimized uploading and downloading artifacts

---
 .github/workflows/build_wheels_linux.yml     |  54 +--------
 .github/workflows/build_wheels_linux_arm.yml |  54 +--------
 .github/workflows/build_wheels_macos.yml     |  54 +--------
 .github/workflows/build_wheels_macos_m1.yml  |  54 +--------
 .github/workflows/build_wheels_windows.yml   | 110 +------------------
 setup.py                                     |   4 +-
 6 files changed, 27 insertions(+), 303 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 338673dc..bd42944c 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -67,33 +67,11 @@ jobs:
         name: wheels
         path: wheelhouse/opencv*.whl
 
-    - name: Saving opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+    - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
-        name: opencv-python-wheels
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
+        path: wheelhouse/opencv*.whl
 
   test:
     needs: [build]
@@ -130,32 +108,10 @@ jobs:
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
-    - name: Download opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+    - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
-        name: opencv-contrib-python-headless-wheels
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
 
     - name: Package installation and run tests
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index 08badc5b..a97bbc29 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -67,33 +67,11 @@ jobs:
         name: wheels
         path: wheelhouse/opencv*.whl
 
-    - name: Saving opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+    - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
-        name: opencv-python-wheels
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
+        path: wheelhouse/opencv*.whl
 
   test:
     needs: [build_arm]
@@ -136,32 +114,10 @@ jobs:
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
-    - name: Download opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+    - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
-        name: opencv-contrib-python-headless-wheels
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
 
     - name: Package installation and run tests
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index 0ff69ede..87fe6f99 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -94,33 +94,11 @@ jobs:
         name: wheels
         path: wheelhouse/opencv*.whl
 
-    - name: Saving opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+    - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
-        name: opencv-python-wheels
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
+        path: wheelhouse/opencv*.whl
 
   test:
     needs: [build]
@@ -175,32 +153,10 @@ jobs:
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
 
-    - name: Download opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+    - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
-        name: opencv-contrib-python-headless-wheels
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
 
     - name: Package installation
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index cd183389..3711e1b3 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -59,33 +59,11 @@ jobs:
         name: wheels
         path: wheelhouse/opencv*.whl
 
-    - name: Saving opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
+    - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
-        name: opencv-python-wheels
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
+        path: wheelhouse/opencv*.whl
 
   test:
     needs: [build]
@@ -111,32 +89,10 @@ jobs:
         submodules: true
         fetch-depth: 0
 
-    - name: Download opencv-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 }}
+    - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
-        name: opencv-contrib-python-headless-wheels
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
 
     - name: Package installation
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index ade90ead..0f697291 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -70,61 +70,11 @@ jobs:
         name: wheels
         path: wheelhouse/opencv*.whl
 
-    - name: Saving opencv-python x86 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
+    - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
-        name: opencv-python-wheels-x86
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python x64 wheels  
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-wheels-x64
-        path: wheelhouse/opencv_python-*.whl
-
-    - name: Saving opencv-python-headless x86 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels-x86
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-python-headless x64 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-python-headless-wheels-x64
-        path: wheelhouse/opencv_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python x86 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels-x86
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python x64 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels-x64
-        path: wheelhouse/opencv_contrib_python-*.whl
-
-    - name: Saving opencv-contrib-python-headless x86 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels-x86
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
-
-    - name: Saving opencv-contrib-python-headless x64 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
-      uses: actions/upload-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels-x64
-        path: wheelhouse/opencv_contrib_python_headless-*.whl
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
+        path: wheelhouse/opencv*
 
   test:
     needs: [build-windows-x86_64]
@@ -160,60 +110,10 @@ jobs:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
 
-    - name: Download opencv-python x86 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels-x86
-        path: wheelhouse/
-
-    - name: Download opencv-python x64 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-wheels-x64
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless x86 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x86' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels-x86
-        path: wheelhouse/
-
-    - name: Download opencv-python-headless x64 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 0 && matrix.platform == 'x64' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-python-headless-wheels-x64
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python x86 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels-x86
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python x64 wheels
-      if: ${{ matrix.without_gui == 0 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-wheels-x64
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless x86 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x86' }}
-      uses: actions/download-artifact@v2
-      with:
-        name: opencv-contrib-python-headless-wheels-x86
-        path: wheelhouse/
-
-    - name: Download opencv-contrib-python-headless x64 wheels
-      if: ${{ matrix.without_gui == 1 && matrix.with_contrib == 1 && matrix.platform == 'x64' }}
+    - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
-        name: opencv-contrib-python-headless-wheels-x64
+        name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
         path: wheelhouse/
 
     - name: Package installation
diff --git a/setup.py b/setup.py
index 331631ea..cef4c93f 100644
--- a/setup.py
+++ b/setup.py
@@ -385,8 +385,8 @@ def _classify_installed_files_override(
         # add lines from the old __init__.py file to the config file
         with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
             custom_init_data = custom_init.read()
-        with open('%spython/cv2/config-%s.%s.py'
-        % (cmake_install_dir, sys.version_info[0], sys.version_info[1]), 'w') as opencv_init_config:
+        with open('%spython/cv2/config-%s.py'
+        % (cmake_install_dir, sys.version_info[0]), 'w') as opencv_init_config:
             opencv_init_config.write(custom_init_data)
 
         for package_name, relpaths_re in cls.package_paths_re.items():

From cc12af622b06c2900bc134cf4c3ff7b9a3ee84e1 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Sat, 25 Dec 2021 15:42:39 +0300
Subject: [PATCH 318/345] Updated commits to 4.5.5 release

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 opencv_extra   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opencv b/opencv
index 4223495e..dad26339 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit 4223495e6cd67011f86b8ecd9be1fa105018f3b1
+Subproject commit dad26339a975b49cfb6c7dbe4bd5276c9dcb36e2
diff --git a/opencv_contrib b/opencv_contrib
index 2bc3e1a1..49e8f123 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 2bc3e1a169afd2675ef68221176f32cc0ea5427a
+Subproject commit 49e8f123ca08e76891856a1ecce491b62d08ba20
diff --git a/opencv_extra b/opencv_extra
index 822ee112..37294e3c 160000
--- a/opencv_extra
+++ b/opencv_extra
@@ -1 +1 @@
-Subproject commit 822ee11240b969e98e20546663bc481a5e7089cc
+Subproject commit 37294e3c876a72c992d4718b9bbfc8346b9e779a

From ec7b7e48ba145484e10f71bad0a804093dacc973 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Sun, 26 Dec 2021 22:02:16 +0300
Subject: [PATCH 319/345] Added openexr build flag

---
 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index cef4c93f..63c66320 100644
--- a/setup.py
+++ b/setup.py
@@ -160,6 +160,7 @@ def main():
             "-DBUILD_PERF_TESTS=OFF",
             "-DBUILD_DOCS=OFF",
             "-DPYTHON3_LIMITED_API=ON",
+            "-DBUILD_OPENEXR=ON",
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64

From 0a17e6c91b36baf133fbf2546483805d806bd5f2 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 24 Jan 2022 23:18:32 +0300
Subject: [PATCH 320/345] Updated dependencies to the latest releases (openssl
 and ffmpeg) in a dockerfile, turned on building libpng

---
 docker/manylinux2014/Dockerfile_aarch64 | 12 ++++++------
 docker/manylinux2014/Dockerfile_i686    | 12 ++++++------
 docker/manylinux2014/Dockerfile_x86_64  | 12 ++++++------
 setup.py                                |  1 +
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index c76ccec4..9a5b0a48 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -18,9 +18,9 @@ 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 && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
+    tar -xf OpenSSL_1_1_1m.tar.gz && \
+    cd openssl-OpenSSL_1_1_1m && \
     ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
@@ -50,9 +50,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
-    tar -xf ffmpeg-4.3.2.tar.bz2 && \
-    cd ffmpeg-4.3.2 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
+    tar -xf ffmpeg-4.4.1.tar.bz2 && \
+    cd ffmpeg-4.4.1 && \
     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) && \
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index 6a60a073..b434f5c0 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -18,9 +18,9 @@ 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 && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
+    tar -xf OpenSSL_1_1_1m.tar.gz && \
+    cd openssl-OpenSSL_1_1_1m && \
     # in i686, ./config detects x64 in i686 container without linux32
     # when run from "docker build"
     linux32 ./config --prefix="$HOME/ffmpeg_build" no-pinshared shared zlib && \
@@ -52,9 +52,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
-    tar -xf ffmpeg-4.3.2.tar.bz2 && \
-    cd ffmpeg-4.3.2 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
+    tar -xf ffmpeg-4.4.1.tar.bz2 && \
+    cd ffmpeg-4.4.1 && \
     PATH=~/bin:$PATH && \
     PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" linux32 ./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) && \
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 49622378..f07baf74 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -18,9 +18,9 @@ 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 && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
+    tar -xf OpenSSL_1_1_1m.tar.gz && \
+    cd openssl-OpenSSL_1_1_1m && \
     ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
@@ -50,9 +50,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
-    tar -xf ffmpeg-4.3.2.tar.bz2 && \
-    cd ffmpeg-4.3.2 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
+    tar -xf ffmpeg-4.4.1.tar.bz2 && \
+    cd ffmpeg-4.4.1 && \
     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) && \
diff --git a/setup.py b/setup.py
index 63c66320..5b79e389 100644
--- a/setup.py
+++ b/setup.py
@@ -161,6 +161,7 @@ def main():
             "-DBUILD_DOCS=OFF",
             "-DPYTHON3_LIMITED_API=ON",
             "-DBUILD_OPENEXR=ON",
+            "-DBUILD_PNG=ON",
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64

From 0066feb17909a5fa2295bb9c376054febc902340 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 25 Jan 2022 11:32:45 +0300
Subject: [PATCH 321/345] Added versions of dependecies as arguments in
 dockerfiles

---
 docker/manylinux2014/Dockerfile_aarch64 | 47 ++++++++++++---------
 docker/manylinux2014/Dockerfile_i686    | 56 ++++++++++++++-----------
 docker/manylinux2014/Dockerfile_x86_64  | 40 ++++++++++--------
 3 files changed, 82 insertions(+), 61 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 9a5b0a48..b380d3ba 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -1,26 +1,33 @@
 FROM quay.io/pypa/manylinux2014_aarch64:latest
 
+ARG CCACHE_VERSION=3.7.9
+ARG FFMPEG_VERSION=4.4.1
+ARG NASM_VERSION=2.15.04
+ARG OPENSSL_VERSION=1_1_1m
+ARG QT_VERSION=5.15.0
+ARG YASM_VERSION=1.3.0
+
 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 && \
+RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
+    tar -xf qt-everywhere-src-${QT_VERSION}.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 && \
+    ./configure -prefix /opt/Qt${QT_VERSION} -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
+    rm -rf qt-everywhere-src-${QT_VERSION} && \
+    rm qt-everywhere-src-${QT_VERSION}.tar.xz
 
-ENV QTDIR /opt/Qt5.15.0
+ENV QTDIR /opt/Qt${QT_VERSION}
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
-    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
-    tar -xf OpenSSL_1_1_1m.tar.gz && \
-    cd openssl-OpenSSL_1_1_1m && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    cd openssl-OpenSSL_${OPENSSL_VERSION} && \
     ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
@@ -28,16 +35,16 @@ RUN mkdir ~/ffmpeg_sources && \
     rm -rf ~/openssl_build
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
-    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
+    tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./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 && \
+    curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
+    tar -xf yasm-${YASM_VERSION}.tar.gz && \
+    cd yasm-${YASM_VERSION} && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -50,9 +57,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
-    tar -xf ffmpeg-4.4.1.tar.bz2 && \
-    cd ffmpeg-4.4.1 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    cd ffmpeg-${FFMPEG_VERSION} && \
     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) && \
@@ -61,9 +68,9 @@ RUN cd ~/ffmpeg_sources && \
     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 && \
+RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
+    tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
+    cd ccache-${CCACHE_VERSION} && \
     linux32 ./configure && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
diff --git a/docker/manylinux2014/Dockerfile_i686 b/docker/manylinux2014/Dockerfile_i686
index b434f5c0..3b866874 100644
--- a/docker/manylinux2014/Dockerfile_i686
+++ b/docker/manylinux2014/Dockerfile_i686
@@ -1,26 +1,34 @@
 FROM quay.io/pypa/manylinux2014_i686:latest
 
+ARG CCACHE_VERSION=3.7.9
+ARG CMAKE_VERSION=3.17.0
+ARG FFMPEG_VERSION=4.4.1
+ARG NASM_VERSION=2.15.04
+ARG OPENSSL_VERSION=1_1_1m
+ARG QT_VERSION=5.15.0
+ARG YASM_VERSION=1.3.0
+
 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 && \
+RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
+    tar -xf qt-everywhere-src-${QT_VERSION}.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 && \
+    ./configure -prefix /opt/Qt${QT_VERSION} -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
+    rm -rf qt-everywhere-src-${QT_VERSION} && \
+    rm qt-everywhere-src-${QT_VERSION}.tar.xz
 
-ENV QTDIR /opt/Qt5.15.0
+ENV QTDIR /opt/Qt${QT_VERSION}
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
-    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
-    tar -xf OpenSSL_1_1_1m.tar.gz && \
-    cd openssl-OpenSSL_1_1_1m && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    cd openssl-OpenSSL_${OPENSSL_VERSION} && \
     # in i686, ./config detects x64 in i686 container without linux32
     # when run from "docker build"
     linux32 ./config --prefix="$HOME/ffmpeg_build" no-pinshared shared zlib && \
@@ -30,16 +38,16 @@ RUN mkdir ~/ffmpeg_sources && \
     rm -rf ~/openssl_build
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
-    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
+    tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
     linux32 ./configure && \
     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 && \
+    curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
+    tar -xf yasm-${YASM_VERSION}.tar.gz && \
+    cd yasm-${YASM_VERSION} && \
     linux32 ./configure && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -52,9 +60,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
-    tar -xf ffmpeg-4.4.1.tar.bz2 && \
-    cd ffmpeg-4.4.1 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    cd ffmpeg-${FFMPEG_VERSION} && \
     PATH=~/bin:$PATH && \
     PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" linux32 ./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) && \
@@ -63,22 +71,22 @@ RUN cd ~/ffmpeg_sources && \
     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 && \
+RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
+    tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
+    cd ccache-${CCACHE_VERSION} && \
     linux32 ./configure && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
 
-RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
-    tar -xf cmake-3.17.0.tar.gz && \
-    cd cmake-3.17.0 && \
+RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \
+    tar -xf cmake-${CMAKE_VERSION}.tar.gz && \
+    cd cmake-${CMAKE_VERSION} && \
     export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
     ./configure --system-curl && \
     make && \
     make install && \
     cd .. && \
-    rm -rf cmake-3.17.0*
+    rm -rf cmake-${CMAKE_VERSION}*
 
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index f07baf74..fb367c0a 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,26 +1,32 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
+ARG FFMPEG_VERSION=4.4.1
+ARG NASM_VERSION=2.15.04
+ARG OPENSSL_VERSION=1_1_1m
+ARG QT_VERSION=5.15.0
+ARG YASM_VERSION=1.3.0
+
 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 && \
+RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
+    tar -xf qt-everywhere-src-${QT_VERSION}.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 && \
+    ./configure -prefix /opt/Qt${QT_VERSION} -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
+    rm -rf qt-everywhere-src-${QT_VERSION} && \
+    rm qt-everywhere-src-${QT_VERSION}.tar.xz
 
-ENV QTDIR /opt/Qt5.15.0
+ENV QTDIR /opt/Qt${QT_VERSION}
 ENV PATH "$QTDIR/bin:$PATH"
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
-    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz && \
-    tar -xf OpenSSL_1_1_1m.tar.gz && \
-    cd openssl-OpenSSL_1_1_1m && \
+    curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
+    cd openssl-OpenSSL_${OPENSSL_VERSION} && \
     ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
@@ -28,16 +34,16 @@ RUN mkdir ~/ffmpeg_sources && \
     rm -rf ~/openssl_build
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.15.04/nasm-2.15.04.tar.bz2 && \
-    tar -xf nasm-2.15.04.tar.bz2 && cd nasm-2.15.04 && ./autogen.sh && \
+    curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
+    tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./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 && \
+    curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
+    tar -xf yasm-${YASM_VERSION}.tar.gz && \
+    cd yasm-${YASM_VERSION} && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
@@ -50,9 +56,9 @@ RUN cd ~/ffmpeg_sources && \
     make install
 
 RUN cd ~/ffmpeg_sources && \
-    curl -O -L https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.bz2 && \
-    tar -xf ffmpeg-4.4.1.tar.bz2 && \
-    cd ffmpeg-4.4.1 && \
+    curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
+    cd ffmpeg-${FFMPEG_VERSION} && \
     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) && \

From 700cb0095233e104d6c9e96bb45d3d3312015cd1 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Thu, 3 Mar 2022 11:12:51 +0300
Subject: [PATCH 322/345] Defined static version of windows server

---
 .github/workflows/build_wheels_windows.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 0f697291..cb2beb12 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -21,7 +21,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [windows-latest]
+        os: [windows-2019]
         python-version: ['3.6']
         platform: [x86, x64]
         with_contrib: [0, 1]
@@ -86,7 +86,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [windows-latest]
+        os: [windows-2019]
         python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x86, x64]
         with_contrib: [0, 1]

From 141a763d0e2675476b92e4a15359b19684c68eb2 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Thu, 3 Mar 2022 11:30:02 +0300
Subject: [PATCH 323/345] Updated MSBuild action

---
 .github/workflows/build_wheels_windows.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index cb2beb12..0262c7b8 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -53,7 +53,7 @@ jobs:
         architecture: ${{ matrix.platform }}
 
     - name: Setup MSBuild.exe
-      uses: warrenbuckley/Setup-MSBuild@v1
+      uses: microsoft/setup-msbuild@v1.1
 
     - name: Build a package
       run: |

From 602a8be9e21df225a32827a621f15d7be0e5eebd Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Thu, 3 Mar 2022 14:00:43 +0300
Subject: [PATCH 324/345] Defined ffmpeg version for macos (4.4.1) and fixed
 MacOS build

---
 .github/workflows/build_wheels_macos.yml |  1 +
 travis_config.sh                         | 37 ++++++------------------
 2 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index 87fe6f99..c70f2b2d 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -55,6 +55,7 @@ jobs:
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       PLAT: x86_64
+      FFMPEG_FORMULA_VERSION: '@4'
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
diff --git a/travis_config.sh b/travis_config.sh
index 7bbfec68..dfb656e8 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -50,7 +50,7 @@ if [ -n "$IS_OSX" ]; then
     function generate_ffmpeg_formula {
         local FF="ffmpeg"
         local LFF="ffmpeg_opencv"
-        local FF_FORMULA; FF_FORMULA=$(brew formula "$FF")
+        local FF_FORMULA; FF_FORMULA=$(brew formula "${FF}${FFMPEG_FORMULA_VERSION}")
         local LFF_FORMULA; LFF_FORMULA="$(dirname "$FF_FORMULA")/${LFF}.rb"
 
         local REGENERATE
@@ -70,8 +70,9 @@ if [ -n "$IS_OSX" ]; then
         if [ -n "$REGENERATE" ]; then
             echo "Regenerating custom ffmpeg formula"
             # Bottle block syntax: https://docs.brew.sh/Bottles#bottle-dsl-domain-specific-language
+            # FfmpegAT4 is a class in ffmpeg@4 formula
             perl -wpe 'BEGIN {our ($found_blank, $bottle_block);}
-                if (/(^class )(Ffmpeg)(\s.*)/) {$_=$1.$2."Opencv".$3."\n"; next;}
+                if (/(^class )(FfmpegAT4)(\s.*)/) {$_=$1."FfmpegOpencv".$3."\n"; next;}
                 if (!$found_blank && /^$/) {$_.="conflicts_with \"ffmpeg\"\n\n"; $found_blank=1; next;}
                 if (!$bottle_block && /^\s*bottle do$/) { $bottle_block=1; next; }
                 if ($bottle_block) { if (/^\s*end\s*$/) { $bottle_block=0} elsif (/^\s*sha256\s/) {$_=""} next; }
@@ -111,34 +112,14 @@ function pre_build {
     CACHE_STAGE=
     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
-    #     generate_ffmpeg_formula
-    #     brew_add_local_bottles
-    # 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 update
-        generate_ffmpeg_formula
-        brew_add_local_bottles
-        # brew unlink python@2
-        brew install --build-bottle 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
+    brew update
+    generate_ffmpeg_formula
+    brew_add_local_bottles
+    brew install --build-bottle ffmpeg_opencv
+    # It needs when we use not the latest ffmpeg formula
+    brew link ffmpeg_opencv
 
     if [ -n "$CACHE_STAGE" ]; then
         brew_go_bootstrap_mode 0

From 9de011e3885dc2a7d4f39f4a5d289857395b3eb8 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 22 Mar 2022 17:57:51 +0300
Subject: [PATCH 325/345] Added pylint test

---
 .github/workflows/build_wheels_macos.yml    |  5 +++
 .github/workflows/build_wheels_macos_m1.yml |  5 +++
 .github/workflows/build_wheels_windows.yml  |  6 ++++
 tests/pylint.py                             |  3 ++
 travis_config.sh                            | 37 ++++++++++-----------
 5 files changed, 37 insertions(+), 19 deletions(-)
 create mode 100644 tests/pylint.py

diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index c70f2b2d..2e434a5f 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -171,6 +171,11 @@ jobs:
         cd ${{ github.workspace }}/opencv
         python modules/python/test/test.py -v --repo .
 
+    - name: Pylint test
+      run: |
+        python -m pip install pylint
+        python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build, test]
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 3711e1b3..46ecb631 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -106,6 +106,11 @@ jobs:
         cd ${{ github.workspace }}/opencv
         arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
 
+    - name: Pylint test
+      run: |
+        arch -arm64 python${{ matrix.python-version }} -m pip install pylint
+        arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build, test]
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 0262c7b8..cee1d848 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -130,6 +130,12 @@ jobs:
         python modules\python\test\test.py -v --repo .
       shell: cmd
 
+    - name: Pylint test
+      run: |
+        python -m pip install pylint
+        python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+      shell: cmd
+
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build-windows-x86_64, test]
diff --git a/tests/pylint.py b/tests/pylint.py
new file mode 100644
index 00000000..d10ad684
--- /dev/null
+++ b/tests/pylint.py
@@ -0,0 +1,3 @@
+from cv2 import getStructuringElement, MORPH_ELLIPSE
+
+a = getStructuringElement(MORPH_ELLIPSE, (3, 3))
diff --git a/travis_config.sh b/travis_config.sh
index dfb656e8..751a1772 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -141,37 +141,36 @@ function run_tests {
 
     PYTHON=python$PYTHON_VERSION
 
-    if [ -n "$IS_OSX" ]; then
-      echo "Running for OS X"
-
-      cd ../tests
-      $PYTHON get_build_info.py
-
-      cd ../opencv/
-      export OPENCV_TEST_DATA_PATH=../opencv_extra/testdata
-    else
-      echo "Running for linux"
-
-      if [ $PYTHON == "python3.6" ]; then
-        $PYTHON -m pip install -U numpy==1.19.4
-      fi
-      cd /io/tests
-      $PYTHON get_build_info.py
+    echo "Running for linux"
 
-      cd /io/opencv
-      export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata
+    if [ $PYTHON == "python3.6" ]; then
+      $PYTHON -m pip install -U numpy==1.19.4
     fi
+    cd /io/tests
+    $PYTHON get_build_info.py
+
+    cd /io/opencv
+    export OPENCV_TEST_DATA_PATH=/io/opencv_extra/testdata
 
     test_wheels
+    pylint_test
 }
 
 function test_wheels {
 
-    echo "Starting tests..."
+    echo "Starting OpenCV tests..."
 
     #Test package
     $PYTHON modules/python/test/test.py -v --repo .
 }
 
+function pylint_test {
+
+    echo "Starting Pylint tests..."
+
+    $PYTHON -m pip install pylint
+    $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+}
+
 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
 set -x

From 1e26c5d08c182fdbb09d73bc97594bab793e79f6 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Wed, 23 Mar 2022 10:38:47 +0300
Subject: [PATCH 326/345] Pinned pylint version

---
 .github/workflows/build_wheels_macos.yml    | 2 +-
 .github/workflows/build_wheels_macos_m1.yml | 2 +-
 .github/workflows/build_wheels_windows.yml  | 2 +-
 travis_config.sh                            | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index 2e434a5f..f22d56e1 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -173,7 +173,7 @@ jobs:
 
     - name: Pylint test
       run: |
-        python -m pip install pylint
+        python -m pip install pylint==2.12.2
         python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
 
   test_release_opencv_python:
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 46ecb631..1f51a342 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -108,7 +108,7 @@ jobs:
 
     - name: Pylint test
       run: |
-        arch -arm64 python${{ matrix.python-version }} -m pip install pylint
+        arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2
         arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
 
   test_release_opencv_python:
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index cee1d848..bf9f9906 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -132,7 +132,7 @@ jobs:
 
     - name: Pylint test
       run: |
-        python -m pip install pylint
+        python -m pip install pylint==2.12.2
         python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
       shell: cmd
 
diff --git a/travis_config.sh b/travis_config.sh
index 751a1772..db3bf773 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -168,7 +168,7 @@ function pylint_test {
 
     echo "Starting Pylint tests..."
 
-    $PYTHON -m pip install pylint
+    $PYTHON -m pip install pylint==2.12.2
     $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
 }
 

From ed16e8ef97a35647aa129f167ade956e4630714f Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Wed, 23 Mar 2022 16:20:07 +0300
Subject: [PATCH 327/345] Changed using custom test for pylint to opencv sample

---
 .github/workflows/build_wheels_linux.yml    |  2 +-
 .github/workflows/build_wheels_macos.yml    |  4 +++-
 .github/workflows/build_wheels_macos_m1.yml |  4 +++-
 .github/workflows/build_wheels_windows.yml  |  4 +++-
 tests/pylint.py                             |  3 ---
 tests/pylintrc                              | 12 ++++++++++++
 travis_config.sh                            |  3 ++-
 7 files changed, 24 insertions(+), 8 deletions(-)
 delete mode 100644 tests/pylint.py
 create mode 100644 tests/pylintrc

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index bd42944c..5ed44e21 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -102,7 +102,7 @@ jobs:
     - name: Checkout
       uses: actions/checkout@v2
       with:
-        submodules: false
+        submodules: true
         fetch-depth: 0
 
     - name: Setup Environment variables
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index f22d56e1..bccec01f 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -137,6 +137,7 @@ jobs:
       CONFIG_PATH: travis_config.sh
       PLAT: x86_64
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
+      PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
 
     steps:
     - name: Checkout
@@ -174,7 +175,8 @@ jobs:
     - name: Pylint test
       run: |
         python -m pip install pylint==2.12.2
-        python -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+        cd ${{ github.workspace }}/tests
+        python -m pylint $PYLINT_TEST_FILE
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 1f51a342..9f7b0f37 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -81,6 +81,7 @@ jobs:
 
     env:
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
+      PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
 
     steps:
     - name: Checkout
@@ -109,7 +110,8 @@ jobs:
     - name: Pylint test
       run: |
         arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2
-        arch -arm64 python${{ matrix.python-version }} -m pylint ${{ github.workspace }}/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+        cd ${{ github.workspace }}/tests
+        arch -arm64 python${{ matrix.python-version }} -m pylint $PYLINT_TEST_FILE
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index bf9f9906..337c77b2 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -96,6 +96,7 @@ jobs:
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
+      PYLINT_TEST_FILE: ${{ github.workspace }}\opencv\samples\python\squares.py
 
     steps:
     - name: Checkout
@@ -133,7 +134,8 @@ jobs:
     - name: Pylint test
       run: |
         python -m pip install pylint==2.12.2
-        python -m pylint ${{ github.workspace }}\tests\pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+        cd ${{ github.workspace }}\tests
+        python -m pylint $PYLINT_TEST_FILE
       shell: cmd
 
   test_release_opencv_python:
diff --git a/tests/pylint.py b/tests/pylint.py
deleted file mode 100644
index d10ad684..00000000
--- a/tests/pylint.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from cv2 import getStructuringElement, MORPH_ELLIPSE
-
-a = getStructuringElement(MORPH_ELLIPSE, (3, 3))
diff --git a/tests/pylintrc b/tests/pylintrc
new file mode 100644
index 00000000..a3892018
--- /dev/null
+++ b/tests/pylintrc
@@ -0,0 +1,12 @@
+# Source: opencv/platforms/scripts/pylintrc
+
+[MESSAGES CONTROL]
+
+# Disable all to choose the Tests one by one
+disable=all
+
+# Tests
+enable=bad-indentation,       # Used when an unexpected number of indentation’s tabulations or spaces has been found.
+       mixed-indentation,     # Used when there are some mixed tabs and spaces in a module.
+       unnecessary-semicolon, # Used when a statement is ended by a semi-colon (”;”), which isn’t necessary.
+       unused-variable        # Used when a variable is defined but not used. (Use _var to ignore var).
diff --git a/travis_config.sh b/travis_config.sh
index db3bf773..4560f726 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -169,7 +169,8 @@ function pylint_test {
     echo "Starting Pylint tests..."
 
     $PYTHON -m pip install pylint==2.12.2
-    $PYTHON -m pylint /io/tests/pylint.py --extension-pkg-whitelist=cv2 --disable=missing-docstring
+    cd /io/tests
+    $PYTHON -m pylint /io/opencv/samples/python/squares.py
 }
 
 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'

From 3a4c30e50438a3f50c28deb80d16b96235dc7bb7 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Thu, 24 Mar 2022 18:17:16 +0300
Subject: [PATCH 328/345] Added pre-downloaded 3rdparty files to source
 packages

---
 .github/workflows/build_wheels_linux.yml |  6 ++++--
 scripts/source-packages-preparation.sh   | 20 ++++++++++++++++++++
 setup.py                                 |  2 ++
 3 files changed, 26 insertions(+), 2 deletions(-)
 create mode 100755 scripts/source-packages-preparation.sh

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 5ed44e21..3e3e010b 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -171,12 +171,14 @@ jobs:
 
     - name: Build a package
       run: |
+        # Download all 3rdparty files
+        source scripts/source-packages-preparation.sh ${{ github.workspace }}
         set -e
         # Build and package
         set -x
           python -m pip install --upgrade pip
           python -m pip install scikit-build
-          python setup.py sdist
+          python setup.py sdist --formats=xztar
         set +x
         # Install and run tests
         set -x
@@ -186,7 +188,7 @@ jobs:
       uses: actions/upload-artifact@v2
       with:
         name: wheels
-        path: dist/opencv*.tar.gz
+        path: dist/opencv*.tar.xz
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
diff --git a/scripts/source-packages-preparation.sh b/scripts/source-packages-preparation.sh
new file mode 100755
index 00000000..be49b5b8
--- /dev/null
+++ b/scripts/source-packages-preparation.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# ${1} variable is a path to repository opencv-python
+
+# Define flags
+if [ "0" == $ENABLE_CONTRIB ]; then
+  git submodule update --init opencv
+  EXTRA_CMAKE_OPTIONS="-DOPENCV_DOWNLOAD_PATH=${1}/opencv/3rdparty"
+else
+  git submodule update --init opencv opencv_contrib
+  EXTRA_CMAKE_OPTIONS="-DOPENCV_DOWNLOAD_PATH=${1}/opencv/3rdparty -DOPENCV_EXTRA_MODULES_PATH=${1}/opencv_contrib/modules"
+fi
+
+# Download 3rdparty files
+cd opencv && \
+mkdir generate && \
+cd generate && \
+cmake $EXTRA_CMAKE_OPTIONS ${1}/opencv && \
+cd ${1} && \
+rm -rf opencv/generate
diff --git a/setup.py b/setup.py
index 5b79e389..c9f09212 100644
--- a/setup.py
+++ b/setup.py
@@ -162,6 +162,8 @@ def main():
             "-DPYTHON3_LIMITED_API=ON",
             "-DBUILD_OPENEXR=ON",
             "-DBUILD_PNG=ON",
+            # To have all 3rdparty files in one place for source packages
+            "-DOPENCV_DOWNLOAD_PATH=%s" % (os.path.join(os.path.dirname(os.path.abspath(__file__)), "opencv", "3rdparty")),
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64

From 7ba53fc4f48894593bda7493709d542e38e2c36d Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 25 Mar 2022 11:52:15 +0300
Subject: [PATCH 329/345] Revert changes for pre-downloaded files

---
 .github/workflows/build_wheels_linux.yml |  2 --
 scripts/source-packages-preparation.sh   | 20 --------------------
 setup.py                                 |  2 --
 3 files changed, 24 deletions(-)
 delete mode 100755 scripts/source-packages-preparation.sh

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 3e3e010b..a368661d 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -171,8 +171,6 @@ jobs:
 
     - name: Build a package
       run: |
-        # Download all 3rdparty files
-        source scripts/source-packages-preparation.sh ${{ github.workspace }}
         set -e
         # Build and package
         set -x
diff --git a/scripts/source-packages-preparation.sh b/scripts/source-packages-preparation.sh
deleted file mode 100755
index be49b5b8..00000000
--- a/scripts/source-packages-preparation.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-# ${1} variable is a path to repository opencv-python
-
-# Define flags
-if [ "0" == $ENABLE_CONTRIB ]; then
-  git submodule update --init opencv
-  EXTRA_CMAKE_OPTIONS="-DOPENCV_DOWNLOAD_PATH=${1}/opencv/3rdparty"
-else
-  git submodule update --init opencv opencv_contrib
-  EXTRA_CMAKE_OPTIONS="-DOPENCV_DOWNLOAD_PATH=${1}/opencv/3rdparty -DOPENCV_EXTRA_MODULES_PATH=${1}/opencv_contrib/modules"
-fi
-
-# Download 3rdparty files
-cd opencv && \
-mkdir generate && \
-cd generate && \
-cmake $EXTRA_CMAKE_OPTIONS ${1}/opencv && \
-cd ${1} && \
-rm -rf opencv/generate
diff --git a/setup.py b/setup.py
index c9f09212..5b79e389 100644
--- a/setup.py
+++ b/setup.py
@@ -162,8 +162,6 @@ def main():
             "-DPYTHON3_LIMITED_API=ON",
             "-DBUILD_OPENEXR=ON",
             "-DBUILD_PNG=ON",
-            # To have all 3rdparty files in one place for source packages
-            "-DOPENCV_DOWNLOAD_PATH=%s" % (os.path.join(os.path.dirname(os.path.abspath(__file__)), "opencv", "3rdparty")),
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64

From ad010427c7197033532b3f2238b273bb9a5513fb Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 25 Mar 2022 17:10:44 +0300
Subject: [PATCH 330/345] Skip only gapi if it was not found

---
 setup.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index c9f09212..2fbdc816 100644
--- a/setup.py
+++ b/setup.py
@@ -414,7 +414,8 @@ def _classify_installed_files_override(
                     final_install_relpaths.append(new_install_relpath)
                     del m, fslash_relpath, new_install_relpath
                 else:
-                    if not found:
+                    # gapi can be missed if ADE was not downloaded (network issue)
+                    if not found and "gapi" not in relpath_re:
                         raise Exception("Not found: '%s'" % relpath_re)
                 del r, found
 

From f68be384bb0310f1fdf95351fdffda7bf288b8d1 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 25 Mar 2022 17:10:44 +0300
Subject: [PATCH 331/345] Skip only gapi if it was not found

---
 setup.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 5b79e389..5784d5a4 100644
--- a/setup.py
+++ b/setup.py
@@ -412,7 +412,8 @@ def _classify_installed_files_override(
                     final_install_relpaths.append(new_install_relpath)
                     del m, fslash_relpath, new_install_relpath
                 else:
-                    if not found:
+                    # gapi can be missed if ADE was not downloaded (network issue)
+                    if not found and "gapi" not in relpath_re:
                         raise Exception("Not found: '%s'" % relpath_re)
                 del r, found
 

From 96cffde198e5bc3411a9577b97021ce59477f97a Mon Sep 17 00:00:00 2001
From: Yclept Nemo <pscjtwjdjtAhnbjm/dpn>
Date: Mon, 21 Mar 2022 15:06:30 -0400
Subject: [PATCH 332/345] Synchronize with scikit-build

scikit-build commit 94089992b353ea3e4b4c2f118ea1987ca54ecbb8:
skbuild/setuptools_wrap.py:_classify_installed_files
    cmake_install_dir -> _cmake_install_dir

This allows tracking scikit-build versions >= 0.13.2. The dependencies
file has been updated.
---
 pyproject.toml | 3 ++-
 setup.py       | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 6aaab1d3..a47525d5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,7 @@
 [build-system]
 requires = [
-  "setuptools", "wheel", "scikit-build", "cmake", "pip",
+  "setuptools", "wheel", "cmake", "pip",
+  "scikit-build>=0.13.2",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
diff --git a/setup.py b/setup.py
index 5b79e389..3714e9e3 100644
--- a/setup.py
+++ b/setup.py
@@ -451,7 +451,7 @@ def _classify_installed_files_override(
             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,
+            _cmake_install_dir=cmake_install_reldir,
         )
 
 

From 7419f5820ea9c4d2d816f484f1930f2eca23e9cb Mon Sep 17 00:00:00 2001
From: Niyas Sait <niyas.sait@linaro.org>
Date: Mon, 28 Mar 2022 10:13:56 +0100
Subject: [PATCH 333/345] add support for building windows/arm64 package

---
 setup.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/setup.py b/setup.py
index 5784d5a4..b5c5580a 100644
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,7 @@ def main():
     )
 
     # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
-    x64 = sys.maxsize > 2 ** 32
+    is64 = sys.maxsize > 2 ** 32
 
     package_name = "opencv-python"
 
@@ -88,7 +88,7 @@ def main():
     # 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 "")]
+            [r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if is64 else "")]
             if os.name == "nt"
             else []
         )
@@ -130,7 +130,7 @@ def main():
     files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]}
 
     ci_cmake_generator = (
-        ["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
+        ["-G", "Visual Studio 14" + (" Win64" if is64 else "")]
         if os.name == "nt"
         else ["-G", "Unix Makefiles"]
     )
@@ -164,9 +164,15 @@ def main():
             "-DBUILD_PNG=ON",
         ]
         + (
+            # CMake flags for windows/arm64 build
+            ["-DCMAKE_GENERATOR_PLATFORM=ARM64",
+             # Emulated cmake requires following flags to correctly detect
+             # target architecture for windows/arm64 build
+             "-DOPENCV_WORKAROUND_CMAKE_20989=ON",
+             "-DCMAKE_SYSTEM_PROCESSOR=ARM64"]
+            if platform.machine() == "ARM64" and sys.platform == "win32"
             # If it is not defined 'linker flags: /machine:X86' on Windows x64
-            ["-DCMAKE_GENERATOR_PLATFORM=x64"]
-            if x64 and sys.platform == "win32"
+            else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32"
             else []
           )
         + (
@@ -186,7 +192,7 @@ def main():
                 "-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:
+    if sys.platform.startswith("linux") and not is64 and "bdist_wheel" in sys.argv:
         subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
 
     # OS-specific components during CI builds

From 4b068fcba76c2d61a041ed87f7e36b8248b53397 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Thu, 7 Apr 2022 13:34:12 +0300
Subject: [PATCH 334/345] Pinned versions for dependencies

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index a47525d5..f237ddbc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [build-system]
 requires = [
-  "setuptools", "wheel", "cmake", "pip",
+  "setuptools==59.2.0", "wheel==0.37.0", "cmake==3.22.3", "pip",
   "scikit-build>=0.13.2",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",

From f89dca7a27c9ba9659b0b3091e4f64ac1c9bc13d Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 8 Apr 2022 10:01:04 +0300
Subject: [PATCH 335/345] Downgraded cmake version

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index f237ddbc..ade9bc2d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [build-system]
 requires = [
-  "setuptools==59.2.0", "wheel==0.37.0", "cmake==3.22.3", "pip",
+  "setuptools==59.2.0", "wheel==0.37.0", "cmake>=3.6.3", "pip",
   "scikit-build>=0.13.2",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",

From 443b747a4ee7ff8d23af221e0361d7f199d5c8ae Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Fri, 8 Apr 2022 10:30:35 +0300
Subject: [PATCH 336/345] Downgraded cmake version to 3.1

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index ade9bc2d..ff535e86 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [build-system]
 requires = [
-  "setuptools==59.2.0", "wheel==0.37.0", "cmake>=3.6.3", "pip",
+  "setuptools==59.2.0", "wheel==0.37.0", "cmake>=3.1", "pip",
   "scikit-build>=0.13.2",
   "numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
   "numpy==1.14.5; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",

From 3ac27ad2f3648e4c750a4c3230171713cd2d1edf Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 31 May 2022 01:23:49 +0300
Subject: [PATCH 337/345] Updated dependecies for the next release

---
 .github/workflows/build_wheels_linux.yml     |  4 +-
 .github/workflows/build_wheels_linux_arm.yml |  2 +-
 docker/manylinux2014/Dockerfile_aarch64      | 77 +++++++++++++++----
 docker/manylinux2014/Dockerfile_x86_64       | 79 ++++++++++++++++----
 setup.py                                     |  1 -
 travis_config.sh                             |  5 --
 6 files changed, 127 insertions(+), 41 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index a368661d..fac5ebad 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -39,7 +39,7 @@ jobs:
       MB_ML_VER: 2014
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       PLAT: x86_64
@@ -145,7 +145,7 @@ jobs:
       NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index a97bbc29..c58e0631 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -40,7 +40,7 @@ jobs:
       MB_ML_VER: 2014
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/asenyaev/manylinux2014_${PLAT}
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index b380d3ba..fedf1e98 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -2,29 +2,60 @@ FROM quay.io/pypa/manylinux2014_aarch64:latest
 
 ARG CCACHE_VERSION=3.7.9
 ARG FFMPEG_VERSION=4.4.1
+ARG FREETYPE_VERSION=2.12.1
+ARG LIBPNG_VERSION=1.6.37
 ARG NASM_VERSION=2.15.04
-ARG OPENSSL_VERSION=1_1_1m
+ARG OPENSSL_VERSION=1_1_1o
 ARG QT_VERSION=5.15.0
 ARG YASM_VERSION=1.3.0
 
-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
+ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
+
+# epel-release need for aarch64 to get openblas packages
+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 lapack-devel epel-release -y && \
+    yum install openblas-devel -y && \
+    cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
+    curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
+    # libpng will be built from source
+    yum remove libpng -y
+
+RUN mkdir ~/libpng_sources && \
+    cd ~/libpng_sources && \
+    curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \
+    tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \
+    cd libpng-${LIBPNG_VERSION} && \
+    ./configure --prefix=/usr/local && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf ~/libpng_sources
+
+RUN mkdir ~/freetype_sources && \
+    cd ~/freetype_sources && \
+    curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
+    tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
+    cd freetype-${FREETYPE_VERSION} && \
+    ./configure --prefix="$HOME/ffmpeg_build" --enable-freetype-config && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf ~/freetype_sources
 
 RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
     tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
-    cd qt-everywhere* && \
+    cd qt-everywhere-src-${QT_VERSION} && \
     export MAKEFLAGS=-j$(nproc) && \
     ./configure -prefix /opt/Qt${QT_VERSION} -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-${QT_VERSION} && \
-    rm qt-everywhere-src-${QT_VERSION}.tar.xz
+    rm -rf qt-everywhere*
 
 ENV QTDIR /opt/Qt${QT_VERSION}
 ENV PATH "$QTDIR/bin:$PATH"
 
-RUN mkdir ~/ffmpeg_sources && \
-    cd ~/ffmpeg_sources && \
+RUN mkdir ~/openssl_sources && \
+    cd ~/openssl_sources && \
     curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     cd openssl-OpenSSL_${OPENSSL_VERSION} && \
@@ -32,31 +63,40 @@ RUN mkdir ~/ffmpeg_sources && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \
-    rm -rf ~/openssl_build
+    cd .. && \
+    rm -rf ~/openssl_build ~/openssl_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/nasm_sources && \
+    cd ~/nasm_sources && \
     curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
     tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
-    make install
+    make install && \
+    cd .. && \
+    rm -rf ~/nasm_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/yasm_sources && \
+    cd ~/yasm_sources && \
     curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
     tar -xf yasm-${YASM_VERSION}.tar.gz && \
     cd yasm-${YASM_VERSION} && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
-    make install
+    make install && \
+    cd .. && \
+    rm -rf ~/yasm_sources
 
-RUN cd ~/ffmpeg_sources && \
-    git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
+RUN mkdir ~/libvpx_sources && \
+    cd ~/libvpx_sources && \
+    git clone --depth 1 https://github.com/webmproject/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 && \
+RUN mkdir ~/ffmpeg_sources && \
+    cd ~/ffmpeg_sources && \
     curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     cd ffmpeg-${FFMPEG_VERSION} && \
@@ -66,7 +106,8 @@ RUN cd ~/ffmpeg_sources && \
     make install && \
     echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
     ldconfig && \
-    rm -rf ~/ffmpeg_sources
+    rm -rf ~/ffmpeg_sources && \
+    yum remove bzip2-devel -y
 
 RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
     tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
@@ -75,6 +116,10 @@ RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERS
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install
 
+# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
+RUN mkdir /io && \
+    git config --global --add safe.directory /io
+
 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_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index fb367c0a..13325756 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,29 +1,60 @@
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
 ARG FFMPEG_VERSION=4.4.1
+ARG FREETYPE_VERSION=2.12.1
+ARG LIBPNG_VERSION=1.6.37
 ARG NASM_VERSION=2.15.04
-ARG OPENSSL_VERSION=1_1_1m
+ARG OPENSSL_VERSION=1_1_1o
 ARG QT_VERSION=5.15.0
 ARG YASM_VERSION=1.3.0
 
-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
+ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
+
+# epel-release need for aarch64 to get openblas packages
+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 lapack-devel epel-release -y && \
+    yum install openblas-devel -y && \
+    cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
+    curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
+    # libpng will be built from source
+    yum remove libpng -y
+
+RUN mkdir ~/libpng_sources && \
+    cd ~/libpng_sources && \
+    curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \
+    tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \
+    cd libpng-${LIBPNG_VERSION} && \
+    ./configure --prefix=/usr/local && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf ~/libpng_sources
+
+RUN mkdir ~/freetype_sources && \
+    cd ~/freetype_sources && \
+    curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
+    tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
+    cd freetype-${FREETYPE_VERSION} && \
+    ./configure --prefix="$HOME/ffmpeg_build" --enable-freetype-config && \
+    make && \
+    make install && \
+    cd .. && \
+    rm -rf ~/freetype_sources
 
 RUN curl -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
     tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
-    cd qt-everywhere* && \
+    cd qt-everywhere-src-${QT_VERSION} && \
     export MAKEFLAGS=-j$(nproc) && \
     ./configure -prefix /opt/Qt${QT_VERSION} -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-${QT_VERSION} && \
-    rm qt-everywhere-src-${QT_VERSION}.tar.xz
+    rm -rf qt-everywhere*
 
 ENV QTDIR /opt/Qt${QT_VERSION}
 ENV PATH "$QTDIR/bin:$PATH"
 
-RUN mkdir ~/ffmpeg_sources && \
-    cd ~/ffmpeg_sources && \
+RUN mkdir ~/openssl_sources && \
+    cd ~/openssl_sources && \
     curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     cd openssl-OpenSSL_${OPENSSL_VERSION} && \
@@ -31,31 +62,42 @@ RUN mkdir ~/ffmpeg_sources && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \
-    rm -rf ~/openssl_build
+    cd .. && \
+    rm -rf ~/openssl_build ~/openssl_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/nasm_sources && \
+    cd ~/nasm_sources && \
     curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
     tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
-    make install
+    make install && \
+    cd .. && \
+    rm -rf ~/nasm_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/yasm_sources && \
+    cd ~/yasm_sources && \
     curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
     tar -xf yasm-${YASM_VERSION}.tar.gz && \
     cd yasm-${YASM_VERSION} && \
     ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
-    make install
+    make install && \
+    cd .. && \
+    rm -rf ~/yasm_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/libvpx_sources && \
+    cd ~/libvpx_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
+    make install && \
+    cd .. && \
+    rm -rf ~/libvpx_sources
 
-RUN cd ~/ffmpeg_sources && \
+RUN mkdir ~/ffmpeg_sources && \
+    cd ~/ffmpeg_sources && \
     curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     cd ffmpeg-${FFMPEG_VERSION} && \
@@ -65,7 +107,12 @@ RUN cd ~/ffmpeg_sources && \
     make install && \
     echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
     ldconfig && \
-    rm -rf ~/ffmpeg_sources
+    rm -rf ~/ffmpeg_sources && \
+    yum remove bzip2-devel -y
+
+# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
+RUN mkdir /io && \
+    git config --global --add safe.directory /io
 
 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
 ENV LDFLAGS -L/root/ffmpeg_build/lib
diff --git a/setup.py b/setup.py
index 02d991b9..e9255907 100644
--- a/setup.py
+++ b/setup.py
@@ -161,7 +161,6 @@ def main():
             "-DBUILD_DOCS=OFF",
             "-DPYTHON3_LIMITED_API=ON",
             "-DBUILD_OPENEXR=ON",
-            "-DBUILD_PNG=ON",
         ]
         + (
             # If it is not defined 'linker flags: /machine:X86' on Windows x64
diff --git a/travis_config.sh b/travis_config.sh
index 4560f726..366d35ad 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -98,11 +98,6 @@ function pre_build {
 
   if [ -n "$IS_OSX" ]; then
     brew install lapack
-  else
-    # epel-release need for aarch64 to get openblas packages
-    yum install -y lapack-devel epel-release && yum install -y openblas-devel
-    cp /usr/include/lapacke/lapacke*.h /usr/include/
-    curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h
   fi
 
   if [ -n "$IS_OSX" ]; then

From 4f8289d4627a42621303d9fce6f46b630950186e Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 31 May 2022 10:48:58 +0300
Subject: [PATCH 338/345] Updated dependecies for the next release

---
 docker/manylinux2014/Dockerfile_aarch64 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index fedf1e98..03889a51 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -93,7 +93,9 @@ RUN mkdir ~/libvpx_sources && \
     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
+    make install && \
+    cd .. && \
+    rm -rf ~/libvpx_sources
 
 RUN mkdir ~/ffmpeg_sources && \
     cd ~/ffmpeg_sources && \
@@ -114,7 +116,9 @@ RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERS
     cd ccache-${CCACHE_VERSION} && \
     linux32 ./configure && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
-    make install
+    make install && \
+    cd .. && \
+    rm -rf ccache-${CCACHE_VERSION}.tar.gz
 
 # Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
 RUN mkdir /io && \

From 9ec924e1818c9ee755458cb8ac71fd2475d0153d Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 31 May 2022 13:31:34 +0300
Subject: [PATCH 339/345] Updated submodules to the latest commits

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 opencv_extra   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opencv b/opencv
index dad26339..d6151eae 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit dad26339a975b49cfb6c7dbe4bd5276c9dcb36e2
+Subproject commit d6151eae23aebdb3fce524a86026c2753daed685
diff --git a/opencv_contrib b/opencv_contrib
index 49e8f123..84f8ea8e 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 49e8f123ca08e76891856a1ecce491b62d08ba20
+Subproject commit 84f8ea8e99f98d8ab7868dbd29cccb6bdd26fb94
diff --git a/opencv_extra b/opencv_extra
index 37294e3c..c2cf721e 160000
--- a/opencv_extra
+++ b/opencv_extra
@@ -1 +1 @@
-Subproject commit 37294e3c876a72c992d4718b9bbfc8346b9e779a
+Subproject commit c2cf721e3b8ce535900bc0f97a5cd17efb35361e

From df365e5d8ca5cc0b4b29e26fdcc1837a38e8318e Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 31 May 2022 13:33:43 +0300
Subject: [PATCH 340/345] Check changes on 3.4 branch in PRs

---
 .github/workflows/build_wheels_linux.yml     | 1 +
 .github/workflows/build_wheels_linux_arm.yml | 1 +
 .github/workflows/build_wheels_macos.yml     | 1 +
 .github/workflows/build_wheels_macos_m1.yml  | 1 +
 .github/workflows/build_wheels_windows.yml   | 1 +
 5 files changed, 5 insertions(+)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index fac5ebad..362001fb 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -4,6 +4,7 @@ on:
   pull_request:
     branches:
       - master
+      - 3.4
     paths-ignore:
       - '.github/workflows/build_wheels_linux_arm.yml'
       - '.github/workflows/build_wheels_windows*'
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index c58e0631..a892040b 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -4,6 +4,7 @@ on:
   pull_request:
     branches:
       - master
+      - 3.4
     paths-ignore:
       - '.github/workflows/build_wheels_linux.yml'
       - '.github/workflows/build_wheels_windows*'
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index bccec01f..c453ab85 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -4,6 +4,7 @@ on:
   pull_request:
     branches:
       - master
+      - 3.4
     paths-ignore:
       - '.github/workflows/build_wheels_linux*'
       - '.github/workflows/build_wheels_windows*'
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 9f7b0f37..1ac065f1 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -4,6 +4,7 @@ on:
   pull_request:
     branches:
       - master
+      - 3.4
     paths-ignore:
       - '.github/workflows/build_wheels_linux*'
       - '.github/workflows/build_wheels_windows*'
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 337c77b2..0dad17b5 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -4,6 +4,7 @@ on:
   pull_request:
     branches:
       - master
+      - 3.4
     paths-ignore:
       - '.github/workflows/build_wheels_linux*'
       - '.github/workflows/build_wheels_macos*'

From 5633cf319efadb628e8369b48834d74491c10b1a Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Tue, 31 May 2022 14:09:35 +0300
Subject: [PATCH 341/345] Removed unused lines

---
 setup.py | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/setup.py b/setup.py
index 37366d9a..11014d6b 100644
--- a/setup.py
+++ b/setup.py
@@ -374,21 +374,6 @@ def _classify_installed_files_override(
 
         print("Copying files from CMake output")
 
-        # lines for a proper work using pylint and an autocomplete in IDE
-        with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'r') as opencv_init:
-            opencv_init_lines = opencv_init.readlines()
-            extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi'
-                             '\nfrom . import misc\nfrom . import utils\nfrom . import data\nfrom . import version\n')
-            free_line_after_imports = 6
-            opencv_init_lines.insert(free_line_after_imports, extra_imports)
-            opencv_init_data = ""
-            for line in opencv_init_lines:
-                opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
-                opencv_init_data = opencv_init_data + opencv_init_replacement
-
-        with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'w') as opencv_final_init:
-            opencv_final_init.write(opencv_init_data)
-
         # add lines from the old __init__.py file to the config file
         with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
             custom_init_data = custom_init.read()

From 04b1a52ac69811a33db2fb2110a03b2971c110e5 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Mon, 6 Jun 2022 00:48:04 +0300
Subject: [PATCH 342/345] Updated submodules to 4.6.0 release

---
 opencv         | 2 +-
 opencv_contrib | 2 +-
 opencv_extra   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opencv b/opencv
index d6151eae..b0dc4741 160000
--- a/opencv
+++ b/opencv
@@ -1 +1 @@
-Subproject commit d6151eae23aebdb3fce524a86026c2753daed685
+Subproject commit b0dc474160e389b9c9045da5db49d03ae17c6a6b
diff --git a/opencv_contrib b/opencv_contrib
index 84f8ea8e..db16caf6 160000
--- a/opencv_contrib
+++ b/opencv_contrib
@@ -1 +1 @@
-Subproject commit 84f8ea8e99f98d8ab7868dbd29cccb6bdd26fb94
+Subproject commit db16caf6ceee76b43b94c846be276e92a43e9700
diff --git a/opencv_extra b/opencv_extra
index c2cf721e..936854e2 160000
--- a/opencv_extra
+++ b/opencv_extra
@@ -1 +1 @@
-Subproject commit c2cf721e3b8ce535900bc0f97a5cd17efb35361e
+Subproject commit 936854e2b666853d6d0732a8eabc2d699f4fa3d8

From 8d045058df0245039a8a8754d140a820548dedb8 Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <andrey.senyaev@gmail.com>
Date: Wed, 8 Jun 2022 13:36:57 +0300
Subject: [PATCH 343/345] Changed format of an archive for source packages

---
 .github/workflows/build_wheels_linux.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 362001fb..5315e161 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -177,7 +177,7 @@ jobs:
         set -x
           python -m pip install --upgrade pip
           python -m pip install scikit-build
-          python setup.py sdist --formats=xztar
+          python setup.py sdist --formats=gztar
         set +x
         # Install and run tests
         set -x
@@ -187,7 +187,7 @@ jobs:
       uses: actions/upload-artifact@v2
       with:
         name: wheels
-        path: dist/opencv*.tar.xz
+        path: dist/opencv*.tar.gz
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease

From 54473f17f7c138d4632b003a5e6f736e80481572 Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Fri, 24 Jun 2022 22:09:56 +1000
Subject: [PATCH 344/345] Updated multibuild to upgrade default 64-bit test
 image to focal

---
 .gitmodules | 2 +-
 multibuild  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 655467e8..7193d3b9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,7 +6,7 @@
 	url = https://github.com/opencv/opencv_contrib.git
 [submodule "multibuild"]
 	path = multibuild
-	url = https://github.com/matthew-brett/multibuild.git
+	url = https://github.com/multi-build/multibuild.git
 [submodule "opencv_extra"]
 	path = opencv_extra
 	url = https://github.com/opencv/opencv_extra.git
diff --git a/multibuild b/multibuild
index b89bb903..bce1637e 160000
--- a/multibuild
+++ b/multibuild
@@ -1 +1 @@
-Subproject commit b89bb903e94308be79abefa4f436bf123ebb1313
+Subproject commit bce1637e202cb52b0e7ea42baa1cccc894b82806

From 4638ce51fa4ce1b8a8752acdb2320a8b328d275f Mon Sep 17 00:00:00 2001
From: Andrey Senyaev <76472231+asenyaev@users.noreply.github.com>
Date: Mon, 4 Jul 2022 16:08:39 +0300
Subject: [PATCH 345/345] Changed labeles for macOS ARM64 and Linux ARM64
 builds (#681)

* Changed labeles for macOS ARM64 and Linux ARM64 builds

* Changed labeles for macOS ARM64 and Linux ARM64 builds

* Added proper cleanup step for all workflows, removed unused lines, changed ubuntu-latest to ubuntu-20.04

* Updated docker images to work under non-root user, unified cleanup step
---
 .github/workflows/build_wheels_linux.yml     | 53 +++++++-------------
 .github/workflows/build_wheels_linux_arm.yml | 41 ++++-----------
 .github/workflows/build_wheels_macos.yml     | 31 +++---------
 .github/workflows/build_wheels_macos_m1.yml  | 31 ++++--------
 .github/workflows/build_wheels_windows.yml   | 51 +++++++------------
 docker/manylinux2014/Dockerfile_aarch64      | 35 +++++++++----
 docker/manylinux2014/Dockerfile_x86_64       | 45 +++++++++++++----
 7 files changed, 121 insertions(+), 166 deletions(-)

diff --git a/.github/workflows/build_wheels_linux.yml b/.github/workflows/build_wheels_linux.yml
index 5315e161..98ad3dc8 100644
--- a/.github/workflows/build_wheels_linux.yml
+++ b/.github/workflows/build_wheels_linux.yml
@@ -15,21 +15,18 @@ on:
 
 jobs:
   build:
-    runs-on: ${{ matrix.os }}
+    runs-on: ubuntu-20.04
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest]
         python-version: ['3.6']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       REPO_DIR: .
@@ -40,34 +37,32 @@ jobs:
       MB_ML_VER: 2014
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
-      USE_CCACHE: 1
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220628
+      USE_CCACHE: 0
       UNICODE_WIDTH: 32
       PLAT: x86_64
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Update submodules
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
-
     - name: Build a package
       run: source scripts/build.sh
-
     - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
-
     - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
@@ -76,21 +71,18 @@ jobs:
 
   test:
     needs: [build]
-    runs-on: ${{ matrix.os }}
+    runs-on: ubuntu-20.04
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest]
         python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
@@ -98,42 +90,38 @@ jobs:
       NP_TEST_DEP_LATEST: numpy==1.21.2
       CONFIG_PATH: travis_config.sh
       PLAT: x86_64
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: true
         fetch-depth: 0
-
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
     - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
         name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
-
     - name: Package installation and run tests
       run: source scripts/install.sh
 
   build_sdist:
-    runs-on: ${{ matrix.os }}
+    runs-on: ubuntu-20.04
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest]
         python-version: [3.8]
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [1]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       REPO_DIR: .
@@ -146,30 +134,29 @@ jobs:
       NP_TEST_DEP: numpy==1.19.4
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220628
       USE_CCACHE: 1
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui || 0 }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib || 0 }}
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Update submodules
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
-
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
-
     - name: Build a package
       run: |
         set -e
@@ -182,7 +169,6 @@ jobs:
         # Install and run tests
         set -x
         echo "skipping tests because of sdist"
-
     - name: saving artifacts
       uses: actions/upload-artifact@v2
       with:
@@ -192,7 +178,7 @@ jobs:
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build, build_sdist, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: test-opencv-python-release
     defaults:
       run:
@@ -202,7 +188,6 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload all wheels
         run: |
           python -m pip install twine
@@ -211,7 +196,7 @@ jobs:
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build, build_sdist, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: opencv-python-release
     defaults:
       run:
@@ -221,22 +206,18 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-* wheelhouse/opencv-python-[^h]*
-
       - name: Upload wheels for opencv_contrib_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-* wheelhouse/opencv-contrib-python-[^h]*
-
       - name: Upload wheels for opencv_python_headless
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-* wheelhouse/opencv-python-headless-*
-
       - name: Upload wheels for opencv_contrib_python_headless
         run: |
           python -m pip install twine
diff --git a/.github/workflows/build_wheels_linux_arm.yml b/.github/workflows/build_wheels_linux_arm.yml
index a892040b..4d0c3daf 100644
--- a/.github/workflows/build_wheels_linux_arm.yml
+++ b/.github/workflows/build_wheels_linux_arm.yml
@@ -15,21 +15,18 @@ on:
 
 jobs:
   build_arm:
-    runs-on: ${{ matrix.os }}
+    runs-on: opencv-cn-lin-arm64
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
-        os: [ARM64]
         python-version: ['3.6']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       REPO_DIR: .
@@ -41,33 +38,30 @@ jobs:
       MB_ML_VER: 2014
       TRAVIS_BUILD_DIR: ${{ github.workspace }}
       CONFIG_PATH: travis_config.sh
-      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014:${PLAT}
+      DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64:20220628
       USE_CCACHE: 0
       UNICODE_WIDTH: 32
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
     steps:
+    - name: UID
+      run: id -u
     - name: Cleanup
-      if: always()
-      uses: AutoModality/action-clean@v1
-
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Build a package
       run: source scripts/build.sh
-
     - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
-
     - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
@@ -76,21 +70,18 @@ jobs:
 
   test:
     needs: [build_arm]
-    runs-on: ${{ matrix.os }}
+    runs-on: opencv-cn-lin-arm64
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
-        os: [ARM64]
         python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
@@ -100,34 +91,29 @@ jobs:
       CONFIG_PATH: travis_config.sh
       DOCKER_TEST_IMAGE: multibuild/focal_arm64v8
       UNICODE_WIDTH: 32
-
     steps:
     - name: Cleanup
-      if: always()
-      uses: AutoModality/action-clean@v1
-
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: true
         fetch-depth: 0
-
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
     - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
         name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
-
     - name: Package installation and run tests
       run: source scripts/install.sh
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build_arm, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: test-opencv-python-release
     defaults:
       run:
@@ -137,7 +123,6 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload all wheels
         run: |
           python -m pip install twine
@@ -146,7 +131,7 @@ jobs:
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build_arm, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: opencv-python-release
     defaults:
       run:
@@ -156,22 +141,18 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
-
       - name: Upload wheels for opencv_contrib_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
-
       - name: Upload wheels for opencv_python_headless
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
-
       - name: Upload wheels for opencv_contrib_python_headless
         run: |
           python -m pip install twine
diff --git a/.github/workflows/build_wheels_macos.yml b/.github/workflows/build_wheels_macos.yml
index c453ab85..af892101 100644
--- a/.github/workflows/build_wheels_macos.yml
+++ b/.github/workflows/build_wheels_macos.yml
@@ -19,7 +19,6 @@ jobs:
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
@@ -40,7 +39,6 @@ jobs:
             python-version: '3.8'
           - os: macos-11
             python-version: '3.9'
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       REPO_DIR: .
@@ -60,18 +58,18 @@ jobs:
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Update submodules
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
-
     - name: Build a package
       run: |
         set -e
@@ -89,13 +87,11 @@ jobs:
         echo $ENABLE_HEADLESS > headless.enabled
         set -x
         build_wheel $REPO_DIR $PLAT
-
     - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
-
     - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
@@ -108,7 +104,6 @@ jobs:
     defaults:
       run:
         shell: bash
-
     strategy:
       fail-fast: false
       matrix:
@@ -129,7 +124,6 @@ jobs:
             python-version: '3.8'
           - os: macos-11
             python-version: '3.9'
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       MB_PYTHON_VERSION: ${{ matrix.python-version }}
@@ -139,40 +133,36 @@ jobs:
       PLAT: x86_64
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
       PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: true
         fetch-depth: 0
-
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
-
     - name: Setup Environment variables
       run: if [ "3.10" == "${{ matrix.python-version }}" ]; then echo "TEST_DEPENDS=$(echo $NP_TEST_DEP_LATEST)" >> $GITHUB_ENV; else echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV; fi
-
     - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
         name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
-
     - name: Package installation
       run: |
         python -m pip install wheelhouse/opencv*.whl
         cd ${{ github.workspace }}/tests
         python get_build_info.py
-
     - name: Run tests
       run: |
         cd ${{ github.workspace }}/opencv
         python modules/python/test/test.py -v --repo .
-
     - name: Pylint test
       run: |
         python -m pip install pylint==2.12.2
@@ -182,7 +172,7 @@ jobs:
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: test-opencv-python-release
     defaults:
       run:
@@ -192,7 +182,6 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload all wheels
         run: |
           python -m pip install twine
@@ -201,7 +190,7 @@ jobs:
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: opencv-python-release
     defaults:
       run:
@@ -211,22 +200,18 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
-
       - name: Upload wheels for opencv_contrib_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
-
       - name: Upload wheels for opencv_python_headless
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
-
       - name: Upload wheels for opencv_contrib_python_headless
         run: |
           python -m pip install twine
diff --git a/.github/workflows/build_wheels_macos_m1.yml b/.github/workflows/build_wheels_macos_m1.yml
index 1ac065f1..a1d7c924 100644
--- a/.github/workflows/build_wheels_macos_m1.yml
+++ b/.github/workflows/build_wheels_macos_m1.yml
@@ -15,35 +15,32 @@ on:
 
 jobs:
   build:
-    runs-on: ${{ matrix.os }}
-
+    runs-on: opencv-cn-mac-arm64
     strategy:
       fail-fast: false
       matrix:
-        os: [macOS-M1]
         python-version: ['3.7']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       CI_BUILD: 1
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Update submodules
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
-
     - name: Build a package
       run: |
         git submodule update --init multibuild
@@ -53,13 +50,11 @@ jobs:
         arch -arm64 python${{ matrix.python-version }} -m pip install toml && python${{ matrix.python-version }} -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | python${{ matrix.python-version }} -m pip install -r /dev/stdin
         arch -arm64 python${{ matrix.python-version }} setup.py bdist_wheel --py-limited-api=cp37 --dist-dir=wheelhouse -v
         delocate-wheel ${{ github.workspace }}/wheelhouse/opencv*
-
     - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
-
     - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
@@ -68,46 +63,41 @@ jobs:
 
   test:
     needs: [build]
-    runs-on: ${{ matrix.os }}
-
+    runs-on: opencv-cn-mac-arm64-tests
     strategy:
       fail-fast: false
       matrix:
-        os: [macOS-M1]
         python-version: ['3.7', '3.8', '3.9', '3.10']
         platform: [x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
       PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
-
     steps:
+    - name: Cleanup
+      run: find . -mindepth 1 -delete
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: true
         fetch-depth: 0
-
     - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
         name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
         path: wheelhouse/
-
     - name: Package installation
       run: |
         arch -arm64 python${{ matrix.python-version }} -m pip install --user --no-cache --force-reinstall wheelhouse/opencv*.whl
         cd ${{ github.workspace }}/tests
         arch -arm64 python${{ matrix.python-version }} get_build_info.py
-
     - name: Run tests
       run: |
         cd ${{ github.workspace }}/opencv
         arch -arm64 python${{ matrix.python-version }} modules/python/test/test.py -v --repo .
-
     - name: Pylint test
       run: |
         arch -arm64 python${{ matrix.python-version }} -m pip install pylint==2.12.2
@@ -117,7 +107,7 @@ jobs:
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: test-opencv-python-release
     defaults:
       run:
@@ -136,7 +126,7 @@ jobs:
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: opencv-python-release
     defaults:
       run:
@@ -146,7 +136,6 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
diff --git a/.github/workflows/build_wheels_windows.yml b/.github/workflows/build_wheels_windows.yml
index 0dad17b5..087efc04 100644
--- a/.github/workflows/build_wheels_windows.yml
+++ b/.github/workflows/build_wheels_windows.yml
@@ -14,48 +14,43 @@ on:
 
 jobs:
   build-windows-x86_64:
-    runs-on: ${{ matrix.os }}
-    defaults:
-      run:
-        shell: powershell
-
+    runs-on: windows-2019
     strategy:
       fail-fast: false
       matrix:
-        os: [windows-2019]
         python-version: ['3.6']
         platform: [x86, x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       SDIST: ${{ matrix.build_sdist || 0 }}
       ENABLE_HEADLESS: ${{ matrix.without_gui }}
       ENABLE_CONTRIB: ${{ matrix.with_contrib }}
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
-
     steps:
+    - name: Cleanup
+      shell: bash
+      run: |
+        rm -rf ./* || true
+        rm -rf ./.??* || true
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: false
         fetch-depth: 0
-
     - name: Update submodules
       if: github.event_name == 'pull_request'
       run: git submodule update --remote
-
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
-
     - name: Setup MSBuild.exe
       uses: microsoft/setup-msbuild@v1.1
-
     - name: Build a package
       run: |
         python --version
@@ -64,13 +59,11 @@ jobs:
         python -m pip install toml && python -c "import toml; c = toml.load('pyproject.toml'); print('\n'.join(c['build-system']['requires']))" >> requirements.txt | python -m pip install -r requirements.txt
         set "CI_BUILD=1" && python setup.py bdist_wheel --py-limited-api=cp36 --dist-dir=%cd%\wheelhouse -v
       shell: cmd
-
     - name: Saving all wheels
       uses: actions/upload-artifact@v2
       with:
         name: wheels
         path: wheelhouse/opencv*.whl
-
     - name: Saving a wheel accordingly to matrix
       uses: actions/upload-artifact@v2
       with:
@@ -79,45 +72,44 @@ jobs:
 
   test:
     needs: [build-windows-x86_64]
-    runs-on: ${{ matrix.os }}
+    runs-on: windows-2019
     defaults:
       run:
-        shell: powershell
-
+        shell: cmd
     strategy:
       fail-fast: false
       matrix:
-        os: [windows-2019]
         python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
         platform: [x86, x64]
         with_contrib: [0, 1]
         without_gui: [0, 1]
         build_sdist: [0]
-
     env:
       ACTIONS_ALLOW_UNSECURE_COMMANDS: true
       OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
       PYLINT_TEST_FILE: ${{ github.workspace }}\opencv\samples\python\squares.py
-
     steps:
+    - name: Cleanup
+      shell: bash
+      run: |
+        rm -rf ./* || true
+        rm -rf ./.??* || true
+      working-directory: ${{ github.workspace }}
     - name: Checkout
       uses: actions/checkout@v2
       with:
         submodules: true
         fetch-depth: 0
-
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
         architecture: ${{ matrix.platform }}
-
     - name: Download a wheel accordingly to matrix
       uses: actions/download-artifact@v2
       with:
         name: wheel-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}-${{ matrix.platform }}
         path: wheelhouse/
-
     - name: Package installation
       run: |
         cd ${{ github.workspace }}/tests
@@ -125,24 +117,20 @@ jobs:
         if ($LastExitCode -ne 0) {throw $LastExitCode}
         python get_build_info.py
       shell: powershell
-
     - name: Run tests
       run: |
         cd ${{ github.workspace }}/opencv
         python modules\python\test\test.py -v --repo .
-      shell: cmd
-
     - name: Pylint test
       run: |
         python -m pip install pylint==2.12.2
         cd ${{ github.workspace }}\tests
         python -m pylint $PYLINT_TEST_FILE
-      shell: cmd
 
   test_release_opencv_python:
     if: github.event_name == 'release' && github.event.release.prerelease
     needs: [build-windows-x86_64, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: test-opencv-python-release
     defaults:
       run:
@@ -152,7 +140,6 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload all wheels
         run: |
           python -m pip install twine
@@ -161,7 +148,7 @@ jobs:
   release_opencv_python:
     if: github.event_name == 'release' && !github.event.release.prerelease
     needs: [build-windows-x86_64, test]
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     environment: opencv-python-release
     defaults:
       run:
@@ -171,22 +158,18 @@ jobs:
         with:
           name: wheels
           path: wheelhouse/
-
       - name: Upload wheels for opencv_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_python-*
-
       - name: Upload wheels for opencv_contrib_python
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_CONTRIB_PYTHON_USERNAME }} -p ${{ secrets.OPENCV_CONTRIB_PYTHON_PASSWORD }} --skip-existing wheelhouse/opencv_contrib_python-*
-
       - name: Upload wheels for opencv_python_headless
         run: |
           python -m pip install twine
           python -m twine upload -u ${{ secrets.OPENCV_PYTHON_HEADLESS_USERNAME }} -p ${{ secrets.OPENCV_PYTHON_HEADLESS_PASSWORD }} --skip-existing wheelhouse/opencv_python_headless-*
-
       - name: Upload wheels for opencv_contrib_python_headless
         run: |
           python -m pip install twine
diff --git a/docker/manylinux2014/Dockerfile_aarch64 b/docker/manylinux2014/Dockerfile_aarch64
index 03889a51..2679cbbf 100644
--- a/docker/manylinux2014/Dockerfile_aarch64
+++ b/docker/manylinux2014/Dockerfile_aarch64
@@ -1,3 +1,6 @@
+# Version: 20220628
+# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64
+
 FROM quay.io/pypa/manylinux2014_aarch64:latest
 
 ARG CCACHE_VERSION=3.7.9
@@ -35,7 +38,7 @@ RUN mkdir ~/freetype_sources && \
     curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
     tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
     cd freetype-${FREETYPE_VERSION} && \
-    ./configure --prefix="$HOME/ffmpeg_build" --enable-freetype-config && \
+    ./configure --prefix="/ffmpeg_build" --enable-freetype-config && \
     make && \
     make install && \
     cd .. && \
@@ -59,7 +62,7 @@ RUN mkdir ~/openssl_sources && \
     curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     cd openssl-OpenSSL_${OPENSSL_VERSION} && \
-    ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
+    ./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \
@@ -70,7 +73,7 @@ RUN mkdir ~/nasm_sources && \
     cd ~/nasm_sources && \
     curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
     tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
-    ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
+    ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -81,7 +84,7 @@ RUN mkdir ~/yasm_sources && \
     curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
     tar -xf yasm-${YASM_VERSION}.tar.gz && \
     cd yasm-${YASM_VERSION} && \
-    ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
+    ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -91,7 +94,7 @@ RUN mkdir ~/libvpx_sources && \
     cd ~/libvpx_sources && \
     git clone --depth 1 https://github.com/webmproject/libvpx.git && \
     cd libvpx && \
-    ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
+    ./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -103,10 +106,10 @@ RUN mkdir ~/ffmpeg_sources && \
     tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     cd ffmpeg-${FFMPEG_VERSION} && \
     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" && \
+    PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/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 && \
+    echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
     ldconfig && \
     rm -rf ~/ffmpeg_sources && \
     yum remove bzip2-devel -y
@@ -120,10 +123,20 @@ RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERS
     cd .. && \
     rm -rf ccache-${CCACHE_VERSION}.tar.gz
 
+# Self-hosted runner UID is 1004
+RUN useradd ci -m -s /bin/bash -G users --uid=1004 && \
+    mkdir /io && \
+    chown -R ci:ci /io && \
+    # This needs to find ffmpeg packages from ci user
+    chown -R ci:ci /ffmpeg_build && \
+    # This calls in mutlibuild scripts and cannot be run without permissions
+    chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel
+
+USER ci
+
 # Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
-RUN mkdir /io && \
-    git config --global --add safe.directory /io
+RUN git config --global --add safe.directory /io
 
-ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
-ENV LDFLAGS -L/root/ffmpeg_build/lib
+ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig
+ENV LDFLAGS -L/ffmpeg_build/lib
 ENV PATH "$HOME/bin:$PATH"
diff --git a/docker/manylinux2014/Dockerfile_x86_64 b/docker/manylinux2014/Dockerfile_x86_64
index 13325756..8bb77341 100644
--- a/docker/manylinux2014/Dockerfile_x86_64
+++ b/docker/manylinux2014/Dockerfile_x86_64
@@ -1,5 +1,9 @@
+# Version: 20220628
+# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64
+
 FROM quay.io/pypa/manylinux2014_x86_64:latest
 
+ARG CCACHE_VERSION=3.7.9
 ARG FFMPEG_VERSION=4.4.1
 ARG FREETYPE_VERSION=2.12.1
 ARG LIBPNG_VERSION=1.6.37
@@ -34,7 +38,7 @@ RUN mkdir ~/freetype_sources && \
     curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \
     tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \
     cd freetype-${FREETYPE_VERSION} && \
-    ./configure --prefix="$HOME/ffmpeg_build" --enable-freetype-config && \
+    ./configure --prefix="/ffmpeg_build" --enable-freetype-config && \
     make && \
     make install && \
     cd .. && \
@@ -58,7 +62,7 @@ RUN mkdir ~/openssl_sources && \
     curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \
     cd openssl-OpenSSL_${OPENSSL_VERSION} && \
-    ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
+    ./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     # skip installing documentation
     make install_sw && \
@@ -69,7 +73,7 @@ RUN mkdir ~/nasm_sources && \
     cd ~/nasm_sources && \
     curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
     tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
-    ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
+    ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -80,7 +84,7 @@ RUN mkdir ~/yasm_sources && \
     curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \
     tar -xf yasm-${YASM_VERSION}.tar.gz && \
     cd yasm-${YASM_VERSION} && \
-    ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
+    ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -90,7 +94,7 @@ RUN mkdir ~/libvpx_sources && \
     cd ~/libvpx_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 && \
+    ./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
     make -j$(getconf _NPROCESSORS_ONLN) && \
     make install && \
     cd .. && \
@@ -102,18 +106,37 @@ RUN mkdir ~/ffmpeg_sources && \
     tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
     cd ffmpeg-${FFMPEG_VERSION} && \
     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" && \
+    PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/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 && \
+    echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
     ldconfig && \
     rm -rf ~/ffmpeg_sources && \
     yum remove bzip2-devel -y
 
+RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
+    tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
+    cd ccache-${CCACHE_VERSION} && \
+    ./configure && \
+    make -j$(getconf _NPROCESSORS_ONLN) && \
+    make install && \
+    cd .. && \
+    rm -rf ccache-${CCACHE_VERSION}.tar.gz
+
+# GitHub Actions user`s UID is 1001
+RUN useradd ci -m -s /bin/bash -G users --uid=1001 && \
+    mkdir /io && \
+    chown -R ci:ci /io && \
+    # This needs to find ffmpeg packages from ci user
+    chown -R ci:ci /ffmpeg_build && \
+    # This calls in mutlibuild scripts and cannot be run without permissions
+    chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel
+
+USER ci
+
 # Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced
-RUN mkdir /io && \
-    git config --global --add safe.directory /io
+RUN git config --global --add safe.directory /io
 
-ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
-ENV LDFLAGS -L/root/ffmpeg_build/lib
+ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig
+ENV LDFLAGS -L/ffmpeg_build/lib
 ENV PATH "$HOME/bin:$PATH"
