-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.py
101 lines (97 loc) · 4.52 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
import sys
import os
from distutils.command.build import build
from distutils.command.clean import clean
from setuptools.command.install import install
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
import numpy
import shutil
import versioneer
class CustomBuild(build):
"""
Subclasses build command to ensure that built_ext is run before files
are copied. Make setuptools compile the Cython files first, then run install
"""
def run(self):
self.run_command('build_ext')
build.run(self)
class CustomInstall(install):
"""
Subclasses install command to ensure that built_ext is run before files
are copied. Make setuptools compile the Cython files first, then run install
"""
def run(self):
self.run_command('build_ext')
self.do_egg_install()
#setuptools cleanup is weak, do it manually
cmdline = ''.join(sys.argv[1:])
if 'clean' in cmdline:
for tree in ['PyGBe.egg-info', 'build', 'dist', '__pycache__']:
shutil.rmtree(tree, ignore_errors=True)
for cyfile in [
'pygbe/tree/calculateMultipoles.cpp',
'pygbe/tree/direct.cpp',
'pygbe/tree/multipole.cpp',
'pygbe/tree/rhs.cpp',
'pygbe/util/semi_analyticalwrap.cpp',]:
os.remove(cyfile)
def main():
setupkw = dict(
name='PyGBe',
description='A boundary element method code that does molecular electrostatics calculations with a continuum approach',
platforms='Linux',
install_requires = ['numpy > 1.8',],
license='MIT',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(cmdclass={'build': CustomBuild, 'install': CustomInstall}),
url='https://github.com/pygbe/pygbe',
classifiers=['Programming Language :: Python :: 3'],
packages = find_packages(),
#tell setuptools to use the custom build and install classes
#create an entrance point that points to pygbe.main.main
entry_points={'console_scripts': ['pygbe = pygbe.main:main',
'pygbe-lspr = pygbe.lspr:main',
'pygbe-slic = pygbe.slic:main']},
#Cython modules with all compilation options
ext_modules = cythonize([
Extension("pygbe.tree.multipole",
sources=["pygbe/tree/multipole.pyx"],
language = "c++",
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
extra_link_args=['-fopenmp'],
),
Extension("pygbe.tree.direct",
sources=["pygbe/tree/direct.pyx"],
language = "c++",
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
extra_link_args=['-fopenmp'],
),
Extension("pygbe.tree.rhs",
sources=["pygbe/tree/rhs.pyx"],
language = "c++",
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
extra_link_args=['-fopenmp'],
),
Extension("pygbe.tree.calculateMultipoles",
sources=["pygbe/tree/calculateMultipoles.pyx"],
language = "c++",
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
extra_link_args=['-fopenmp'],
),
Extension("pygbe.util.semi_analyticalwrap",
sources=["pygbe/util/semi_analyticalwrap.pyx"],
language = "c++",
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
extra_link_args=['-fopenmp'],
),
], language_level = 3),
)
setup(**setupkw)
if __name__ == '__main__':
main()