forked from pygbe/pygbe
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
91 lines (86 loc) · 3.86 KB
/
setup.py
File metadata and controls
91 lines (86 loc) · 3.86 KB
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
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
import numpy
import shutil
class CustomBuild(build):
"""
Subclasses build command to ensure that built_ext is run before files
are copied. Make setuptools compile the SWIG 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 SWIG 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']:
shutil.rmtree(tree, ignore_errors=True)
for swigfile in [
'pygbe/tree/calculateMultipoles.py',
'pygbe/tree/calculateMultipoles_wrap.cpp',
'pygbe/tree/direct.py',
'pygbe/tree/direct_wrap.cpp',
'pygbe/tree/multipole.py',
'pygbe/tree/multipole_wrap.cpp',
'pygbe/util/semi_analyticalwrap.py',
'pygbe/util/semi_analyticalwrap_wrap.cpp',]:
os.remove(swigfile)
def main():
if sys.version_info[0] != 2:
sys.exit('PyGBe only supports Python 2.7')
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',
packages = find_packages(),
#tell setuptools to use the custom build and install classes
cmdclass={'build': CustomBuild, 'install': CustomInstall},
#create an entrance point that points to pygbe.main.main
entry_points={'console_scripts': ['pygbe = pygbe.main:main']},
#SWIG modules with all compilation options
ext_modules = [
Extension("_multipole",
sources=["pygbe/tree/multipole.i", "pygbe/tree/multipole.cpp"],
swig_opts=['-c++'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
),
Extension("_direct",
sources=["pygbe/tree/direct.i", "pygbe/tree/direct.cpp"],
swig_opts=['-c++'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
),
Extension("_calculateMultipoles",
sources=["pygbe/tree/calculateMultipoles.i", "pygbe/tree/calculateMultipoles.cpp"],
swig_opts=['-c++'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
),
Extension("_semi_analyticalwrap",
sources=["pygbe/util/semi_analyticalwrap.i", "pygbe/util/semi_analyticalwrap.cpp"],
swig_opts=['-c++'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-fPIC', '-O3', '-funroll-loops', '-msse3', '-fopenmp'],
),
],
)
setup(**setupkw)
if __name__ == '__main__':
main()