-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
91 lines (83 loc) · 3.11 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# Copyright (c) 2015, Scott J Maddox
#
# This file is part of Open Band Parameters Device Simulator (OBPDS).
#
# OBPDS is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OBPDS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OBPDS. If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import sys
import os.path
from setuptools import setup, Extension
import numpy
try:
from Cython.Build import cythonize
USE_CYTHON = True
except:
if len(sys.argv) >= 1 and 'sdist' in sys.argv[1:]:
raise RuntimeError('Cython is required to build a source distribution.')
USE_CYTHON = False
def no_cythonize(extensions, **_ignore):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in ('.pyx', '.py'):
if extension.language == 'c++':
ext = '.cpp'
else:
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [Extension("fdint._fdint", ["fdint/_fdint"+ext]),
Extension("fdint.fd", ["fdint/fd"+ext]),
Extension("fdint.dfd", ["fdint/dfd"+ext]),
Extension("fdint.ifd", ["fdint/ifd"+ext]),
Extension("fdint.gfd", ["fdint/gfd"+ext]),
Extension("fdint.dgfd", ["fdint/dgfd"+ext]),
Extension("fdint.scfd", ["fdint/scfd"+ext]),]
# read in __version__
exec(open('fdint/version.py').read())
metadata = dict(
name='fdint',
version=__version__, # read from version.py
description = 'A free, open-source python package for quickly and '
'precisely approximating Fermi-Dirac integrals.',
long_description=open('README.rst').read(),
url='http://scott-maddox.github.io/fdint',
author='Scott J. Maddox',
author_email='[email protected]',
license='BSD',
packages=['fdint',
'fdint.tests',
'fdint.examples'],
package_dir={'fdint': 'fdint'},
data_files=['fdint/__init__.pxd',
'fdint/_fdint.pxd',
'fdint/scfd.pxd',],
test_suite='fdint.tests',
setup_requires=['numpy'],
install_requires=['numpy'],
# zip_safe=True,
# use_2to3=True,
include_dirs=[numpy.get_include()],
)
if USE_CYTHON:
metadata['ext_modules'] = cythonize(extensions)
else:
metadata['ext_modules'] = no_cythonize(extensions)
setup(**metadata)