Skip to content

Commit

Permalink
Merge pull request #470 from jhamman/drop_py2
Browse files Browse the repository at this point in the history
Drop Python 2 Support
  • Loading branch information
Joe Hamman committed Oct 19, 2019
2 parents 9949654 + 67bce7e commit e7708c9
Show file tree
Hide file tree
Showing 38 changed files with 299 additions and 552 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:

matrix:
include:
- python: 2.7
- python: 3.5
- python: 3.6
- python: 3.7
Expand Down
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ environment:

matrix:

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7"
DISTUTILS_USE_SDK: "1"

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"

Expand Down
11 changes: 7 additions & 4 deletions bench/compress_normal.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import numpy as np
import sys
sys.path.insert(0, '..')
import zarr
import line_profiler
import timeit

import numpy as np

import line_profiler
import zarr
from zarr import blosc

sys.path.insert(0, '..')

# setup
a = np.random.normal(2000, 1000, size=200000000).astype('u2')
z = zarr.empty_like(a, chunks=1000000, compression='blosc', compression_opts=dict(cname='lz4', clevel=5, shuffle=2))
Expand Down
4 changes: 1 addition & 3 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
IF %MAJOR_PYTHON_VERSION% == "3" (
SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
Expand Down
32 changes: 7 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,15 @@
# serve to show the default.


import sys
import os
from mock import Mock as MagicMock


PY2 = sys.version_info[0] == 2


class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()


MOCK_MODULES = []
if PY2:
MOCK_MODULES.append('lzma')


sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
import sys

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

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

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
import zarr
version = zarr.__version__
# The full version, including alpha/beta/rc tags.
release = zarr.__version__
Expand Down
3 changes: 3 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Upcoming Release
* Do not rename Blosc parameters in n5 backend and add `blocksize` parameter,
compatible with n5-blosc.

* Removed support for Python 2.
By :user:`jhamman`; :issue:`393`, :issue:`470`.

.. _release_2.3.2:

2.3.2
Expand Down
11 changes: 2 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
from setuptools import setup
import sys

from setuptools import setup

DESCRIPTION = 'An implementation of chunked, compressed, ' \
'N-dimensional arrays for Python.'
Expand All @@ -17,11 +16,6 @@
'numcodecs>=0.6.2',
]

if sys.version_info < (3, 5):
dependencies.append('scandir')
if sys.version_info < (3, 3) and sys.platform == "win32":
dependencies.append('pyosreplace')

setup(
name='zarr',
description=DESCRIPTION,
Expand All @@ -35,6 +29,7 @@
'setuptools>18.0',
'setuptools-scm>1.5.4'
],
python_requires='>=3.5',
install_requires=dependencies,
package_dir={'': '.'},
packages=['zarr', 'zarr.tests'],
Expand All @@ -47,8 +42,6 @@
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: Unix',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down
12 changes: 4 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
# and then run "tox" from this directory.

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

[testenv]
install_command = pip install --no-binary=numcodecs {opts} {packages}
setenv =
PYTHONHASHSEED = 42
# hooks for coverage exclusions based on Python major version
py35,py36,py37: PY_MAJOR_VERSION = py3
py27: PY_MAJOR_VERSION = py2
passenv =
ZARR_TEST_ABS
ZARR_TEST_MONGO
Expand All @@ -21,24 +18,23 @@ commands =
# clear out any data files generated during tests
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*")]'
# main unit test runner
py27,py35,py36: pytest -v --cov=zarr --cov-config=.coveragerc zarr
py35,py36: pytest -v --cov=zarr --cov-config=.coveragerc zarr
# don't collect coverage when running older numpy versions
py37-{npy115,npy116}: pytest -v zarr
# collect coverage and run doctests under py37
py37-npylatest: pytest -v --cov=zarr --cov-config=.coveragerc --doctest-plus zarr --remote-data
# generate a coverage report
py27,py35,py36,py37-npylatest: coverage report -m
py35,py36,py37-npylatest: coverage report -m
# run doctests in the tutorial and spec
py37-npylatest: python -m doctest -o NORMALIZE_WHITESPACE -o ELLIPSIS docs/tutorial.rst docs/spec/v2.rst
# pep8 checks
py37-npylatest: flake8 zarr
# print environment for debugging
pip freeze
deps =
py27: backports.lzma
py37-npy115: numpy==1.15.4
py37-npy116: numpy==1.16.4
py27,py35,py36,py37-npylatest: -rrequirements_dev_numpy.txt
py35,py36,py37-npylatest: -rrequirements_dev_numpy.txt
-rrequirements_dev_minimal.txt
-rrequirements_dev_optional.txt

Expand Down
29 changes: 14 additions & 15 deletions zarr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# -*- coding: utf-8 -*-
# flake8: noqa
from __future__ import absolute_import, print_function, division


from zarr.core import Array
from zarr.creation import (empty, zeros, ones, full, array, empty_like, zeros_like,
ones_like, full_like, open_array, open_like, create)
from zarr.storage import (DictStore, MemoryStore, DirectoryStore, ZipStore, TempStore,
NestedDirectoryStore, DBMStore, LMDBStore, SQLiteStore,
LRUStoreCache, ABSStore, RedisStore, MongoDBStore)
from zarr.hierarchy import group, open_group, Group
from zarr.sync import ThreadSynchronizer, ProcessSynchronizer
from zarr.codecs import *
from zarr.convenience import (open, save, save_array, save_group, load, copy_store,
copy, copy_all, tree, consolidate_metadata,
open_consolidated)
from zarr.convenience import (consolidate_metadata, copy, copy_all, copy_store,
load, open, open_consolidated, save, save_array,
save_group, tree)
from zarr.core import Array
from zarr.creation import (array, create, empty, empty_like, full, full_like,
ones, ones_like, open_array, open_like, zeros,
zeros_like)
from zarr.errors import CopyError, MetadataError
from zarr.hierarchy import Group, group, open_group
from zarr.n5 import N5Store
from zarr.errors import CopyError, MetadataError, PermissionError
from zarr.storage import (ABSStore, DBMStore, DictStore, DirectoryStore,
LMDBStore, LRUStoreCache, MemoryStore, MongoDBStore,
NestedDirectoryStore, RedisStore, SQLiteStore,
TempStore, ZipStore)
from zarr.sync import ProcessSynchronizer, ThreadSynchronizer
from zarr.version import version as __version__
5 changes: 1 addition & 4 deletions zarr/attrs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
from collections.abc import MutableMapping


from zarr.compat import MutableMapping
from zarr.errors import PermissionError
from zarr.meta import parse_metadata
from zarr.util import json_dumps

Expand Down
3 changes: 0 additions & 3 deletions zarr/codecs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# flake8: noqa
from __future__ import absolute_import, print_function, division


from numcodecs import *
from numcodecs.registry import codec_registry
39 changes: 0 additions & 39 deletions zarr/compat.py

This file was deleted.

23 changes: 10 additions & 13 deletions zarr/convenience.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
"""Convenience functions for storing and loading data."""
from __future__ import absolute_import, print_function, division
import io
import re
import itertools

import re
from collections.abc import Mapping

from zarr.core import Array
from zarr.creation import (open_array, normalize_store_arg,
array as _create_array)
from zarr.hierarchy import open_group, group as _create_group, Group
from zarr.storage import contains_array, contains_group
from zarr.errors import err_path_not_found, CopyError
from zarr.util import normalize_storage_path, TreeViewer, buffer_size
from zarr.compat import Mapping, PY2, text_type
from zarr.creation import array as _create_array
from zarr.creation import normalize_store_arg, open_array
from zarr.errors import CopyError, err_path_not_found
from zarr.hierarchy import Group
from zarr.hierarchy import group as _create_group
from zarr.hierarchy import open_group
from zarr.meta import json_dumps, json_loads
from zarr.storage import contains_array, contains_group
from zarr.util import TreeViewer, buffer_size, normalize_storage_path


# noinspection PyShadowingBuiltins
Expand Down Expand Up @@ -451,9 +451,6 @@ def __exit__(self, *args):
def __call__(self, *args, **kwargs):
if self.log_file is not None:
kwargs['file'] = self.log_file
if PY2: # pragma: py3 no cover
# expect file opened in text mode, need to adapt message
args = [text_type(a) for a in args]
print(*args, **kwargs)
if hasattr(self.log_file, 'flush'):
# get immediate feedback
Expand Down
Loading

0 comments on commit e7708c9

Please sign in to comment.