README.md 3.5 KB
Newer Older
O
Olli-Pekka Heinisuo 已提交
1 2 3
| Platform| Status |
| :---: | :---: |
| Windows | [![buildstatus](https://ci.appveyor.com/api/projects/status/5kjqpmvll5dwj5jd?svg=true)](https://ci.appveyor.com/project/skvark/opencv-python) |
O
Olli-Pekka Heinisuo 已提交
4
| Manylinux|  [![Build Status](https://travis-ci.org/skvark/opencv-python.svg?branch=master)](https://travis-ci.org/skvark/opencv-python) |
O
Olli-Pekka Heinisuo 已提交
5

O
Olli-Pekka Heinisuo 已提交
6 7 8 9 10 11
# OpenCV on wheels

Work in progress!

The aim of this repository is to provide means to package each new [OpenCV release](https://github.com/Itseez/opencv/releases) for the most used Python versions and platforms.

O
Olli-Pekka Heinisuo 已提交
12
At the same time it allows anyone to build a custom version of OpenCV for any Python version: just fork this repo and modify the build files and scripts to fit your needs.
O
Olli-Pekka Heinisuo 已提交
13 14 15

## Why?

16
1. Installation of OpenCV for Python is pretty hideous:
O
Olli-Pekka Heinisuo 已提交
17 18 19 20 21 22 23 24 25 26 27 28
	1. Download OpenCV
	2. Find cv2.pyd from the package
		- If it exists, copy it to the root of Python site-packages
		- If it does not exist for some reason for your setup, you have to setup the build environment and compile it manually
	3. Try to import cv2 and hope it works
2. Everyone should be able to install OpenCV (or any package for that matter) with pip with a single command without building anything
3. Python [wheels](http://pythonwheels.com/) are nice, we should use them more

## Documentation

The project is structured like a normal Python package with a standard ``setup.py`` file. The build process is as follows (see ``appveyor.yml``):

O
Olli-Pekka Heinisuo 已提交
29 30
1. Checkout OpenCV (TO DO: pull only latest tag)
2. Find OpenCV version from the sources
O
Olli-Pekka Heinisuo 已提交
31 32 33
2. Upgrade pip and install numpy for each Python version
3. Build OpenCV
	- tests are disabled, otherwise build time increases too much
O
Olli-Pekka Heinisuo 已提交
34
4. Copy each ``.pyd/.so`` file to cv2 folder of this project and generate wheel
O
Olli-Pekka Heinisuo 已提交
35
5. Install the generated wheels for each Python version
O
Olli-Pekka Heinisuo 已提交
36 37
6. Test that the Python versions can import them
7. TO DO: upload the wheels to PyPi
O
Olli-Pekka Heinisuo 已提交
38

O
Olli-Pekka Heinisuo 已提交
39
Currently the ``setup.py`` file parses OpenCV version information from the OpenCV sources. OpenCV depends on numpy, so ``setup.py`` checks the numpy version also with the help of pip.
O
Olli-Pekka Heinisuo 已提交
40

O
Olli-Pekka Heinisuo 已提交
41
As described earlier, for example the ``.pyd`` file on Windows is normally copied to site-packages. I don't want to pollute the root folder, so the ``__init__.py`` file in cv2 folder handles the import logic correctly by importing the actual ``.pyd`` module and replacing the imported cv2 package in ``sys.modudes`` with the cv2 module to retain backward compatibility.
O
Olli-Pekka Heinisuo 已提交
42

O
Olli-Pekka Heinisuo 已提交
43 44 45
## 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 out there since they are built against an old version of glibc.
46

O
Olli-Pekka Heinisuo 已提交
47 48 49 50 51 52
## Versioning

Currently the ``find_version.py`` script searches for the version information from OpenCV sources. The CI build number is then added after the actual OpenCV version to differentiate packages (this repo might have modifications but OpenCV version stays same).

## Supported Python versions

O
Olli-Pekka Heinisuo 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66
#### Windows: 

There's a build time limitation (AppVeyor open source builds may take max. 1 hour) which restricts the supported Python versions to two. As Python's 2.x releases are slowly approaching legacy state, 2.7.x releases will be the only supported Python 2 versions on Windows. On Python 3 side, builds will be run only for the latest release.

However, if you wan't to get some other versions, just fork this repo and change the dependencies.

#### Linux

Manylinux wheels are built for all the Python versions which are supported by the manylinux containers.

#### OS X

TODO

O
Olli-Pekka Heinisuo 已提交
67