Skip to content

Commit e7708c9

Browse files
author
Joe Hamman
authored
Merge pull request #470 from jhamman/drop_py2
Drop Python 2 Support
2 parents 9949654 + 67bce7e commit e7708c9

38 files changed

+299
-552
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ services:
2424

2525
matrix:
2626
include:
27-
- python: 2.7
2827
- python: 3.5
2928
- python: 3.6
3029
- python: 3.7

appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ environment:
1818

1919
matrix:
2020

21-
- PYTHON: "C:\\Python27-x64"
22-
PYTHON_VERSION: "2.7"
23-
DISTUTILS_USE_SDK: "1"
24-
2521
- PYTHON: "C:\\Python35-x64"
2622
PYTHON_VERSION: "3.5"
2723

bench/compress_normal.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import numpy as np
21
import sys
3-
sys.path.insert(0, '..')
4-
import zarr
5-
import line_profiler
62
import timeit
3+
4+
import numpy as np
5+
6+
import line_profiler
7+
import zarr
78
from zarr import blosc
89

10+
sys.path.insert(0, '..')
11+
912
# setup
1013
a = np.random.normal(2000, 1000, size=200000000).astype('u2')
1114
z = zarr.empty_like(a, chunks=1000000, compression='blosc', compression_opts=dict(cname='lz4', clevel=5, shuffle=2))

build.cmd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ SET COMMAND_TO_RUN=%*
2323
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
2424

2525
SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
26-
IF %MAJOR_PYTHON_VERSION% == "2" (
27-
SET WINDOWS_SDK_VERSION="v7.0"
28-
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
26+
IF %MAJOR_PYTHON_VERSION% == "3" (
2927
SET WINDOWS_SDK_VERSION="v7.1"
3028
) ELSE (
3129
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"

docs/conf.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,15 @@
1414
# serve to show the default.
1515

1616

17-
import sys
1817
import os
19-
from mock import Mock as MagicMock
20-
21-
22-
PY2 = sys.version_info[0] == 2
23-
24-
25-
class Mock(MagicMock):
26-
@classmethod
27-
def __getattr__(cls, name):
28-
return Mock()
29-
30-
31-
MOCK_MODULES = []
32-
if PY2:
33-
MOCK_MODULES.append('lzma')
34-
35-
36-
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
18+
import sys
3719

20+
# The version info for the project you're documenting, acts as replacement for
21+
# |version| and |release|, also used in various other places throughout the
22+
# built documents.
23+
#
24+
# The short X.Y version.
25+
import zarr
3826

3927
# If extensions (or modules to document with autodoc) are in another directory,
4028
# add these directories to sys.path here. If the directory is relative to the
@@ -81,12 +69,6 @@ def __getattr__(cls, name):
8169
copyright = '2018, Zarr Developers'
8270
author = 'Zarr Developers'
8371

84-
# The version info for the project you're documenting, acts as replacement for
85-
# |version| and |release|, also used in various other places throughout the
86-
# built documents.
87-
#
88-
# The short X.Y version.
89-
import zarr
9072
version = zarr.__version__
9173
# The full version, including alpha/beta/rc tags.
9274
release = zarr.__version__

docs/release.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Upcoming Release
1818
* Do not rename Blosc parameters in n5 backend and add `blocksize` parameter,
1919
compatible with n5-blosc.
2020

21+
* Removed support for Python 2.
22+
By :user:`jhamman`; :issue:`393`, :issue:`470`.
23+
2124
.. _release_2.3.2:
2225

2326
2.3.2

setup.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, division
3-
from setuptools import setup
42
import sys
53

4+
from setuptools import setup
65

76
DESCRIPTION = 'An implementation of chunked, compressed, ' \
87
'N-dimensional arrays for Python.'
@@ -17,11 +16,6 @@
1716
'numcodecs>=0.6.2',
1817
]
1918

20-
if sys.version_info < (3, 5):
21-
dependencies.append('scandir')
22-
if sys.version_info < (3, 3) and sys.platform == "win32":
23-
dependencies.append('pyosreplace')
24-
2519
setup(
2620
name='zarr',
2721
description=DESCRIPTION,
@@ -35,6 +29,7 @@
3529
'setuptools>18.0',
3630
'setuptools-scm>1.5.4'
3731
],
32+
python_requires='>=3.5',
3833
install_requires=dependencies,
3934
package_dir={'': '.'},
4035
packages=['zarr', 'zarr.tests'],
@@ -47,8 +42,6 @@
4742
'Programming Language :: Python',
4843
'Topic :: Software Development :: Libraries :: Python Modules',
4944
'Operating System :: Unix',
50-
'Programming Language :: Python :: 2',
51-
'Programming Language :: Python :: 2.7',
5245
'Programming Language :: Python :: 3',
5346
'Programming Language :: Python :: 3.5',
5447
'Programming Language :: Python :: 3.6',

tox.ini

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py27, py35, py36, py37-npy{115,116,latest}, docs
7+
envlist = py35, py36, py37-npy{115,116,latest}, docs
88

99
[testenv]
1010
install_command = pip install --no-binary=numcodecs {opts} {packages}
1111
setenv =
1212
PYTHONHASHSEED = 42
13-
# hooks for coverage exclusions based on Python major version
14-
py35,py36,py37: PY_MAJOR_VERSION = py3
15-
py27: PY_MAJOR_VERSION = py2
1613
passenv =
1714
ZARR_TEST_ABS
1815
ZARR_TEST_MONGO
@@ -21,24 +18,23 @@ commands =
2118
# clear out any data files generated during tests
2219
python -c 'import glob; import shutil; import os; [(shutil.rmtree(d) if os.path.isdir(d) else os.remove(d) if os.path.isfile(d) else None) for d in glob.glob("./example*")]'
2320
# main unit test runner
24-
py27,py35,py36: pytest -v --cov=zarr --cov-config=.coveragerc zarr
21+
py35,py36: pytest -v --cov=zarr --cov-config=.coveragerc zarr
2522
# don't collect coverage when running older numpy versions
2623
py37-{npy115,npy116}: pytest -v zarr
2724
# collect coverage and run doctests under py37
2825
py37-npylatest: pytest -v --cov=zarr --cov-config=.coveragerc --doctest-plus zarr --remote-data
2926
# generate a coverage report
30-
py27,py35,py36,py37-npylatest: coverage report -m
27+
py35,py36,py37-npylatest: coverage report -m
3128
# run doctests in the tutorial and spec
3229
py37-npylatest: python -m doctest -o NORMALIZE_WHITESPACE -o ELLIPSIS docs/tutorial.rst docs/spec/v2.rst
3330
# pep8 checks
3431
py37-npylatest: flake8 zarr
3532
# print environment for debugging
3633
pip freeze
3734
deps =
38-
py27: backports.lzma
3935
py37-npy115: numpy==1.15.4
4036
py37-npy116: numpy==1.16.4
41-
py27,py35,py36,py37-npylatest: -rrequirements_dev_numpy.txt
37+
py35,py36,py37-npylatest: -rrequirements_dev_numpy.txt
4238
-rrequirements_dev_minimal.txt
4339
-rrequirements_dev_optional.txt
4440

zarr/__init__.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# -*- coding: utf-8 -*-
22
# flake8: noqa
3-
from __future__ import absolute_import, print_function, division
4-
5-
6-
from zarr.core import Array
7-
from zarr.creation import (empty, zeros, ones, full, array, empty_like, zeros_like,
8-
ones_like, full_like, open_array, open_like, create)
9-
from zarr.storage import (DictStore, MemoryStore, DirectoryStore, ZipStore, TempStore,
10-
NestedDirectoryStore, DBMStore, LMDBStore, SQLiteStore,
11-
LRUStoreCache, ABSStore, RedisStore, MongoDBStore)
12-
from zarr.hierarchy import group, open_group, Group
13-
from zarr.sync import ThreadSynchronizer, ProcessSynchronizer
143
from zarr.codecs import *
15-
from zarr.convenience import (open, save, save_array, save_group, load, copy_store,
16-
copy, copy_all, tree, consolidate_metadata,
17-
open_consolidated)
4+
from zarr.convenience import (consolidate_metadata, copy, copy_all, copy_store,
5+
load, open, open_consolidated, save, save_array,
6+
save_group, tree)
7+
from zarr.core import Array
8+
from zarr.creation import (array, create, empty, empty_like, full, full_like,
9+
ones, ones_like, open_array, open_like, zeros,
10+
zeros_like)
11+
from zarr.errors import CopyError, MetadataError
12+
from zarr.hierarchy import Group, group, open_group
1813
from zarr.n5 import N5Store
19-
from zarr.errors import CopyError, MetadataError, PermissionError
14+
from zarr.storage import (ABSStore, DBMStore, DictStore, DirectoryStore,
15+
LMDBStore, LRUStoreCache, MemoryStore, MongoDBStore,
16+
NestedDirectoryStore, RedisStore, SQLiteStore,
17+
TempStore, ZipStore)
18+
from zarr.sync import ProcessSynchronizer, ThreadSynchronizer
2019
from zarr.version import version as __version__

zarr/attrs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, division
2+
from collections.abc import MutableMapping
33

4-
5-
from zarr.compat import MutableMapping
6-
from zarr.errors import PermissionError
74
from zarr.meta import parse_metadata
85
from zarr.util import json_dumps
96

zarr/codecs.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# -*- coding: utf-8 -*-
22
# flake8: noqa
3-
from __future__ import absolute_import, print_function, division
4-
5-
63
from numcodecs import *
74
from numcodecs.registry import codec_registry

zarr/compat.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

zarr/convenience.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# -*- coding: utf-8 -*-
22
"""Convenience functions for storing and loading data."""
3-
from __future__ import absolute_import, print_function, division
43
import io
5-
import re
64
import itertools
7-
5+
import re
6+
from collections.abc import Mapping
87

98
from zarr.core import Array
10-
from zarr.creation import (open_array, normalize_store_arg,
11-
array as _create_array)
12-
from zarr.hierarchy import open_group, group as _create_group, Group
13-
from zarr.storage import contains_array, contains_group
14-
from zarr.errors import err_path_not_found, CopyError
15-
from zarr.util import normalize_storage_path, TreeViewer, buffer_size
16-
from zarr.compat import Mapping, PY2, text_type
9+
from zarr.creation import array as _create_array
10+
from zarr.creation import normalize_store_arg, open_array
11+
from zarr.errors import CopyError, err_path_not_found
12+
from zarr.hierarchy import Group
13+
from zarr.hierarchy import group as _create_group
14+
from zarr.hierarchy import open_group
1715
from zarr.meta import json_dumps, json_loads
16+
from zarr.storage import contains_array, contains_group
17+
from zarr.util import TreeViewer, buffer_size, normalize_storage_path
1818

1919

2020
# noinspection PyShadowingBuiltins
@@ -451,9 +451,6 @@ def __exit__(self, *args):
451451
def __call__(self, *args, **kwargs):
452452
if self.log_file is not None:
453453
kwargs['file'] = self.log_file
454-
if PY2: # pragma: py3 no cover
455-
# expect file opened in text mode, need to adapt message
456-
args = [text_type(a) for a in args]
457454
print(*args, **kwargs)
458455
if hasattr(self.log_file, 'flush'):
459456
# get immediate feedback

0 commit comments

Comments
 (0)