8000 Build working for linux and OSX by c-martinez · Pull Request #10 · opencv/opencv-python · GitHub
[go: up one dir, main page]

Skip to content

Build working for linux and OSX #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master'
  • Loading branch information
c-martinez committed Aug 22, 2016
commit 2d8b64baa210b5642adb43fc093577638b9d71bb
44 changes: 44 additions & 0 deletions LICENSE-3RD-PARTY.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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-2016, 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.
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.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Olli-Pekka Heinisuo, Carlos Martinez

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.
2 changes: 2 additions & 0 deletions MANIFEST.in
< 10000 template class="js-file-alert-template">
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE.txt
include LICENSE-3RD-PARTY.txt
56 changes: 0 additions & 56 deletions README.md

This file was deleted.

137 changes: 137 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
.. image:: https://img.shields.io/appveyor/ci/skvark/opencv-python.svg?maxAge=2592000&label=Windows
:target: https://ci.appveyor.com/project/skvark/opencv-python
:alt: AppVeyor CI test status (Windows)

.. image:: https://img.shields.io/travis/skvark/opencv-python.svg?maxAge=2592000&label=Linux
:target: https://travis-ci.org/skvark/opencv-python
:alt: Travis CI test status (Linux)

OpenCV on wheels
================

Unofficial OpenCV packages for Python. Work in progress!

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.

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.

Installation and Usage
----------------------

To install this package:

``pip install opencv-python``

To import the package:

``import cv2``

`OpenCV documentation <http://docs.opencv.org/>`__

Build process
-------------

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

1. Checkout repository and submodules

- OpenCV is included as submodule and the version is updated
manually by maintainers when a new OpenCV release has been made

2. Find OpenCV version from the sources
3. Upgrade pip and install numpy for each Python version
4. Build OpenCV

- tests are disabled, otherwise build time increases too much

5. Copy each ``.pyd/.so`` file to cv2 folder of this project and
generate wheel
6. Install the generated wheels for each Python version
7. Test that the Python versions can import them
8. Use twine to upload all wheels to PyPI

Currently the ``find_version.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.

The ``cv2.pyd`` file for example on Windows is normally copied to site-packages.
To avoid polluting the root folder 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.

Licensing
---------

Opencv-python package (scripts in this repository) is available under
MIT license. The OpenCV itself is available under `3-clause BSD
License <https://github.com/opencv/opencv/blob/master/LICENSE>`__
(`LICENSE-3RD-PARTY.txt <https://github.com/skvark/opencv-python/blob/master/LICENSE-3RD-PARTY.txt>`__).

Versioning
----------

Currently the ``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.

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:

``cv_major.cv_minor.cv_revision.package_revision`` e.g. ``3.1.0.0``

Development builds
~~~~~~~~~~~~~~~~~~

Every commit to the master branch of this repo will be built. Possible
build artifacts use local version identifiers:

``cv_major.cv_minor.cv_revision+git_hash_of_this_repo`` e.g.
``3.1.0+14a8d39``

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 out there
since they are built against an old version of glibc.

Supported Python versions
-------------------------

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
12 changes: 11 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
environment:
USER:
secure: fXgF9uyy6sT0JoVOR7BoqA==

PASS:
secure: DJMOk9HEW0qeOC0a2klPZpUMlPvq6vp6Rzv1++SpaYo=

install:
- cmd: >-

git clone -q --branch=master https://github.com/c-martinez/opencv.git "%APPVEYOR_BUILD_FOLDER%\opencv
git submodule update --init --recursive

C:\Python35\python.exe find_version.py

Expand Down Expand Up @@ -99,3 +106,6 @@ test_script:
artifacts:
- path: dist\*.whl
name: wheels

deploy_script:
- if "%APPVEYOR_REPO_TAG%"=="true" (twine -u %USER% -p %PASS% -r pypitest dist/*) else (echo "Tag not set, deployment skipped.")
21 changes: 20 additions & 1 deletion find_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
import os
import subprocess

opencv_version = ""
# dig out the version from OpenCV sources
Expand All @@ -20,5 +22,22 @@
opencv_version += words[2]
break

# used in local dev releases
git_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).splitlines()[0].decode()

if os.name == 'posix':
version = os.getenv('TRAVIS_TAG', git_hash)
else:
version = os.getenv('APPVEYOR_REPO_TAG_NAME', git_hash)

if version != git_hash:
# tag identifies the build and should be a sequential revision number
opencv_version += ".{}".format(version)
else:
# local version identifier, not to be published on PyPI
opencv_version += "+{}".format(version)

print("Version: ", opencv_version)

with open('cv_version.py', 'w') as f:
f.write('opencv_version = "%s"'%opencv_version)
f.write('opencv_version = "{}"'.format(opencv_version))
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numpy
numpy==1.11.1
wheel
twine
37 changes: 33 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import pip
import os
import sys
import io

long_description = ""

with io.open('README.rst', encoding="utf-8") as f:
long_description = f.read()

# cv_version.py should be generated by running find_version.py
from cv_version import opencv_version
Expand All @@ -16,7 +22,7 @@

class BinaryDistribution(Distribution):
""" Forces BinaryDistribution. """
def has_ext_modules(asd):
def has_ext_modules(self):
return True

def is_pure(self):
Expand All @@ -31,10 +37,33 @@ def is_pure(self):

setup(name='opencv-python',
version=opencv_version,
description='OpenCV',
url='https://github.com/skvark/opencv-python',
license='MIT',
description='Wrapper package for OpenCV python bindings.',
long_description = long_description,
distclass=BinaryDistribution,
packages=['cv2'],
package_data=package_data,
include_package_data=True,
maintainer="Olli-Pekka Heinisuo",
include_package_data=True,
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 :: C++',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: Software Development',
]
)
You are viewing a condensed version of this merge commit. You can view the full changes here.
0