Skip to content

Commit

Permalink
Add python 2.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
akiomik committed Jul 4, 2019
1 parent 0e0f81b commit a0cf1e2
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 24 deletions.
18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
dist: xenial
language: python
python:
- "3.7"
matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.7
env: TOXENV=py37
env:
global:
- PIPENV_VERBOSITY=-1
install:
- pip install pipenv
- pipenv install -d
- pipenv install -d codecov
- pipenv install -d --skip-lock
- pipenv install -d codecov --skip-lock
script:
- make test
- make test-tox
after_success:
- pipenv run codecov
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ all: test clean build;
test:
pipenv run pytest && pipenv run flake8 ${SRC_DIR}

benchmark:
test-tox:
pipenv run tox && pipenv run flake8 ${SRC_DIR}

test-benchmark:
pipenv run pytest --benchmark-only --benchmark-max-time=5 --benchmark-columns="mean,stddev,min,max"

clean:
find . -type f -name "*.pyc" -delete
rm -rf dist build *.egg-info

build:
Expand All @@ -20,4 +24,4 @@ test-upload: clean build
upload: clean build
pipenv run twine upload -s -r pypi dist/*

.PHONY: all test benchmark clean build test-upload upload
.PHONY: all test test-tox test-benchmark benchmark clean build test-upload upload
4 changes: 1 addition & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pillow = "*"
twine = "*"
wheel = "*"
pytest-benchmark = "*"

[requires]
python_version = "3.7"
tox = "*"

[packages]
35 changes: 31 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pilgram

[![PyPI version](https://badge.fury.io/py/pilgram.svg)](https://badge.fury.io/py/pilgram)
[![PyPI](https://img.shields.io/pypi/v/pilgram.svg)](https://python.org/pypi/pipenv)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pilgram.svg)](https://python.org/pypi/pipenv)
[![Build Status](https://travis-ci.org/akiomik/pilgram.svg?branch=master)](https://travis-ci.org/akiomik/pilgram)
[![codecov](https://codecov.io/gh/akiomik/pilgram/branch/master/graph/badge.svg)](https://codecov.io/gh/akiomik/pilgram)

Expand All @@ -12,7 +13,7 @@ The filter implementations are inspired by [CSSgram](https://una.im/CSSgram/).

## Requirements

- Python 3
- Python 2 or 3
- [Pillow](https://pillow.readthedocs.io/en/stable/) or [pillow-simd](https://github.com/uploadcare/pillow-simd)

## Install
Expand Down Expand Up @@ -55,5 +56,6 @@ pilgram.css.sepia(im).save('sample-sepia.jpg')

```sh
pipenv install --dev
make test
make test # python 3
make test-tox # python 2 and 3
```
2 changes: 1 addition & 1 deletion pilgram/css/blending/soft_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _soft_light(cb, cs, d_cb):
def _d_cb(cb):
"""Returns D(Cb) - Cb"""

cb /= 255
cb = float(cb) / 255

if cb <= .25:
d = ((16 * cb - 12) * cb + 4) * cb
Expand Down
8 changes: 4 additions & 4 deletions pilgram/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test_linear_gradient_mask_vertical():

def test_linear_gradient_mask_start_end():
w, h = (4, 4)
start = 100 / 255
end = 200 / 255
start = 100.0 / 255
end = 200.0 / 255
mask = util.linear_gradient_mask((w, h), start=start, end=end)

assert list(mask.getdata()) == [100, 133, 166, 200] * h
Expand All @@ -82,8 +82,8 @@ def test_linear_gradient_mask_start_end():

def test_linear_gradient_mask_start_end_vertical():
w, h = (4, 4)
start = 100 / 255
end = 200 / 255
start = 100.0 / 255
end = 200.0 / 255
mask = util.linear_gradient_mask(
(w, h), start=start, end=end, is_horizontal=False)

Expand Down
2 changes: 1 addition & 1 deletion pilgram/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fill(size, color):
assert len(color) in [3, 4]

if len(color) == 4:
color[3] = round(color[3] * 255) # alpha
color[3] = int(round(color[3] * 255)) # alpha

uniqued = list(set(color))
cmap = {c: Image.new('L', size, c) for c in uniqued}
Expand Down
24 changes: 24 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ classifiers =
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Topic :: Multimedia :: Graphics
Topic :: Software Development :: Libraries :: Python Modules

Expand All @@ -30,6 +36,7 @@ zip_safe = false
packages = find:
setup_requires =
setuptools >= 38.3.0
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*

[options.packages.find]
exclude =
Expand All @@ -50,3 +57,20 @@ show_missing = true

[flake8]
doctests = true

[tox:tox]
envlist = py27, py37

[testenv]
whitelist_externals =
pipenv
pytest
deps =
pillow
numpy
commands =
pipenv install -d --skip-lock
pytest
setenv =
PYTHONPATH = {toxinidir}
PIPENV_VERBOSITY = -1

0 comments on commit a0cf1e2

Please sign in to comment.