Skip to content

Commit 3496462

Browse files
committed
compile blosc extension on windows
1 parent 46721d1 commit 3496462

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

setup.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ def blosc_extension():
4545
if 'sse2' in cpu_info['flags']:
4646
print('[zarr] SSE2 detected')
4747
extra_compile_args.append('-DSHUFFLE_SSE2_ENABLED')
48-
extra_compile_args.append('-msse2')
4948
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'sse2' in f]
49+
if os.name == 'posix':
50+
extra_compile_args.append('-msse2')
51+
elif os.name == 'nt':
52+
define_macros += [('__SSE2__', 1)]
5053

5154
# AVX2
5255
if 'avx2' in cpu_info['flags']:
5356
print('[zarr] AVX2 detected')
5457
extra_compile_args.append('-DSHUFFLE_AVX2_ENABLED')
55-
extra_compile_args.append('-mavx2')
5658
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'avx2' in f]
59+
if os.name == 'posix':
60+
extra_compile_args.append('-mavx2')
61+
elif os.name == 'nt':
62+
define_macros += [('__AVX2__', 1)]
5763

5864
if have_cython:
5965
sources = ['zarr/blosc.pyx']
@@ -93,13 +99,15 @@ class ve_build_ext(build_ext):
9399
def run(self):
94100
try:
95101
build_ext.run(self)
96-
except DistutilsPlatformError:
102+
except DistutilsPlatformError as e:
103+
print('[zarr] ERROR', e, file=sys.stderr)
97104
raise BuildFailed()
98105

99106
def build_extension(self, ext):
100107
try:
101108
build_ext.build_extension(self, ext)
102-
except ext_errors:
109+
except ext_errors as e:
110+
print('[zarr] ERROR', e, file=sys.stderr)
103111
raise BuildFailed()
104112

105113

@@ -166,13 +174,14 @@ def run_setup(with_extensions):
166174

167175
if __name__ == '__main__':
168176
is_pypy = hasattr(sys, 'pypy_translation_info')
169-
is_posix = os.name == 'posix'
170177

171178
try:
172-
run_setup(is_posix and not is_pypy)
179+
run_setup(not is_pypy)
173180
except BuildFailed:
174-
print('[zarr]' + ('*' * 75))
175-
print('[zarr] WARNING compilation of the Blosc C extension failed.')
176-
print('[zarr] Retrying installation without C extensions...')
177-
print('[zarr]' + ('*' * 75))
181+
print('[zarr]' + ('*' * 75), file=sys.stderr)
182+
print('[zarr] WARNING compilation of the Blosc C extension failed.',
183+
file=sys.stderr)
184+
print('[zarr] Retrying installation without C extensions...',
185+
file=sys.stderr)
186+
print('[zarr]' + ('*' * 75), file=sys.stderr)
178187
run_setup(False)

zarr/blosc.c

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)