Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support: allow blas & lapack dirs to be specified by user

  • Loading branch information...
commit a899da80258b48bcbd445d15147c29b03a2cb5fa 1 parent ace8e75
@strohel authored
Showing with 31 additions and 3 deletions.
  1. +14 −1 support/dist.py
  2. +17 −2 support/dist_cmd_build_prepare.py
View
15 support/dist.py
@@ -10,6 +10,7 @@
from distutils.errors import DistutilsOptionError
import distutils.log as log
from distutils.util import strtobool
+import os
from dist_cmd_build import build
from dist_cmd_build_prepare import build_prepare
@@ -23,6 +24,9 @@ def __init__(self, attrs=None):
Distribution.__init__(self, attrs)
self.use_cython = None
self.profile = False
+ self.blas_lib = None
+ self.lapack_lib = None
+ self.library_dirs = None
if not self.ext_modules:
self.ext_modules = []
@@ -34,7 +38,16 @@ def __init__(self, attrs=None):
('use-cython=', None, "use Cython to make faster binary python modules (choices: "
+ "yes/no; default: autodetect)"),
('profile=', None, 'embed profiling information into Cython build (choices: '
- + 'yes/no; default: no)')
+ + 'yes/no; default: no)'),
+
+ # cython-build specific options
+ ('blas-lib=', None,
+ 'library name that provides cblas_sswap function, without lib prefix [default: cblas]'),
+ ('lapack-lib=', None,
+ 'library name that provides clapack_sgetri function, without lib prefix [default: lapack]'),
+ ('library-dirs=', 'L',
+ 'list of additional directories where libraries are seached for, separated by '
+ + '{0} character'.format(os.pathsep)),
]
def has_ext_modules(self):
View
19 support/dist_cmd_build_prepare.py
@@ -18,6 +18,8 @@
class build_prepare(Command):
"""Additional build step that is used to add Cython Extension per each module that is specified"""
+ description = 'scan defined packages for python modules and inject Cython module per each'
+
def initialize_options(self):
self.ext_options = {} # options common to all extensions
self.ext_options['include_dirs'] = [self.distribution.numpy_include_dir]
@@ -29,6 +31,19 @@ def initialize_options(self):
self.deps = [] # .pxd dependencies for injected packages
def finalize_options(self):
+ # these options are passed through global distribution
+ dist = self.distribution
+ self.blas_lib = dist.blas_lib
+ self.lapack_lib = dist.lapack_lib
+ self.library_dirs = dist.library_dirs
+
+ self.blas_lib = self.blas_lib or 'cblas'
+ self.lapack_lib = self.lapack_lib or 'lapack'
+ if self.library_dirs:
+ self.library_dirs = self.library_dirs.split(os.pathsep)
+ else:
+ self.library_dirs = []
+
# these are just aliases to distribution variables
self.packages = self.distribution.packages
self.py_modules = self.distribution.py_modules
@@ -64,8 +79,8 @@ def run(self):
self.distribution.ext_modules.append(self.distribution.Extension(
'tokyo', # module name
['tokyo/tokyo.pyx', 'tokyo/tokyo.pxd'], # source file and deps
- libraries=['cblas', 'lapack', 'clapack'], # TODO!!! somewhere lapack, somewhere clapack
- library_dirs=[os.path.join(get_config_var('LIBDIR'), 'atlas')],
+ libraries=[self.blas_lib, self.lapack_lib],
+ library_dirs=self.library_dirs,
**self.ext_options
))
self.package_data['tokyo'] = '*.pxd'
Please sign in to comment.
Something went wrong with that request. Please try again.