Skip to content

Commit dd5195e

Browse files
Add library_dirs to compilation path
When building with conda-build, setup.py needs to find $PREFIX/Library/libs and $PREFIX/Library/include. Logic is based on mkl_fft/mkl_fft/setup.py.
1 parent 155b12a commit dd5195e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

mkl_random/setup.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626

2727
from __future__ import division, print_function
2828

29-
from os.path import join, split, dirname, abspath
29+
import os
3030
import sys
31+
from os.path import join, split, dirname, abspath
3132
from distutils.msvccompiler import get_build_version as get_msvc_build_version
3233
from numpy import get_include as get_numpy_include
3334
from distutils.sysconfig import get_python_inc as get_python_include
@@ -48,8 +49,19 @@ def configuration(parent_package='',top_path=None):
4849
from numpy.distutils.system_info import get_info
4950

5051
config = Configuration('mkl_random', parent_package, top_path)
51-
52-
libs = get_info('mkl').get('libraries', ['mkl_rt'])
52+
mkl_root = os.getenv('MKLROOT', None)
53+
if mkl_root:
54+
mkl_info = {
55+
'include_dirs': [join(mkl_root, 'include')],
56+
'library_dirs': [join(mkl_root, 'lib'), join(mkl_root, 'lib', 'intel64')],
57+
'libraries': ['mkl_rt']
58+
}
59+
else:
60+
mkl_info = get_info('mkl')
61+
62+
mkl_include_dirs = mkl_info.get('include_dirs', [])
63+
mkl_library_dirs = mkl_info.get('library_dirs', [])
64+
libs = mkl_info.get('libraries', ['mkl_rt'])
5365
if sys.platform == 'win32':
5466
libs.append('Advapi32')
5567

@@ -95,7 +107,8 @@ def configuration(parent_package='',top_path=None):
95107
name='mklrand',
96108
sources=sources,
97109
libraries=libs,
98-
include_dirs=[wdir,pdir],
110+
include_dirs=[wdir,pdir] + mkl_include_dirs,
111+
library_dirs=mkl_library_dirs,
99112
define_macros=defs,
100113
)
101114

0 commit comments

Comments
 (0)