Skip to content

Commit

Permalink
Add manylinux1 wheels, fix #6, publish docs to GitHub pages (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
letmaik authored Aug 19, 2017
1 parent f43646c commit a464ff5
Show file tree
Hide file tree
Showing 16 changed files with 264 additions and 129 deletions.
88 changes: 36 additions & 52 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,50 @@
language: python

sudo: required

python:
- "2.7"
- "3.4"
language: generic

env:
global:
- LENSFUN_GIT="git://git.code.sf.net/p/lensfun/code"
matrix:
- USE_LATEST_LENSFUN=false
- USE_LATEST_LENSFUN=true
- PYPI_USER=letmaik

matrix:
include:
- os: linux
services:
- docker
env: DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64

- os: osx
# use oldest available image to be as compatible as possible when producing wheels
osx_image: xcode6.4 # = OS X 10.10
# (NumPy 1.7.2 has no macOS wheels)
env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.7.1

git:
submodules: false
- os: osx
osx_image: xcode6.4
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.8.*

- os: osx
osx_image: xcode6.4
env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.9.*

- os: osx
osx_image: xcode6.4
env: PYTHON_VERSION=3.6 NUMPY_VERSION=1.11.*

install:
# checkout master, see https://sourceforge.net/p/lensfun/bugs/36/
# git checkout -f `git describe --abbrev=0 --tags` ;
- if [ $USE_LATEST_LENSFUN == true ]; then
cd .. ;
git clone $LENSFUN_GIT lensfun ;
cd lensfun ;
git checkout 75a845abf ;
cmake . -DBUILD_TESTS=off ;
sudo make install ;
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/99local.conf ;
sudo ldconfig ;
cd ../lensfunpy ;
else
sudo apt-get update ;
sudo apt-get install liblensfun-dev ;
fi
- travis_retry pip install -r dev-requirements.txt
- python setup.py sdist
- pip install dist/*.tar.gz
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull $DOCKER_IMAGE; fi

script:
- mkdir tmp_for_test
- cd tmp_for_test
- nosetests --verbosity=3 --nocapture ../test
- cd ..
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run --rm -e TRAVIS_TAG -e PYPI_USER -e PYPI_PASS -v `pwd`:/io $DOCKER_IMAGE /io/travis/build_linux.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis/build_macos.sh; fi

after_success:
- if [[ $USE_LATEST_LENSFUN == false && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then
pip install travispy ;
travis_retry python -c "import os; from travispy import TravisPy; t = TravisPy.github_auth(os.environ['GITHUB_TOKEN']); t.build(t.branch('mac-wheels', 'letmaik/lensfunpy').id).restart()" ;
fi

before_deploy:
# otherwise sphinx would fail
- python setup.py build_ext --inplace
# scipy is imported by lensfunpy.util, but because the util module is not unit-tested scipy is not installed earlier
# sphinx needs scipy in order to import the util module, otherwise it can't generate docs
- pip install sphinx scipy
- ls dist/
- ls build/

deploy:
provider: pypi
user: letmaik
password:
secure: GW2vr0X3tka3QQT4MiqPIt1aJ++HxI7bwbpSBj5zURvjGQQ/IKWJp1HBVkdFD+skpnctZyLxh97SprGZXLGtcbXLTDi7u+bkzW30Mv2FR4zHFb5dWCdf5mutinZG5dCmWmxvMx0GhNGpVsxo4Y/LDt+r0tPyT6DtmDs/9B01dLs=
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
local_dir: build/sphinx/html
on:
tags: true
condition: $USE_LATEST_LENSFUN = false && $TRAVIS_PYTHON_VERSION == '2.7'
condition: $PYTHON_VERSION = '3.6' && $TRAVIS_OS_NAME == 'osx'
67 changes: 31 additions & 36 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ lensfunpy

.. image:: https://travis-ci.org/letmaik/lensfunpy.svg?branch=master
:target: https://travis-ci.org/letmaik/lensfunpy
:alt: Linux Build Status

.. image:: https://travis-ci.org/letmaik/lensfunpy.svg?branch=master
:target: https://travis-ci.org/letmaik/lensfunpy
:alt: Mac Build Status

:alt: Linux/macOS Build Status

.. image:: https://ci.appveyor.com/api/projects/status/qg6tssjvx5xjb3xd?svg=true
:target: https://ci.appveyor.com/project/letmaik/lensfunpy
:alt: Windows Build Status

lensfunpy is an easy-to-use Python wrapper for the lensfun_ library.

`API Documentation <http://pythonhosted.org/lensfunpy/api/>`_
`API Documentation <https://letmaik.github.io/lensfunpy/api/>`_

Sample code
-----------
Expand Down Expand Up @@ -70,42 +66,26 @@ It is also possible to apply the correction via `SciPy <http://www.scipy.org>`_
The `lensfunpy.util <http://pythonhosted.org/lensfunpy/api/lensfunpy.util.html>`_ module
contains convenience functions for RGB images which handle both OpenCV and SciPy.

NumPy Dependency
----------------

Before installing lensfunpy, you need to have *numpy* installed.
You can check your numpy version with ``pip freeze``.
Installation
------------

The minimum supported numpy version depends on your Python version:
Binary wheels for Linux, macOS, and Windows are provided for Python 2.7, 3.4, 3.5, and 3.6.
These can be installed with a simple ``pip install rawpy``.
Currently, Linux and macOS wheels are only available as 64 bit versions.

========== =========
Python numpy
---------- ---------
2.7 >= 1.7
3.4 >= 1.8
3.5 >= 1.9
3.6 >= 1.11
========== =========
Installation from source on Linux/macOS
---------------------------------------

You can install numpy with ``pip install numpy``.
If you have the need to use a specific lensfun version or you can't use the provided binary wheels
then follow the steps in this section to build lensfunpy from source.

Installation on Windows and Mac OS X
------------------------------------

Binaries are provided for Python 2.7, 3.4, 3.5, and 3.6 for both 32 and 64 bit.
These can be installed with a simple ``pip install lensfunpy``
(or ``pip install --use-wheel lensfunpy`` if using pip < 1.5).

Installation on Linux
---------------------

You need to have the lensfun_ library installed to use this wrapper.
First, install the lensfun_ library on your system.

On Ubuntu, you can get (an outdated) version with:

.. code-block:: sh
sudo apt-get install liblensfun0 liblensfun-dev
sudo apt-get install liblensfun-dev
Or install the latest developer version from the GIT repository:

Expand All @@ -116,7 +96,7 @@ Or install the latest developer version from the GIT repository:
cmake .
sudo make install
After that, it's the usual ``pip install lensfunpy``.
After that, install lensfunpy using ``pip install lensfunpy --no-binary :all:``.

If you get the error "ImportError: liblensfun.so.0: cannot open shared object file: No such file or directory"
when trying to use lensfunpy, then do the following:
Expand All @@ -127,7 +107,22 @@ when trying to use lensfunpy, then do the following:
sudo ldconfig
The lensfun library is installed in ``/usr/local/lib`` when compiled from source, and apparently this folder is not searched
for libraries by default in some Linux distributions. Note that on some systems the installation path may be slightly different, such as ``/usr/local/lib/x86_64-linux-gnu``.
for libraries by default in some Linux distributions.
Note that on some systems the installation path may be slightly different, such as ``/usr/local/lib/x86_64-linux-gnu``
or ``/usr/local/lib64``.

NumPy Dependency
----------------

lensfunpy depends on NumPy. The minimum supported NumPy version depends on your Python version:

========== =========
Python numpy
---------- ---------
2.7 >= 1.7
3.4 >= 1.8
3.5 >= 1.9
3.6 >= 1.11
========== =========

.. _lensfun: http://lensfun.sourceforge.net
13 changes: 5 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ environment:
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"


PYPI_USER: letmaik

matrix:
# Note: numpy binary wheels for Windows are only available from 1.10.4 onwards.
# That is why this script uses Conda instead of the pre-installed Python versions in AppVeyor.
Expand Down Expand Up @@ -76,8 +78,8 @@ install:
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""

# we use conda to prevent compiling numpy and cython
- "conda install --yes numpy=%NUMPY_VERSION% cython"
# we use conda to prevent compiling numpy, scipy, and cython
- "conda install --yes numpy=%NUMPY_VERSION% cython scipy"
- "pip install -r dev-requirements.txt"

# force nose reinstall (not using possibly existing conda package)
Expand Down Expand Up @@ -107,10 +109,5 @@ test_script:
- nosetests --verbosity=3 --nocapture ../test
- cd ..

# artifacts are big, and we don't really need to store them
#artifacts:
# Archive the generated wheel package in the ci.appveyor.com build report.
# - path: dist\*

deploy_script:
- "powershell ./appveyor/pypi_deploy.ps1"
2 changes: 1 addition & 1 deletion appveyor/.pypirc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ index-servers =
pypi

[pypi]
username:letmaik
username:%USER%
password:%PASS%
13 changes: 9 additions & 4 deletions appveyor/pypi_deploy.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
echo "APPVEYOR_REPO_TAG: " + $env:APPVEYOR_REPO_TAG
echo "APPVEYOR_REPO_TAG_NAME: " + $env:APPVEYOR_REPO_TAG_NAME
Write-Host "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
Write-Host "APPVEYOR_REPO_TAG_NAME: $env:APPVEYOR_REPO_TAG_NAME"

if (($env:APPVEYOR_REPO_TAG -eq "True") -and ($env:APPVEYOR_REPO_TAG_NAME.StartsWith("v"))) {
(Get-Content appveyor\.pypirc) | Foreach-Object {$_ -replace '%PASS%',$env:PYPI_PASS} | Set-Content $env:userprofile\.pypirc
# save credentials in ~\.pypirc
(Get-Content appveyor\.pypirc) `
| Foreach-Object {$_ -replace '%USER%',$env:PYPI_USER -replace '%PASS%',$env:PYPI_PASS} `
| Set-Content $env:userprofile\.pypirc

# build and upload binary wheel
Invoke-Expression "$env:CMD_IN_ENV python setup.py bdist_wheel upload"
}
}
4 changes: 3 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ numpy
cython
nose
wheel>=0.25
sphinx_rtd_theme
sphinx
sphinx_rtd_theme
scipy
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
html_extra_path = ['gh-pages']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down
Empty file added docs/gh-pages/.nojekyll
Empty file.
2 changes: 1 addition & 1 deletion lensfunpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import

from ._version import __version__, __version_info__
from ._version import __version__

import os, sys

Expand Down
21 changes: 12 additions & 9 deletions lensfunpy/_lensfun.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,12 @@ cdef class Database:
:param str xml: load data from XML string
:param bool load_common: whether to load the system/user database files
"""
cdef char* xmlstr
if paths:
for path in paths:
handleError(lf_db_load_file(self.lf, _chars(path)))
if xml:
xml = xml.strip() # lensfun is very strict here
xmlstr = _chars(xml)
handleError(lf_db_load_data(self.lf, 'XML', xmlstr, len(xmlstr)))
xml = _chars(xml.strip()) # stripping as lensfun is very strict here
handleError(lf_db_load_data(self.lf, 'XML', xml, len(xml)))

if load_common:
code = lf_db_load(self.lf)
Expand Down Expand Up @@ -273,11 +271,14 @@ cdef class Database:
if maker is None:
cmaker = NULL
else:
cmaker = _chars(maker)
# direct assignment to cmaker is NOT possible (as the C string is tied to the lifetime of the Python string)
maker = _chars(maker)
cmaker = maker
if model is None:
cmodel = NULL
else:
cmodel = _chars(model)
model = _chars(model)
cmodel = model
if loose_search:
lfCams = lf_db_find_cameras_ext(self.lf, cmaker, cmodel, LF_SEARCH_LOOSE)
else:
Expand Down Expand Up @@ -337,11 +338,13 @@ cdef class Database:
if maker is None:
cmaker = NULL
else:
cmaker = _chars(maker)
maker = _chars(maker)
cmaker = maker
if lens is None:
clens = NULL
else:
clens = _chars(lens)
lens = _chars(lens)
clens = lens
lfLenses = lf_db_find_lenses_hd(self.lf, camera.lf, cmaker, clens, LF_SEARCH_LOOSE if loose_search else 0)
lenses = self._convertLenses(lfLenses)
lf_free(lfLenses)
Expand Down Expand Up @@ -966,7 +969,7 @@ cdef handleError(int code):
else:
raise LensfunError('Unknown lensfun error (code: {}), please report an issue for lensfunpy'.format(code))

cdef char* _chars(s):
def _chars(s):
if isinstance(s, unicode):
# convert unicode to chars
s = (<unicode>s).encode('UTF-8')
Expand Down
3 changes: 1 addition & 2 deletions lensfunpy/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = "1.5.0"
__version_info__ = tuple(map(int, __version__.split('.')))
__version__ = "1.6.0"
Loading

0 comments on commit a464ff5

Please sign in to comment.