-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.py
100 lines (90 loc) · 2.86 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
import sys
from os import path, name
import numpy
from setuptools import setup, Extension, find_packages
from setuptools.command.build_py import build_py as _build_py
# Get long description
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()
long_description = long_description.replace(
'<img src="https://github.com/leakec/tfc/blob/main/docs/Univariate_TFC_Animation.gif" width="600" height="467">',
"",
1,
)
# Get numpy directory
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
# Get version info
version_dict = {}
with open("src/tfc/version.py") as f:
exec(f.read(), version_dict)
version = version_dict["__version__"]
# In the future, can add -DHAS_CUDA to this to enable GPU support
if name == "nt":
# Windows compile flags
cxxFlags = ["/O2", "/std:c++17", "/Wall", "/DWINDOWS_MSVC"]
else:
cxxFlags = ["-O3", "-std=c++17", "-Wall", "-Wextra", "-Wno-unused-parameter", "-fPIC"]
if sys.version_info >= (3, 10):
numpy_version = "numpy>=2.1.0"
else:
numpy_version = "numpy>=1.21.0"
# Create basis function c++ extension
BF = Extension(
"tfc.utils.BF._BF",
sources=["src/tfc/utils/BF/BF.i", "src/tfc/utils/BF/BF.cxx"],
include_dirs=["src/tfc/utils/BF", numpy_include],
swig_opts=["-c++", "-doxygen", "-O", "-olddefs"],
extra_compile_args=cxxFlags,
extra_link_args=cxxFlags,
)
# Custom build options to include swig Python files
class build_py(_build_py):
def run(self):
self.run_command("build_ext")
super(build_py, self).run()
# Setup
setup(
name="tfc",
version=version,
author="Carl Leake and Hunter Johnston",
author_email="leakec57@gmail.com",
description="Theory of Functional Connections (TFC): A functional interpolation framework with applications in differential equations.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/leakec/tfc.git",
license="MIT",
packages=find_packages("src"),
package_dir={"": "src"},
package_data={"": ["src/tfc/py.typed"]},
python_requires=">=3.10",
include_package_data=True,
ext_modules=[BF],
install_requires=[
numpy_version,
"jax",
"jaxlib",
"jaxtyping",
"annotated-types",
"matplotlib",
"colorama",
"graphviz",
"yattag",
"sympy",
],
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Topic :: Education",
],
cmdclass={
"build_py": build_py,
},
)