-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
96 lines (78 loc) · 3.47 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
import os
import platform
import subprocess
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, cmake_lists_dir='.', **kwa):
Extension.__init__(self, name, sources=[], **kwa)
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
class cmake_build_ext(build_ext):
def build_extensions(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError('Cannot find CMake executable')
for ext in self.extensions:
extdir = os.path.abspath(
os.path.dirname(self.get_ext_fullpath(ext.name)))
cfg = 'Release'
cmake_args = [
# Place result in the directory containing the extension
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(
cfg.upper(), extdir + '/' + ext.name + '/build'),
# Place intermediate static libraries in temporary directory
'-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_{}={}'.format(
cfg.upper(), self.build_temp)
]
# We can handle some platform-specific settings at our discretion
if platform.system() == 'Windows':
plat = ('x64'
if platform.architecture()[0] == '64bit' else 'Win32')
cmake_args += [
# These options are likely to be needed under Windows
'-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE',
'-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}'.format(
cfg.upper(), extdir)
]
# Assuming that Visual Studio and MinGW are supported compilers
if self.compiler.compiler_type == 'msvc':
cmake_args += ['-DCMAKE_GENERATOR_PLATFORM=%s' % plat]
else:
cmake_args += ['-G', 'MinGW Makefiles']
else:
cmake_args.append('-DCMAKE_BUILD_TYPE={}'.format(cfg))
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
# Config
subprocess.check_call(['cmake', ext.cmake_lists_dir] + cmake_args,
cwd=self.build_temp)
# Build
subprocess.check_call(['cmake', '--build', '.'],
cwd=self.build_temp)
setup(
name='PyPDE',
version='1.0.0',
author='Haran Jackson',
author_email='jackson.haran@gmail.com',
classifiers=[
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
cmdclass={'build_ext': cmake_build_ext},
description='Solve any hyperbolic/parabolic system of PDEs',
ext_modules=[CMakeExtension('pypde')],
install_requires=["numba>=0.46", "numpy>=1.14"],
keywords=[
'ADER', 'WENO', 'Discontinuous Galerkin', 'Finite Volume', 'PDEs',
'Partial Differential Equations', 'Hyperbolic', 'Parabolic'
],
long_description=open("README.rst").read(),
packages=find_packages(),
python_requires=">=3.6",
setup_requires=["cmake>=3.5"],
tests_require=["matplotlib>=2.0", "scipy>=1.1.0"],
url="https://github.com/haranjackson/pypde",
zip_safe=False)