Skip to content

Commit 696cb9c

Browse files
authored
Merge pull request #139 from alimanfoo/use-numcodecs
Use numcodecs
2 parents 6ebd0da + c4cb428 commit 696cb9c

21 files changed

+213
-9782
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "c-blosc"]
2-
path = c-blosc
3-
url = https://github.com/Blosc/c-blosc.git

MANIFEST.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
recursive-include c-blosc *
2-
recursive-include zarr *.pxd
3-
recursive-include zarr *.pyx
4-
recursive-include zarr *.h
5-
recursive-include zarr *.c
6-
include cpuinfo.py

c-blosc

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/tutorial.rst

Lines changed: 69 additions & 89 deletions
Large diffs are not rendered by default.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
numpy
22
fasteners
3+
numcodecs

requirements_dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ fasteners==0.14.1
88
flake8==3.3.0
99
mccabe==0.6.1
1010
monotonic==1.2
11+
msgpack-python==0.4.8
1112
nose==1.3.7
13+
numcodecs==0.2.0
1214
numpy==1.12.0
1315
packaging
1416
pkginfo==1.4.1

setup.py

Lines changed: 44 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
3-
from glob import glob
4-
import os
5-
from setuptools import setup, Extension
6-
import cpuinfo
7-
import sys
8-
from distutils.command.build_ext import build_ext
9-
from distutils.errors import CCompilerError, DistutilsExecError, \
10-
DistutilsPlatformError
11-
12-
13-
PY2 = sys.version_info[0] == 2
14-
15-
16-
try:
17-
from Cython.Build import cythonize
18-
except ImportError:
19-
have_cython = False
20-
else:
21-
have_cython = True
22-
23-
24-
def blosc_extension():
25-
print('[zarr] Setting up Blosc extension')
26-
27-
# setup blosc extension
28-
blosc_sources = []
29-
extra_compile_args = []
30-
include_dirs = []
31-
define_macros = []
32-
33-
# generic setup
34-
blosc_sources += [f for f in glob('c-blosc/blosc/*.c')
35-
if 'avx2' not in f and 'sse2' not in f]
36-
blosc_sources += glob('c-blosc/internal-complibs/lz4*/*.c')
37-
blosc_sources += glob('c-blosc/internal-complibs/snappy*/*.cc')
38-
blosc_sources += glob('c-blosc/internal-complibs/zlib*/*.c')
39-
blosc_sources += glob('c-blosc/internal-complibs/zstd*/common/*.c')
40-
blosc_sources += glob('c-blosc/internal-complibs/zstd*/compress/*.c')
41-
blosc_sources += glob('c-blosc/internal-complibs/zstd*/decompress/*.c')
42-
blosc_sources += glob('c-blosc/internal-complibs/zstd*/dictBuilder/*.c')
43-
include_dirs += [os.path.join('c-blosc', 'blosc')]
44-
include_dirs += [d for d in glob('c-blosc/internal-complibs/*')
45-
if os.path.isdir(d)]
46-
include_dirs += [d for d in glob('c-blosc/internal-complibs/*/*')
47-
if os.path.isdir(d)]
48-
define_macros += [('HAVE_LZ4', 1),
49-
('HAVE_SNAPPY', 1),
50-
('HAVE_ZLIB', 1),
51-
('HAVE_ZSTD', 1)]
52-
# define_macros += [('CYTHON_TRACE', '1')]
53-
54-
# determine CPU support for SSE2 and AVX2
55-
cpu_info = cpuinfo.get_cpu_info()
56-
57-
# SSE2
58-
if 'sse2' in cpu_info['flags']:
59-
print('[zarr] SSE2 detected')
60-
extra_compile_args.append('-DSHUFFLE_SSE2_ENABLED')
61-
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'sse2' in f]
62-
if os.name == 'posix':
63-
extra_compile_args.append('-msse2')
64-
elif os.name == 'nt':
65-
define_macros += [('__SSE2__', 1)]
66-
67-
# AVX2
68-
if 'avx2' in cpu_info['flags']:
69-
print('[zarr] AVX2 detected')
70-
extra_compile_args.append('-DSHUFFLE_AVX2_ENABLED')
71-
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'avx2' in f]
72-
if os.name == 'posix':
73-
extra_compile_args.append('-mavx2')
74-
elif os.name == 'nt':
75-
define_macros += [('__AVX2__', 1)]
76-
77-
# workaround lack of support for "inline" in MSVC when building for Python
78-
# 2.7 64-bit
79-
if PY2 and os.name == 'nt':
80-
extra_compile_args.append('-Dinline=__inline')
81-
82-
if have_cython:
83-
sources = ['zarr/blosc.pyx']
84-
else:
85-
sources = ['zarr/blosc.c']
86-
87-
# define extension module
88-
extensions = [
89-
Extension('zarr.blosc',
90-
sources=sources + blosc_sources,
91-
include_dirs=include_dirs,
92-
define_macros=define_macros,
93-
extra_compile_args=extra_compile_args,
94-
),
95-
]
96-
97-
if have_cython:
98-
extensions = cythonize(extensions)
99-
100-
return extensions
101-
102-
103-
if sys.platform == 'win32':
104-
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
105-
IOError, ValueError)
106-
else:
107-
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
108-
109-
110-
class BuildFailed(Exception):
111-
pass
112-
113-
114-
class ve_build_ext(build_ext):
115-
# This class allows C extension building to fail.
116-
117-
def run(self):
118-
try:
119-
build_ext.run(self)
120-
except DistutilsPlatformError as e:
121-
print('[zarr] ERROR', e, file=sys.stderr)
122-
raise BuildFailed()
123-
124-
def build_extension(self, ext):
125-
try:
126-
build_ext.build_extension(self, ext)
127-
except ext_errors as e:
128-
print('[zarr] ERROR', e, file=sys.stderr)
129-
raise BuildFailed()
3+
from setuptools import setup
1304

1315

1326
DESCRIPTION = 'A minimal implementation of chunked, compressed, ' \
@@ -135,71 +9,46 @@ def build_extension(self, ext):
1359
with open('README.rst') as f:
13610
LONG_DESCRIPTION = f.read()
13711

138-
139-
def run_setup(with_extensions):
140-
141-
if with_extensions:
142-
ext_modules = blosc_extension()
143-
cmdclass = dict(build_ext=ve_build_ext)
144-
else:
145-
ext_modules = []
146-
cmdclass = dict()
147-
148-
setup(
149-
name='zarr',
150-
description=DESCRIPTION,
151-
long_description=LONG_DESCRIPTION,
152-
use_scm_version={
153-
'version_scheme': 'guess-next-dev',
154-
'local_scheme': 'dirty-tag',
155-
'write_to': 'zarr/version.py'
156-
},
157-
setup_requires=[
158-
'setuptools>18.0',
159-
'setuptools-scm>1.5.4'
160-
],
161-
install_requires=[
162-
'numpy>=1.7',
163-
'fasteners',
164-
],
165-
ext_modules=ext_modules,
166-
cmdclass=cmdclass,
167-
package_dir={'': '.'},
168-
packages=['zarr', 'zarr.tests'],
169-
classifiers=[
170-
'Development Status :: 4 - Beta',
171-
'Intended Audience :: Developers',
172-
'Intended Audience :: Information Technology',
173-
'Intended Audience :: Science/Research',
174-
'License :: OSI Approved :: MIT License',
175-
'Programming Language :: Python',
176-
'Topic :: Software Development :: Libraries :: Python Modules',
177-
'Operating System :: Unix',
178-
'Programming Language :: Python :: 2',
179-
'Programming Language :: Python :: 2.7',
180-
'Programming Language :: Python :: 3',
181-
'Programming Language :: Python :: 3.4',
182-
'Programming Language :: Python :: 3.5',
183-
],
184-
author='Alistair Miles',
185-
author_email='[email protected]',
186-
maintainer='Alistair Miles',
187-
maintainer_email='[email protected]',
188-
url='https://github.com/alimanfoo/zarr',
189-
license='MIT',
190-
)
191-
192-
193-
if __name__ == '__main__':
194-
is_pypy = hasattr(sys, 'pypy_translation_info')
195-
196-
try:
197-
run_setup(not is_pypy)
198-
except BuildFailed:
199-
print('[zarr]' + ('*' * 75), file=sys.stderr)
200-
print('[zarr] WARNING compilation of the Blosc C extension failed.',
201-
file=sys.stderr)
202-
print('[zarr] Retrying installation without C extensions...',
203-
file=sys.stderr)
204-
print('[zarr]' + ('*' * 75), file=sys.stderr)
205-
run_setup(False)
12+
setup(
13+
name='zarr',
14+
description=DESCRIPTION,
15+
long_description=LONG_DESCRIPTION,
16+
use_scm_version={
17+
'version_scheme': 'guess-next-dev',
18+
'local_scheme': 'dirty-tag',
19+
'write_to': 'zarr/version.py'
20+
},
21+
setup_requires=[
22+
'setuptools>18.0',
23+
'setuptools-scm>1.5.4'
24+
],
25+
install_requires=[
26+
'numpy>=1.7',
27+
'fasteners',
28+
'numcodecs>=0.2.0',
29+
],
30+
package_dir={'': '.'},
31+
packages=['zarr', 'zarr.tests'],
32+
classifiers=[
33+
'Development Status :: 4 - Beta',
34+
'Intended Audience :: Developers',
35+
'Intended Audience :: Information Technology',
36+
'Intended Audience :: Science/Research',
37+
'License :: OSI Approved :: MIT License',
38+
'Programming Language :: Python',
39+
'Topic :: Software Development :: Libraries :: Python Modules',
40+
'Operating System :: Unix',
41+
'Programming Language :: Python :: 2',
42+
'Programming Language :: Python :: 2.7',
43+
'Programming Language :: Python :: 3',
44+
'Programming Language :: Python :: 3.4',
45+
'Programming Language :: Python :: 3.5',
46+
'Programming Language :: Python :: 3.6',
47+
],
48+
author='Alistair Miles',
49+
author_email='[email protected]',
50+
maintainer='Alistair Miles',
51+
maintainer_email='[email protected]',
52+
url='https://github.com/alimanfoo/zarr',
53+
license='MIT',
54+
)

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ envlist = py27, py34, py35, py36, docs
1010
setenv =
1111
PYTHONHASHSEED = 42
1212
commands =
13-
py27: pip install -U backports.lzma
1413
python setup.py build_ext --inplace
1514
py27,py34,py35: nosetests -v --with-coverage --cover-erase --cover-package=zarr zarr
16-
py36: nosetests -v --with-coverage --cover-erase --cover-package=zarr --with-doctest --doctest-options=+NORMALIZE_WHITESPACE zarr
15+
py36: nosetests -v --with-coverage --cover-erase --cover-package=zarr --with-doctest --doctest-options=+NORMALIZE_WHITESPACE,+ELLIPSIS zarr
1716
py36: python -m doctest -o NORMALIZE_WHITESPACE -o ELLIPSIS docs/tutorial.rst docs/spec/v2.rst
1817
py36: flake8 --max-line-length=100 zarr
1918
python setup.py bdist_wheel

0 commit comments

Comments
 (0)