-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·96 lines (86 loc) · 3 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
92
93
94
95
96
#!/usr/bin/env python3
import pybind11
import sys
import sysconfig # check default compiler for python.
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup, find_packages, Extension
from distutils.sysconfig import get_config_vars
'''
Reference
* https://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used
'''
# Initialize version.
__version__ = '0.4.1'
copt = {'linux':[]}
lopt = {'linux':[]}
# Check python's default compiler set.
def CheckCompiler(): # {{{
compiler = sysconfig.get_config_var('CC').split(' ')[0]
if compiler == 'icc':
return 'intel'
elif compiler == 'gcc':
return 'gcc'
else:
raise Exception(f"ERROR: Given compiler ({compiler}) is not supported.")
# }}}
# OpenMP flags depending on the compiler
extra_compile_args = []
#extra_compile_args = ['-std=c++11']
if sys.platform == "win32":
extra_compile_args += ['/openmp']
else:
compiler = CheckCompiler()
if compiler == 'gcc':
extra_compile_args += ['-fopenmp']
elif compiler == 'intel':
extra_compile_args += ['-qopenmp'] #,'-xHost','-O2']
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the `get_include()`
method can be invoked."""
def __str__(self):
return pybind11.get_include()
ext_modules = [
Pybind11Extension(
'pyseb.libpysemic', # install libpysemic in "pyseb" directory.
['src/libpysemic.cpp','src/SurfaceEnergyBalance.cpp'],
define_macros=[('VERSION_INFO',__version__), ('HAVE_PYBIND11',1)],
extra_compile_args=extra_compile_args,
extra_link_args=extra_compile_args,
),
Pybind11Extension(
'pyseb.libexample', # install libpysemic in "pyseb" directory.
['src/libexample.cpp'],
define_macros=[('VERSION_INFO',__version__), ('HAVE_PYBIND11', 1)],
extra_compile_args=extra_compile_args,
extra_link_args=extra_compile_args,
),
]
setup(
name='pyseb',
version=__version__,
author='In-Woo Park',
author_email='[email protected]',
description='SEMIC in python and cpp version',
ext_modules=ext_modules,
extras_require={'test':'pytest'},
cmdclass={'build_ext':build_ext},
zip_safe=False,
python_requires='>=3.9',
#setup_requires=['pybind11'],
install_requires=[
'pybind11',
'numpy<2',
'matplotlib',
'tqdm',
'xarray',
'netCDF4',
'memory-profiler', # for checking memory leakage.
'scipy','pytest',
'nbmake', # for testing ipynb file.
],
# which required directory?
packages=find_packages(include=['pyseb']),
# package_dir={'./':["*.so","*.pyd"]},
)