Skip to content

Commit

Permalink
boot straps numpy and uses cython implicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
derNarr committed Feb 6, 2018
1 parent c685a72 commit 1693de5
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext

# Do not import cython as this will be done py setuptools automagically

# boot strap numpy
# https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())

# While setup, this file will be called twice:
# One time, to read the dependencies,
# and after their installation.
try:
from Cython.Distutils import build_ext
import numpy
except ImportError as e:
use_deps = False
else:
use_deps = True

pkg = __import__('pyndl')

Expand All @@ -27,20 +30,16 @@ def load_requirements(fn):
return [x.rstrip() for x in list(f) if x and not x.startswith('#')]


if use_deps:
ext_modules = [
Extension(
"pyndl.ndl_parallel",
["pyndl/ndl_parallel.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
include_dirs=[numpy.get_include()]
)
]
cmdclass = {'build_ext': build_ext}
else:
ext_modules = []
cmdclass = {}
ext_modules = [
Extension(
"pyndl.ndl_parallel",
["pyndl/ndl_parallel.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
#include_dirs=[numpy.get_include()] # this is dealt with in the boot strap class
)
]


setup(
name='pyndl',
Expand All @@ -54,6 +53,7 @@ def load_requirements(fn):
classifiers=classifiers,
platforms='Linux',
packages=['pyndl'],
setup_requires=['numpy', 'Cython'],
install_requires=load_requirements('requirements.txt'),
extras_require={
'tests': [
Expand All @@ -66,5 +66,5 @@ def load_requirements(fn):
'numpydoc',
'easydev==0.9.35']},
ext_modules=ext_modules,
cmdclass=cmdclass
cmdclass={'build_ext': build_ext}
)

0 comments on commit 1693de5

Please sign in to comment.