Skip to content

Commit 14fd219

Browse files
alexwlchanbcail
authored andcommitted
Pin the version of Pillow so we can support JPEG-compressed TIFFs, track breaking changes (loris-imageserver#407)
* transforms_t.py: add a test that uses a JPEG-compressed TIFF * requirements.txt: use pip-tools to compile pinned dependencies * requirements.txt: also use pip-compile for pins * And actually pin the version of Pillow * setup.py: use the requirements.txt to determined installed deps
1 parent 5be51c8 commit 14fd219

File tree

7 files changed

+105
-26
lines changed

7 files changed

+105
-26
lines changed

requirements.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
werkzeug >= 0.11.4
2+
3+
# We put an upper bound on the version of Pillow so we can cope with
4+
# JPEG-compressed TIFFs.
5+
#
6+
# See https://github.com/loris-imageserver/loris/issues/405
7+
pillow >= 2.4.0, <5.0
8+
9+
configobj >= 4.7.2,<=5.0.0
10+
requests >= 2.12.0
11+
netaddr >= 0.7.19
12+
pyjwt >= 1.5.2
13+
cryptography >= 2.0.3
14+
attrs >= 17.3.0

requirements.txt

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
werkzeug >= 0.11.4
2-
pillow >= 2.4.0
3-
configobj >= 4.7.2,<=5.0.0
4-
requests >= 2.12.0
5-
netaddr >= 0.7.19
6-
pyjwt >= 1.5.2
7-
cryptography >= 2.0.3
8-
attrs >= 17.3.0
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile --output-file requirements.txt requirements.in
6+
#
7+
asn1crypto==0.24.0 # via cryptography
8+
attrs==17.4.0
9+
certifi==2018.1.18 # via requests
10+
cffi==1.11.5 # via cryptography
11+
chardet==3.0.4 # via requests
12+
configobj==5.0.0
13+
cryptography==2.1.4
14+
enum34==1.1.6 # via cryptography
15+
idna==2.6 # via cryptography, requests
16+
ipaddress==1.0.19 # via cryptography
17+
netaddr==0.7.19
18+
olefile==0.45.1 # via pillow
19+
pillow==4.3.0
20+
pycparser==2.18 # via cffi
21+
pyjwt==1.5.3
22+
requests==2.18.4
23+
six==1.11.0 # via cryptography
24+
urllib3==1.22 # via requests
25+
werkzeug==0.14.1

requirements_test.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-r requirements.txt
2+
coverage==4.4.1
3+
hypothesis >= 3.11.6
4+
pytest-cov==2.5.1
5+
pytest==3.1.3
6+
responses == 0.3.0
7+
flake8

requirements_test.txt

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
1-
-r requirements.txt
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile --output-file requirements_test.txt requirements_test.in
6+
#
7+
asn1crypto==0.24.0
8+
attrs==17.4.0
9+
certifi==2018.1.18
10+
cffi==1.11.5
11+
chardet==3.0.4
12+
configobj==5.0.0
13+
configparser==3.5.0 # via flake8
214
coverage==4.4.1
3-
hypothesis >= 3.11.6
15+
cryptography==2.1.4
16+
enum34==1.1.6
17+
flake8==3.5.0
18+
funcsigs==1.0.2 # via mock
19+
hypothesis==3.46.1
20+
idna==2.6
21+
ipaddress==1.0.19
22+
mccabe==0.6.1 # via flake8
23+
mock==2.0.0 # via responses
24+
netaddr==0.7.19
25+
olefile==0.45.1
26+
pbr==3.1.1 # via mock
27+
pillow==4.3.0
28+
py==1.5.2 # via pytest
29+
pycodestyle==2.3.1 # via flake8
30+
pycparser==2.18
31+
pyflakes==1.6.0 # via flake8
32+
pyjwt==1.5.3
433
pytest-cov==2.5.1
534
pytest==3.1.3
6-
responses == 0.3.0
7-
flake8
35+
requests==2.18.4
36+
responses==0.3.0
37+
six==1.11.0
38+
urllib3==1.22
39+
werkzeug==0.14.1

setup.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import shutil
1212
import stat
1313

14+
from pip.download import PipSession
15+
from pip.req import parse_requirements
16+
1417
VERSION = loris.__version__
1518

1619
EX_NOUSER = 67
@@ -55,13 +58,10 @@
5558
GROUP_DEFAULT = 'loris'
5659
GROUP_HELP = 'Group that will own the application and has permission to write to caches. [Default: %s]' % (USER_DEFAULT,)
5760

58-
DEPENDENCIES = [
59-
# (package, version, module)
60-
('werkzeug', '>=0.8.3', 'werkzeug'),
61-
('pillow', '>=2.4.0', 'PIL'),
62-
('configobj', '>=4.7.2,<=5.0.0', 'configobj'),
63-
('requests', '>=2.12.0', 'requests'),
64-
]
61+
62+
def local_file(name):
63+
return os.path.relpath(os.path.join(os.path.dirname(__file__), name))
64+
6565

6666
class LorisInstallCommand(install):
6767
description = 'Installs Loris image server'
@@ -214,15 +214,15 @@ def __update_and_deploy_config(self):
214214
config.filename = config_file_target
215215
config.write()
216216

217-
install_requires = []
218-
for d in DEPENDENCIES:
219-
try:
220-
__import__(d[2], fromlist=[''])
221-
except ImportError:
222-
install_requires.append(''.join(d[0:2]))
217+
218+
install_requires = parse_requirements(
219+
local_file('requirements.txt'), session=PipSession()
220+
)
221+
223222

224223
def _read(fname):
225-
return open(os.path.join(os.path.dirname(__file__), fname)).read()
224+
return open(local_file(fname)).read()
225+
226226

227227
setup(
228228
cmdclass={ 'install' : LorisInstallCommand },

tests/img/ycbcr-jpeg.tiff

3.74 KB
Binary file not shown.

tests/transforms_t.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,12 @@ def test_convert_to_gray_with_no_alpha_is_mode_L(self):
305305
request_path = '/%s/full/full/0/gray.jpg' % self.test_jpeg_id
306306
image = self.request_image_from_client(request_path)
307307
assert image.mode == 'L'
308+
309+
def test_jpeg_encoded_tif_can_be_retrieved(self):
310+
# This checks an issue with Pillow where attempting to load
311+
# JPEG-compressed TIFFs. The test file is taken from the test case
312+
# described in https://github.com/python-pillow/Pillow/issues/2926.
313+
#
314+
# See https://github.com/loris-imageserver/loris/issues/405
315+
request_path = '/ycbcr-jpeg.tiff/full/full/0/default.jpg'
316+
image = self.request_image_from_client(request_path)

0 commit comments

Comments
 (0)