Skip to content

Commit 436058a

Browse files
committed
work around bug in os x numpy
1 parent df24cf1 commit 436058a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

jupylet/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import sys
3030
import os
3131

32-
from .env import is_remote, has_display
32+
from .env import is_remote, has_display, is_numpy_openblas
3333

3434

3535
VERSION = '0.8.3'
@@ -44,6 +44,14 @@
4444
# mutlithreaded app.
4545
#
4646
if platform.system() == 'Darwin':
47+
if 'numpy' in sys.modules and is_numpy_openblas():
48+
sys.stderr.write(
49+
'WARNING: numpy was imported before jupylet. ' +
50+
'On Mac OS X you should import jupylet first to let it work around ' +
51+
'a bug in the algebra libraries used by numpy, that may cause the ' +
52+
'program to exit.' + '\n'
53+
)
54+
4755
os.environ['OPENBLAS_NUM_THREADS'] = '1'
4856

4957

jupylet/env.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ def is_binder_env():
103103
return 'BINDER_REQUEST' in os.environ
104104

105105

106+
def is_numpy_openblas():
107+
import numpy
108+
ll = numpy.__config__.get_info('blas_opt_info')['libraries']
109+
for l in ll:
110+
if 'openblas' in l:
111+
return True
112+
return False
113+
114+
106115
def is_osx():
107116
return platform.system().lower() == 'darwin'
108117

0 commit comments

Comments
 (0)