Skip to content

Commit

Permalink
remove dependency of cython and numpy when using setup.py only withou…
Browse files Browse the repository at this point in the history
…t the requirements.txt
  • Loading branch information
xiuliren committed Aug 15, 2019
1 parent 57a4812 commit 39c18d7
Show file tree
Hide file tree
Showing 3 changed files with 8,484 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ build
*checkpoints*
*.nfs
*.sw[pmno]
waterz/evaluate.cpp
jwu/
23 changes: 18 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
from setuptools.extension import Extension
from Cython.Build import cythonize
import numpy
from setuptools.command.build_ext import build_ext as _build_ext
#from Cython.Build import cythonize
import os

version = '0.8.2'
Expand All @@ -14,17 +14,28 @@
with open("README.md", "r") as fh:
long_description = fh.read()

class build_ext(_build_ext):
"""We assume no numpy at the begining
https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py
"""
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())

source_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'waterz')
include_dirs = [
source_dir,
os.path.join(source_dir, 'backend'),
# os.path.dirname(get_python_inc()),
numpy.get_include(),
# numpy.get_include(),
]
extensions = [
Extension(
'waterz.evaluate',
sources=['waterz/evaluate.pyx', 'waterz/frontend_evaluate.cpp'],
sources=['waterz/evaluate.cpp', 'waterz/frontend_evaluate.cpp'],
include_dirs=include_dirs,
language='c++',
extra_link_args=['-std=c++11'],
Expand All @@ -41,6 +52,8 @@
author='Jan Funke, Jingpeng Wu',
author_email='[email protected]',
license='MIT',
cmdclass={'build_ext': build_ext},
setup_requires=['numpy'],
install_requires=requirements,
tests_require=['pytest'],
packages=find_packages(),
Expand All @@ -56,7 +69,7 @@
},
include_package_data=True,
zip_safe=False,
ext_modules=cythonize(extensions),
ext_modules=extensions,
classifiers=[
"Programming Language :: Python :: 3",
"Intended Audience :: Developers",
Expand Down
Loading

0 comments on commit 39c18d7

Please sign in to comment.