Skip to content

Commit ce22c91

Browse files
committed
update README, add README_CONTRIB, cleaning
1 parent f5b3562 commit ce22c91

File tree

4 files changed

+234
-19
lines changed

4 files changed

+234
-19
lines changed

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
:target: https://travis-ci.org/skvark/opencv-python
77
:alt: Travis CI test status (Linux and OS X)
88

9-
OpenCV on wheels
9+
OpenCV on Wheels
1010
================
1111

1212
**Unofficial** OpenCV packages for Python.
1313

14-
This repository generates packages which contain pre-compiled OpenCV binary with Python bindings. This enables super fast (usually < 10 seconds) OpenCV installation for Python.
14+
This package contains only the OpenCV core modules without the optional contrib modules.
15+
If you are looking for a version which includes OpenCV contrib modules, please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead.
1516

16-
If you need only OpenCV Python bindings, no separate OpenCV installation is required.
17+
The packages contain pre-compiled OpenCV binary with Python bindings.
18+
This enables super fast (usually < 10 seconds) OpenCV installation for Python.
19+
20+
If you need only OpenCV Python bindings, no separate OpenCV installation is required.
1721

1822
**IMPORTANT NOTE**
1923

20-
MacOS and Linux wheels have some limitations:
24+
MacOS and Linux wheels have currently some limitations:
2125

2226
- video related functionality is not supported (not compiled with FFmpeg)
23-
- for example ``cv.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)
27+
- for example ``cv2.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)
2428

2529
Installation and Usage
2630
----------------------
@@ -37,6 +41,41 @@ Installation and Usage
3741

3842
4. Read `OpenCV documentation <http://docs.opencv.org/>`__
3943

44+
5. Before opening a new issue, read the FAQ below and have a look at the other issues which are already open.
45+
46+
Frequently Asked Questions
47+
--------------------------
48+
49+
Q: Do I need to install also OpenCV separately?
50+
51+
A: No, the packages are special wheel binary packages and they already contain statically built OpenCV binaries.
52+
53+
Q: Pip does not find package opencv-python?
54+
55+
A: The wheel package format and manylinux builds are pretty new things. Most likely the issue is related to too old pip and can be fixed by running ``pip install --upgrade pip``.
56+
57+
Q: I need contrib modules?
58+
59+
A: Please install `opencv-contrib-python <https://pypi.python.org/pypi/opencv-contrib-python>`__ instead. However, note that commercial usage might be restricted in some countries since the contrib modules contain some non-free/patented algorithms.
60+
61+
Q: Import fails on Windows to some DLL load error?
62+
63+
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.
64+
65+
Q: I have some other import errors?
66+
67+
A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
68+
69+
Q: Why I can't open video files on GNU/Linux distribution X or on macOS?
70+
71+
A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it.
72+
The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box.
73+
Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed static build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.
74+
75+
Q: Why I can't open GUI windows (``cv2.imshow()``) on GNU/Linux distribution X or on macOS?
76+
77+
A: Like above, OpenCV was not compiled against GTK or Carbon. Support for these might be added in the future.
78+
4079
Documentation for opencv-python
4180
-------------------------------
4281

README_CONTRIB.rst

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
.. image:: https://img.shields.io/appveyor/ci/skvark/opencv-python.svg?maxAge=3600&label=Windows
2+
:target: https://ci.appveyor.com/project/skvark/opencv-python
3+
:alt: AppVeyor CI test status (Windows)
4+
5+
.. image:: https://img.shields.io/travis/skvark/opencv-python.svg?maxAge=3600&label="Linux / OS X"
6+
:target: https://travis-ci.org/skvark/opencv-python
7+
:alt: Travis CI test status (Linux and OS X)
8+
9+
OpenCV on Wheels
10+
================
11+
12+
**Unofficial** OpenCV packages for Python with contrib modules.
13+
14+
**Usage of opencv-contrib-python might be restricted in some countries since the contrib package contains some patented algorithms/non-free modules.**
15+
16+
If you are looking for a version without the contrib modules, please install `opencv-python <https://pypi.python.org/pypi/opencv-python>`__ instead.
17+
18+
The packages contain pre-compiled OpenCV binary with Python bindings.
19+
This enables super fast (usually < 10 seconds) OpenCV installation for Python.
20+
21+
If you need only OpenCV Python bindings, no separate OpenCV installation is required.
22+
23+
**IMPORTANT NOTE**
24+
25+
MacOS and Linux wheels have currently some limitations:
26+
27+
- video related functionality is not supported (not compiled with FFmpeg)
28+
- for example ``cv2.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)
29+
30+
Installation and Usage
31+
----------------------
32+
33+
1. If you have previous/other version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts.
34+
- To further avoid conflicts and to make development easier, Python's `virtual environments <https://docs.python.org/3/library/venv.html>`__ are highly recommended for development purposes.
35+
2. Install this package:
36+
37+
``pip install opencv-python``
38+
39+
3. Import the package:
40+
41+
``import cv2``
42+
43+
4. Read `OpenCV documentation <http://docs.opencv.org/>`__
44+
45+
5. Before opening a new issue, read the FAQ below and have a look at the other issues which are already open.
46+
47+
Frequently Asked Questions
48+
--------------------------
49+
50+
Q: Do I need to install also OpenCV separately?
51+
A: No, the packages are special wheel binary packages and they already contain statically built OpenCV binaries.
52+
53+
Q: Pip does not find package opencv-contrib-python?
54+
A: The wheel package format and manylinux builds are pretty new things. Most likely the issue is related to too old pip and can be fixed by running ``pip install --upgrade pip``.
55+
56+
Q: Import fails on Windows to some DLL load error?
57+
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.
58+
59+
Q: I have some other import errors?
60+
A: Make sure you have removed old manual installations of OpenCV Python bindings (cv2.so or cv2.pyd in site-packages).
61+
62+
Q: Why I can't open video files on GNU/Linux distribution X or on macOS?
63+
A: OpenCV video I/O depends heavily on FFmpeg. Manylinux and macOS OpenCV binaries are not compiled against it.
64+
The purpose of these packages is to provide as easy as possible installation experience for OpenCV Python bindings and they should work directly out-of-the-box.
65+
Adding FFmpeg as an additional dependency without a "universal" FFmpeg build (e.g. LGPL licensed static build like in the Windows wheels) the goal is considerably harder to achieve. This might change in the future.
66+
67+
Q: Why I can't open GUI windows (``cv2.imshow()``) on GNU/Linux distribution X or on macOS?
68+
A: Like above, OpenCV was not compiled against GTK or Carbon. Support for these might be added in the future.
69+
70+
Documentation for opencv-python
71+
-------------------------------
72+
73+
The aim of this repository is to provide means to package each new
74+
`OpenCV release <https://github.com/opencv/opencv/releases>`__ for the
75+
most used Python versions and platforms.
76+
77+
At the same time it allows anyone to build a custom version of OpenCV
78+
for any Python version: just fork this repo and modify the build files
79+
and scripts to fit your needs.
80+
81+
Build process
82+
-------------
83+
84+
The project is structured like a normal Python package with a standard
85+
``setup.py`` file. The build process is as follows (see for example
86+
``appveyor.yml`` file):
87+
88+
1. Checkout repository and submodules
89+
90+
- OpenCV is included as submodule and the version is updated
91+
manually by maintainers when a new OpenCV release has been made
92+
93+
2. Find OpenCV version from the sources
94+
3. Upgrade pip and install numpy for each Python version
95+
4. Build OpenCV
96+
97+
- tests are disabled, otherwise build time increases too much
98+
99+
5. Copy each ``.pyd/.so`` file to cv2 folder of this project and
100+
generate wheel
101+
6. Install the generated wheels for each Python version
102+
7. Test that the Python versions can import them
103+
8. Use twine to upload all wheels to PyPI
104+
105+
Currently the ``find_version.py`` file parses OpenCV version information
106+
from the OpenCV sources. OpenCV depends on numpy, so ``setup.py`` checks
107+
the numpy version also with the help of pip.
108+
109+
The ``cv2.pyd`` file for example on Windows is normally copied to site-packages.
110+
To avoid polluting the root folder the ``__init__.py`` file in cv2 folder
111+
handles the import logic correctly by importing the actual ``.pyd`` module
112+
and replacing the imported cv2 package in ``sys.modudes`` with the
113+
cv2 module to retain backward compatibility.
114+
115+
Licensing
116+
---------
117+
118+
Opencv-python package (scripts in this repository) is available under
119+
MIT license.
120+
121+
OpenCV itself is available under `3-clause BSD
122+
License <https://github.com/opencv/opencv/blob/master/LICENSE>`__
123+
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).
124+
125+
Windows wheels ship with `FFmpeg <http://ffmpeg.org>`__ licensed under the `LGPLv2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>`__.
126+
127+
Versioning
128+
----------
129+
130+
Currently the ``find_version.py`` script searches for the version
131+
information from OpenCV sources and appends also a revision number
132+
specific to this repository to the version string.
133+
134+
Releases
135+
~~~~~~~~
136+
137+
A release is made and uploaded to PyPI when a new tag is pushed to
138+
master branch. These tags differentiate packages (this repo might have
139+
modifications but OpenCV version stays same) and should be incremented
140+
sequentially. In practice, release version numbers look like this:
141+
142+
``cv_major.cv_minor.cv_revision.package_revision`` e.g. ``3.1.0.0``
143+
144+
Development builds
145+
~~~~~~~~~~~~~~~~~~
146+
147+
Every commit to the master branch of this repo will be built. Possible
148+
build artifacts use local version identifiers:
149+
150+
``cv_major.cv_minor.cv_revision+git_hash_of_this_repo`` e.g.
151+
``3.1.0+14a8d39``
152+
153+
These artifacts can't be and will not be uploaded to PyPI.
154+
155+
Manylinux wheels
156+
----------------
157+
158+
Linux wheels are built using
159+
`manylinux <https://github.com/pypa/python-manylinux-demo>`__. These
160+
wheels should work out of the box for most of the distros
161+
(which use GNU C standard library) out there since they are built
162+
against an old version of glibc.
163+
164+
Supported Python versions
165+
-------------------------
166+
167+
Python 2.7 is the only supported version in 2.x series.
168+
Python 3.x releases follow Numpy releases, for example
169+
Python 3.3 is no longer supported by Numpy so the support
170+
for it has been dropped in ``opencv-python`` too.
171+
172+
Currently, builds for following Python versions are provided:
173+
174+
- 2.7
175+
- 3.4
176+
- 3.5
177+
- 3.6

setup.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
import sys
66
import io
77

8+
# cv_version.py should be generated by running find_version.py
9+
from cv_version import opencv_version
10+
811
contrib_build = False
912
package_name = "opencv-python"
13+
numpy_version = ""
14+
long_description = ""
15+
package_data = {}
1016

1117
contrib = os.getenv('ENABLE_CONTRIB', None)
1218

@@ -23,26 +29,20 @@
2329
except:
2430
pass
2531

32+
# Use different README and package name for contrib build.
2633
if contrib_build:
2734
package_name = "opencv-contrib-python"
28-
29-
long_description = ""
30-
31-
with io.open('README.rst', encoding="utf-8") as f:
32-
long_description = f.read()
33-
34-
# cv_version.py should be generated by running find_version.py
35-
from cv_version import opencv_version
36-
37-
numpy_version = ""
35+
with io.open('README_CONTRIB.rst', encoding="utf-8") as f:
36+
long_description = f.read()
37+
else:
38+
with io.open('README.rst', encoding="utf-8") as f:
39+
long_description = f.read()
3840

3941
# Get required numpy version
4042
for package in pip.get_installed_distributions():
4143
if package.key == "numpy":
4244
numpy_version = package.version
4345

44-
package_data = {}
45-
4646
if os.name == 'posix':
4747
package_data['cv2'] = ['*.so']
4848
else:
@@ -68,6 +68,7 @@ def is_pure(self):
6868
package_data=package_data,
6969
maintainer="Olli-Pekka Heinisuo",
7070
include_package_data=True,
71+
data_files=[("", ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"])],
7172
install_requires="numpy>=%s" % numpy_version,
7273
classifiers=[
7374
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)