Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Handle dependency of numpy during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
msbentsen committed Mar 17, 2019
1 parent dc0d9bd commit 3d3db69
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import sys
import re
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext

#Test if numpy is installed
try:
import numpy as np
except:
sys.exit("ERROR: Numpy needed for TOBIAS installation. Numpy can be installed using the command \"pip install numpy\"")

cmdclass = {}
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 as np
self.include_dirs.append(np.get_include())

#Add cython modules depending on the availability of cython
try:
Expand All @@ -20,15 +22,17 @@
use_cython = True

if use_cython:
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.pyx"], include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.pyx"], include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.pyx"], include_dirs=[np.get_include()])]
cmdclass.update({'build_ext': build_ext})
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.pyx"]), #, include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.pyx"]), #include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.pyx"])] #, include_dirs=[np.get_include()])]
#cmdclass.update({'build_ext': build_ext})

else:
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.c"], include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.c"], include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.c"], include_dirs=[np.get_include()])]
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.c"]), #, include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.c"]), #, include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.c"])] #, include_dirs=[np.get_include()])]

cmdclass = {'build_ext': build_ext}

#Path of setup file to establish version
setupdir = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -59,6 +63,7 @@ def readme():
},
ext_modules=ext_modules,
cmdclass = cmdclass,
setup_requires=["numpy"],
#dependency_links=['https://github.com/jhkorhonen/MOODS/releases/download/v1.9.3/MOODS-python-1.9.3.tar.gz#egg=MOODS-python-1.9.3'],
install_requires=[
'numpy',
Expand Down

0 comments on commit 3d3db69

Please sign in to comment.