Skip to content

Commit fe0629e

Browse files
Merge pull request #3 from IntelPython/remove-dependency-on-numpy
Remove dependency on numpy
2 parents 7dc9853 + 7cbc19c commit fe0629e

File tree

6 files changed

+81
-118
lines changed

6 files changed

+81
-118
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ install:
3434
- bash miniconda.sh -b -p $HOME/miniconda
3535
- export PATH="$HOME/miniconda/bin:$PATH"
3636
- hash -r
37-
- conda config --set always_yes yes --set changeps1 no
38-
- conda update -q conda
39-
- conda install conda-build
37+
- conda update --yes -q conda
38+
- conda install --yes conda-build
4039
# Useful for debugging any issues with conda
4140
- conda info -a
4241
- gcc -v
4342
- g++ -v
4443

4544
script:
46-
- conda build -c defaults -c intel $PYVER conda-recipe
45+
- conda build -c conda-forge $PYVER --override-channels conda-recipe

conda-recipe/bld.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
@rem Remember to activate compiler, if needed
33

4+
set MKLROOT=%CONDA_PREFIX%
45
%PYTHON% setup.py build --force install --old-and-unmanageable
56
if errorlevel 1 exit 1

conda-recipe/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# make sure that compiler has been sourced, if necessary
44

5-
CFLAGS="-I${PREFIX}/include ${CFLAGS}" $PYTHON setup.py build --force install --old-and-unmanageable
5+
MKLROOT=$CONDA_PREFIX $PYTHON setup.py build --force install --old-and-unmanageable

conda-recipe/meta.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.0.0" %}
1+
{% set version = "2.0.2" %}
22
{% set buildnumber = 0 %}
33

44
package:
@@ -10,6 +10,9 @@ source:
1010

1111
build:
1212
number: {{ buildnumber }}
13+
ignore_run_exports:
14+
- blas
15+
- mkl-service
1316

1417
requirements:
1518
build:
@@ -19,12 +22,10 @@ requirements:
1922
- setuptools
2023
- mkl-devel
2124
- cython
22-
- numpy 1.11.*
2325
run:
2426
- python
2527
- mkl
2628
- six
27-
- {{ pin_compatible('numpy') }}
2829

2930
test:
3031
commands:

mkl/setup.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

setup.py

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
from __future__ import division, print_function, absolute_import
2929
import io
3030
import re
31-
31+
import os
32+
from os.path import join, exists, dirname
33+
import setuptools
34+
import setuptools.extension
3235

3336
with io.open('mkl/__init__.py', 'rt', encoding='utf8') as file:
3437
VERSION = re.search(r'__version__ = \'(.*?)\'', file.read()).group(1)
3538

36-
3739
CLASSIFIERS = """\
3840
Development Status :: 5 - Production/Stable
3941
Intended Audience :: Science/Research
@@ -57,27 +59,80 @@
5759
"""
5860

5961

60-
def configuration(parent_package='', top_path=None):
61-
from numpy.distutils.misc_util import Configuration
62-
63-
config = Configuration(None, parent_package, top_path)
64-
config.set_options(ignore_setup_xxx_py=True,
65-
assume_default_configuration=True,
66-
delegate_options_to_subpackages=True,
67-
quiet=True)
62+
def get_extensions():
63+
try:
64+
from numpy.distutils.system_info import get_info
65+
mkl_info = get_info('mkl')
66+
except ImportError:
67+
mkl_root = os.environ['MKLROOT']
68+
mkl_info = {
69+
'include_dirs': [join(mkl_root, 'include')],
70+
'library_dirs': [join(mkl_root, 'lib'), join(mkl_root, 'lib', 'intel64')],
71+
'libraries': ['mkl_rt']
72+
}
73+
74+
mkl_include_dirs = mkl_info.get('include_dirs', [])
75+
mkl_library_dirs = mkl_info.get('library_dirs', [])
76+
mkl_libraries = mkl_info.get('libraries', ['mkl_rt'])
77+
78+
defs = []
79+
if any(['mkl_rt' in li for li in mkl_libraries]):
80+
#libs += ['dl'] - by default on Linux
81+
defs += [('USING_MKL_RT', None)]
82+
83+
pdir = 'mkl'
84+
try:
85+
from Cython.Build import cythonize
86+
sources = [join(pdir, '_mkl_service.pyx')]
87+
have_cython = True
88+
except ImportError as e:
89+
have_cython = False
90+
sources = [join(pdir, '_mkl_service.c')]
91+
if not exists(sources[0]):
92+
raise ValueError(str(e) + '. ' +
93+
'Cython is required to build the initial .c file.')
94+
95+
extensions = []
96+
extensions.append(
97+
setuptools.extension.Extension(
98+
'mkl._mklinit',
99+
sources=['mkl/_mklinitmodule.c'],
100+
define_macros=defs,
101+
include_dirs=mkl_include_dirs,
102+
libraries=mkl_libraries,
103+
library_dirs=mkl_library_dirs,
104+
extra_compile_args=[
105+
'-DNDEBUG'
106+
# '-g', '-O2', '-Wall',
107+
]
108+
)
109+
)
68110

69-
config.add_subpackage('mkl')
111+
extensions.append(
112+
setuptools.extension.Extension(
113+
'mkl._py_mkl_service',
114+
sources=sources,
115+
include_dirs=mkl_include_dirs,
116+
library_dirs=mkl_library_dirs,
117+
libraries=mkl_libraries,
118+
extra_compile_args=[
119+
'-DNDEBUG'
120+
# '-g', '-O2', '-Wall',
121+
]
122+
)
123+
)
70124

71-
config.version = VERSION
125+
if have_cython:
126+
extensions = cythonize(extensions, include_path=[join(__file__, pdir)])
72127

73-
return config
128+
return extensions
74129

75130

76131
def setup_package():
77132
from setuptools import setup
78-
from numpy.distutils.core import setup
79133
metadata = dict(
80134
name='mkl-service',
135+
version=VERSION,
81136
maintainer="Intel",
82137
maintainer_email="[email protected]",
83138
description="MKL Support Functions",
@@ -99,9 +154,10 @@ def setup_package():
99154
platforms=["Windows", "Linux", "Mac OS-X"],
100155
test_suite='nose.collector',
101156
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
102-
setup_requires=['numpy', 'cython'],
157+
setup_requires=['setuptools', 'cython'],
103158
install_requires=['six'],
104-
configuration=configuration,
159+
packages=setuptools.find_packages(),
160+
ext_modules=get_extensions()
105161
)
106162
setup(**metadata)
107163

0 commit comments

Comments
 (0)