forked from openkim/kliff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
113 lines (90 loc) · 3.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from setuptools import setup, Extension, find_packages
from distutils.sysconfig import get_config_vars
import os
# remove `-Wstrict-prototypes' that is for C not C++
cfg_vars = get_config_vars()
for key, value in cfg_vars.items():
if type(value) == str and "-Wstrict-prototypes" in value:
cfg_vars[key] = value.replace("-Wstrict-prototypes", "")
class get_pybind11_includes:
"""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.
see:
https://github.com/pybind/python_example/blob/master/setup.py
https://github.com/pybind/python_example/issues/32
"""
def __init__(self, user=False):
self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
def get_includes():
return [get_pybind11_includes(), get_pybind11_includes(user=True)]
def get_extra_compile_args():
return ["-std=c++11"]
sym_fn = Extension(
"kliff.descriptors.symmetry_function.sf",
sources=[
"kliff/descriptors/symmetry_function/sym_fn_bind.cpp",
"kliff/descriptors/symmetry_function/sym_fn.cpp",
"kliff/descriptors/symmetry_function/helper.cpp",
],
include_dirs=get_includes(),
extra_compile_args=get_extra_compile_args(),
language="c++",
)
bispectrum = Extension(
"kliff.descriptors.bispectrum.bs",
sources=[
"kliff/descriptors/bispectrum/bispectrum_bind.cpp",
"kliff/descriptors/bispectrum/bispectrum.cpp",
"kliff/descriptors/bispectrum/helper.cpp",
],
include_dirs=get_includes(),
extra_compile_args=get_extra_compile_args(),
language="c++",
)
neighlist = Extension(
"kliff.neighbor.nl",
sources=["kliff/neighbor/neighbor_list.cpp", "kliff/neighbor/neighbor_list_bind.cpp"],
include_dirs=get_includes(),
extra_compile_args=get_extra_compile_args(),
language="c++",
)
def get_version(fname=os.path.join("kliff", "__init__.py")):
with open(fname) as fin:
for line in fin:
line = line.strip()
if "__version__" in line:
v = line.split("=")[1]
# stripe white space, and ' or " in string
if "'" in v:
version = v.strip("' ")
elif '"' in v:
version = v.strip('" ')
break
return version
kliff_scripts = ["bin/kliff"]
setup(
name="kliff",
version=get_version(),
packages=find_packages(),
setup_requires=["pybind11"],
install_requires=["scipy", "pybind11", "pytest"],
ext_modules=[sym_fn, bispectrum, neighlist],
scripts=kliff_scripts,
author="Mingjian Wen",
author_email="[email protected]",
url="https://github.com/mjwen/kliff",
description="KLIFF: KIM-based Learning-Integrated Fitting Framework",
long_description="KLIFF: KIM-based Learning-Integrated Fitting Framework",
classifiers=[
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: Common Development and Distribution License 1.0 (CDDL-1.0)",
"Operating System :: OS Independent",
],
zip_safe=False,
)