Skip to content

Commit 9ad4e16

Browse files
authored
Fix exception from accessing cpu_info when it is None
If `cpuinfo` fails to import, then `cpu_info` is set to `None` at the top of this file. But in the `sse2` check, `cpu_info` is accessed without first checking if it is `None`, causing the build to fail. This fix errs on the conservative side, assuming that we do not want to build SSE2 if `cpu_info` could not be imported. It's possible a similar change is needed on the next line for AVX2, but I wasn't sure why there was no `'avx2' not in cpu_info['flags']` condition there.
1 parent c8ae646 commit 9ad4e16

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def cmake_bool(cond):
8787
platforms = ['any'],
8888
cmake_args = [
8989
'-DBLOSC_DIR:PATH=%s' % os.environ.get('BLOSC_DIR', ''),
90-
'-DDEACTIVATE_SSE2:BOOL=%s' % cmake_bool('DISABLE_BLOSC_SSE2' in os.environ or 'sse2' not in cpu_info['flags']),
90+
'-DDEACTIVATE_SSE2:BOOL=%s' % cmake_bool(('DISABLE_BLOSC_SSE2' in os.environ) or (cpu_info is None) or ('sse2' not in cpu_info['flags'])),
9191
'-DDEACTIVATE_AVX2:BOOL=%s' % cmake_bool('DISABLE_BLOSC_AVX2' in os.environ),
9292
'-DDEACTIVATE_LZ4:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_LZ4', '1'))),
9393
# Snappy is disabled by default

0 commit comments

Comments
 (0)