---
# Installs ocropus

- name: Install ocropus dependencies
  package: name={{ item }} state=present
  with_items:
    - git
    - python-lxml
    - python-pillow
    - python2-pip
    - scipy
    - tkinter

- name: Install extra dependencies with pip (as user)
  pip: name={{ item }} extra_args="--user -U"
  become: no
  with_items:
    - matplotlib
    - numpy

- name: Clone ocropus repository
  git:
    repo: https://github.com/nickjwhite/ocropy
    dest: /home/ec2-user/src/ocropy
    depth: 1
    version: currentworking
  become: no
  register: ocroclone

- name: Build ocropus
  command: python setup.py build
  args:
    chdir: /home/ec2-user/src/ocropy
  become: no
  when: ocroclone.changed

- name: Install ocropus
  command: python setup.py install
  args:
    chdir: /home/ec2-user/src/ocropy
  when: ocroclone.changed