Skip to content

Commit d4e01f4

Browse files
authored
Merge pull request #123 from jakirkham/add_py2_lzma
Support LZMA on Python 2 via backports.lzma
2 parents 31de15d + 3412bf3 commit d4e01f4

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
language: python
22

3+
sudo: false
4+
5+
addons:
6+
apt:
7+
packages:
8+
- liblzma-dev
9+
310
python:
411
- 2.7
512
- 3.4

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ envlist = py27, py34, py35, py36, docs
1010
setenv =
1111
PYTHONHASHSEED = 42
1212
commands =
13+
py27: pip install -U backports.lzma
1314
python setup.py build_ext --inplace
1415
py27,py34,py35: nosetests -v --with-coverage --cover-erase --cover-package=zarr zarr
1516
py36: nosetests -v --with-coverage --cover-erase --cover-package=zarr --with-doctest --doctest-options=+NORMALIZE_WHITESPACE zarr

zarr/codecs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,16 @@ def __repr__(self):
241241
codec_registry[BZ2.codec_id] = BZ2
242242

243243

244+
lzma = None
244245
try:
245246
import lzma
246247
except ImportError: # pragma: no cover
247-
pass
248-
else:
248+
try:
249+
from backports import lzma
250+
except ImportError:
251+
pass
252+
253+
if lzma:
249254

250255
# noinspection PyShadowingBuiltins
251256
class LZMA(Codec):

zarr/tests/test_codecs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,16 @@ def test_decode(self):
201201
self._test_decode_lossless(arr, **config)
202202

203203

204+
lzma = None
204205
try:
205206
import lzma
206207
except ImportError: # pragma: no cover
207-
pass
208-
else:
208+
try:
209+
from backports import lzma
210+
except ImportError:
211+
pass
212+
213+
if lzma:
209214

210215
class TestLZMA(CodecTests, unittest.TestCase):
211216

0 commit comments

Comments
 (0)