Skip to content

Commit 7a0c346

Browse files
committed
merge master to 3.4
2 parents 928952d + c001042 commit 7a0c346

File tree

5 files changed

+147
-35
lines changed

5 files changed

+147
-35
lines changed

README.md

+25-23
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22

33
## OpenCV on Wheels
44

5-
**Unofficial** pre-built OpenCV packages for Python.
5+
**Unofficial** pre-built CPU-only OpenCV packages for Python.
6+
7+
Check the manual build section if you wish to compile the bindings from source to enable additional modules such as CUDA.
68

79
### Installation and Usage
810

911
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.
10-
2. Select the correct package for your environment:
12+
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.
13+
3. Select the correct package for your environment:
1114

12-
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.
15+
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.
1316

1417
**a.** Packages for standard desktop environments (Windows, macOS, almost any GNU/Linux distribution)
1518

16-
- run ``pip install opencv-python`` if you need only main modules
17-
- 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/))
19+
- Option 1 - Main modules package: ``pip install opencv-python``
20+
- 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/))
1821

19-
**b.** Packages for server (headless) environments
22+
**b.** Packages for server (headless) environments (such as Docker, cloud environments etc.), no GUI library dependencies
2023

21-
These packages do not contain any GUI functionality. They are smaller and suitable for more restricted environments.
24+
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.
2225

23-
- run ``pip install opencv-python-headless`` if you need only main modules
24-
- 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/))
26+
- Option 3 - Headless main modules package: ``pip install opencv-python-headless``
27+
- 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/))
2528

26-
3. Import the package:
29+
4. Import the package:
2730

2831
``import cv2``
2932

@@ -77,7 +80,7 @@ A: It's easier for users to understand ``opencv-python`` than ``cv2`` and it mak
7780
## Documentation for opencv-python
7881

7982
[![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)
80-
[![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)
83+
[![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/)
8184

8285
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.
8386

@@ -128,16 +131,18 @@ If some dependency is not enabled in the pre-built wheels, you can also run the
128131

129132
1. Clone this repository: `git clone --recursive https://github.com/skvark/opencv-python.git`
130133
2. ``cd opencv-python``
134+
- you can use `git` to checkout some other version of OpenCV in the `opencv` and `opencv_contrib` submodules if needed
131135
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)
132-
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`
133-
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``.
134-
- Optional: on Linux use the `manylinux` images as a build hosts if maximum portability is needed and run `auditwheel` for the wheel after build
135-
- Optional: on macOS use ``delocate`` (same as ``auditwheel`` but for macOS)
136+
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`
137+
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``.
138+
- this might take anything from 5 minutes to over 2 hours depending on your hardware
136139
6. You'll have the wheel file in the `dist` folder and you can do with that whatever you wish
140+
- 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
141+
- Optional: on macOS use ``delocate`` (same as ``auditwheel`` but for macOS) for better portability
137142

138143
#### Source distributions
139144

140-
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.
145+
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.
141146

142147
You can also force ``pip`` to build the wheels from the source distribution. Some examples:
143148

@@ -146,7 +151,7 @@ You can also force ``pip`` to build the wheels from the source distribution. Som
146151

147152
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.
148153

149-
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.
154+
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.
150155

151156
### Licensing
152157

@@ -184,17 +189,14 @@ These artifacts can't be and will not be uploaded to PyPI.
184189

185190
### Manylinux wheels
186191

187-
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.
192+
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.
188193

189-
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.
194+
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.
190195

191196
### Supported Python versions
192197

193-
Python 3.x releases are provided for officially supported versions (not in EOL).
194-
195-
Currently, builds for following Python versions are provided:
198+
Python 3.x compatible pre-built wheels are provided for the officially supported Python versions (not in EOL):
196199

197-
- 3.5 (EOL in 2020-09-13, builds for 3.5 will not be provided after this)
198200
- 3.6
199201
- 3.7
200202
- 3.8

docker/manylinux2014/Dockerfile_aarch64

+21-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ ENV PATH "$QTDIR/bin:$PATH"
1818

1919
RUN mkdir ~/ffmpeg_sources && \
2020
cd ~/ffmpeg_sources && \
21-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
22-
tar -xf OpenSSL_1_1_1c.tar.gz && \
23-
cd openssl-OpenSSL_1_1_1c && \
24-
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
21+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \
22+
tar -xf OpenSSL_1_1_1g.tar.gz && \
23+
cd openssl-OpenSSL_1_1_1g && \
24+
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
2525
make -j$(getconf _NPROCESSORS_ONLN) && \
2626
# skip installing documentation
2727
make install_sw && \
@@ -61,6 +61,23 @@ RUN cd ~/ffmpeg_sources && \
6161
ldconfig && \
6262
rm -rf ~/ffmpeg_sources
6363

64+
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v3.7.9/ccache-3.7.9.tar.gz && \
65+
tar -xf ccache-3.7.9.tar.gz && \
66+
cd ccache-3.7.9 && \
67+
linux32 ./configure && \
68+
make -j$(getconf _NPROCESSORS_ONLN) && \
69+
make install
70+
71+
RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
72+
tar -xf cmake-3.17.0.tar.gz && \
73+
cd cmake-3.17.0 && \
74+
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
75+
./configure --system-curl && \
76+
make && \
77+
make install && \
78+
cd .. && \
79+
rm -rf cmake-3.17.0*
80+
6481
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
6582
ENV LDFLAGS -L/root/ffmpeg_build/lib
6683
ENV PATH "$HOME/bin:$PATH"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
FROM quay.io/pypa/manylinux2014_aarch64:latest
2+
3+
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
4+
5+
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 && \
6+
tar -xf qt-everywhere-src-5.15.0.tar.xz && \
7+
cd qt-everywhere* && \
8+
export MAKEFLAGS=-j$(nproc) && \
9+
./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 && \
10+
make && \
11+
make install && \
12+
cd .. && \
13+
rm -rf qt-everywhere-src-5.15.0 && \
14+
rm qt-everywhere-src-5.15.0.tar.xz
15+
16+
ENV QTDIR /opt/Qt5.15.0
17+
ENV PATH "$QTDIR/bin:$PATH"
18+
19+
RUN mkdir ~/ffmpeg_sources && \
20+
cd ~/ffmpeg_sources && \
21+
<<<<<<< HEAD
22+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
23+
tar -xf OpenSSL_1_1_1c.tar.gz && \
24+
cd openssl-OpenSSL_1_1_1c && \
25+
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
26+
=======
27+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \
28+
tar -xf OpenSSL_1_1_1g.tar.gz && \
29+
cd openssl-OpenSSL_1_1_1g && \
30+
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
31+
>>>>>>> master
32+
make -j$(getconf _NPROCESSORS_ONLN) && \
33+
# skip installing documentation
34+
make install_sw && \
35+
rm -rf ~/openssl_build
36+
37+
RUN cd ~/ffmpeg_sources && \
38+
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.14.01/nasm-2.14.01.tar.bz2 && \
39+
tar -xf nasm-2.14.01.tar.bz2 && cd nasm-2.14.01 && ./autogen.sh && \
40+
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
41+
make -j$(getconf _NPROCESSORS_ONLN) && \
42+
make install
43+
44+
RUN cd ~/ffmpeg_sources && \
45+
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
46+
tar -xf yasm-1.3.0.tar.gz && \
47+
cd yasm-1.3.0 && \
48+
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
49+
make -j$(getconf _NPROCESSORS_ONLN) && \
50+
make install
51+
52+
RUN cd ~/ffmpeg_sources && \
53+
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
54+
cd libvpx && \
55+
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \
56+
make -j$(getconf _NPROCESSORS_ONLN) && \
57+
make install
58+
59+
RUN cd ~/ffmpeg_sources && \
60+
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
61+
tar -xf ffmpeg-snapshot.tar.bz2 && \
62+
cd ffmpeg && \
63+
PATH=~/bin:$PATH && \
64+
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" && \
65+
make -j$(getconf _NPROCESSORS_ONLN) && \
66+
make install && \
67+
echo "/root/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
68+
ldconfig && \
69+
rm -rf ~/ffmpeg_sources
70+
71+
<<<<<<< HEAD
72+
=======
73+
RUN curl -O -L https://github.com/ccache/ccache/releases/download/v3.7.9/ccache-3.7.9.tar.gz && \
74+
tar -xf ccache-3.7.9.tar.gz && \
75+
cd ccache-3.7.9 && \
76+
linux32 ./configure && \
77+
make -j$(getconf _NPROCESSORS_ONLN) && \
78+
make install
79+
80+
RUN curl -O -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz && \
81+
tar -xf cmake-3.17.0.tar.gz && \
82+
cd cmake-3.17.0 && \
83+
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) && \
84+
./configure --system-curl && \
85+
make && \
86+
make install && \
87+
cd .. && \
88+
rm -rf cmake-3.17.0*
89+
90+
>>>>>>> master
91+
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/root/ffmpeg_build/lib/pkgconfig
92+
ENV LDFLAGS -L/root/ffmpeg_build/lib
93+
ENV PATH "$HOME/bin:$PATH"

docker/manylinux2014/Dockerfile_i686

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ ENV PATH "$QTDIR/bin:$PATH"
1818

1919
RUN mkdir ~/ffmpeg_sources && \
2020
cd ~/ffmpeg_sources && \
21-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
22-
tar -xf OpenSSL_1_1_1c.tar.gz && \
23-
cd openssl-OpenSSL_1_1_1c && \
21+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \
22+
tar -xf OpenSSL_1_1_1g.tar.gz && \
23+
cd openssl-OpenSSL_1_1_1g && \
2424
# in i686, ./config detects x64 in i686 container without linux32
2525
# when run from "docker build"
26-
linux32 ./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
26+
linux32 ./config --prefix="$HOME/ffmpeg_build" no-pinshared shared zlib && \
2727
make -j$(getconf _NPROCESSORS_ONLN) && \
2828
#skip installing documentation
2929
make install_sw && \

docker/manylinux2014/Dockerfile_x86_64

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ ENV PATH "$QTDIR/bin:$PATH"
1818

1919
RUN mkdir ~/ffmpeg_sources && \
2020
cd ~/ffmpeg_sources && \
21-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz && \
22-
tar -xf OpenSSL_1_1_1c.tar.gz && \
23-
cd openssl-OpenSSL_1_1_1c && \
24-
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" shared zlib && \
21+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz && \
22+
tar -xf OpenSSL_1_1_1g.tar.gz && \
23+
cd openssl-OpenSSL_1_1_1g && \
24+
./config --prefix="$HOME/ffmpeg_build" --openssldir="$HOME/ffmpeg_build" no-pinshared shared zlib && \
2525
make -j$(getconf _NPROCESSORS_ONLN) && \
2626
# skip installing documentation
2727
make install_sw && \

0 commit comments

Comments
 (0)