Blob Blame History Raw
From 74191d2b2652122be5cf3610a073060cb039fa23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Fri, 23 Sep 2016 21:25:19 -0400
Subject: [PATCH] setup.py: gracefuly handle cpuinfo failure

When comping on aarch64, setup.py fails with:
Exception: py-cpuinfo currently only works on X86 and some ARM CPUs.
Assume that the CPU does not support SSE2 or AVX in importing cpuinfo fails
and continue.
---
 setup.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index 6b64a571c3..b0dc5bf12a 100755
--- a/setup.py
+++ b/setup.py
@@ -32,8 +32,13 @@ import distutils.spawn
 from setuptools.command.build_ext import build_ext
 
 # For guessing the capabilities of the CPU for C-Blosc
-import cpuinfo
-cpu_info = cpuinfo.get_cpu_info()
+try:
+    import cpuinfo
+    cpu_info = cpuinfo.get_cpu_info()
+    cpu_flags = cpu_info['flags']
+except Exception as e:
+    print('cpuinfo failed, assuming no CPU features:', e)
+    cpu_flags = []
 
 # The name for the pkg-config utility
 PKG_CONFIG = 'pkg-config'
@@ -812,7 +817,7 @@ if 'BLOSC' not in optional_libs:
             os.remove(fd.name)
 
     # SSE2
-    if 'sse2' in cpu_info['flags']:
+    if 'sse2' in cpu_flags:
         print('SSE2 detected')
         CFLAGS.append('-DSHUFFLE_SSE2_ENABLED')
         if os.name == 'nt':
@@ -826,7 +831,7 @@ if 'BLOSC' not in optional_libs:
                           if 'sse2' in f]
     # AVX2
     # Detection code for AVX2 only works for gcc/clang, not for MSVC yet
-    if ('avx2' in cpu_info['flags'] and
+    if ('avx2' in cpu_flags and
         compiler_has_flags(compiler, ["-mavx2"])):
         print('AVX2 detected')
         CFLAGS.append('-DSHUFFLE_AVX2_ENABLED')
-- 
2.9.0