Skip to content

Commit

Permalink
modified setup.py build_ext to import numpy if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthavens committed Sep 17, 2020
1 parent c2718dd commit 82d9663
Show file tree
Hide file tree
Showing 4 changed files with 4,163 additions and 8,318 deletions.
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@

import os

import numpy
from Cython.Distutils import build_ext
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext as _build_ext


def c_name_from_path(location, name):
return os.path.join(location, name).replace('/', '.')


with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()
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())

with open('README.md') as readme_file:
readme = readme_file.read()

# Give user option to specify his local compiler name
if "CC" not in os.environ:
Expand All @@ -26,7 +28,6 @@ def c_name_from_path(location, name):

ext_modules = []
extension_params = dict(
include_dirs=[numpy.get_include()],
extra_compile_args=['-fopenmp', '-O3'],
extra_link_args=['-fopenmp', '-O3'],
)
Expand Down Expand Up @@ -75,6 +76,12 @@ def c_name_from_path(location, name):
),
]

with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()

with open('README.md') as readme_file:
readme = readme_file.read()

setup(
name='smrf-dev',
description="Distributed snow modeling for water resources",
Expand Down Expand Up @@ -130,6 +137,7 @@ def c_name_from_path(location, name):
'local_scheme': 'node-and-date',
},
setup_requires=[
'setuptools_scm'
'setuptools_scm',
'numpy'
],
)

0 comments on commit 82d9663

Please sign in to comment.