-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
135 lines (117 loc) · 5.03 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from numpy.distutils.core import setup
from numpy.distutils.core import Extension
from numpy.distutils.misc_util import has_cxx_sources
import os
class ModuleList:
def __init__(self, **kwargs):
self.module_list = []
self.kwargs = kwargs
def add_module(self, filename):
modname = filename.replace("/", ".")
modname, ext = os.path.splitext(modname)
self.module_list.append(Extension(modname, [filename], **self.kwargs))
extra_compile_args=[]
if False:
#for bug testing
extra_compile_args=["-DF2PY_REPORT_ON_ARRAY_COPY=1"]
#if True:
# extra_compile_args += ["-ffixed-line-length-none"]
fmodules = ModuleList(extra_compile_args=extra_compile_args)
#fmodules.add_module("pygmin/mindist/overlap.f90")
fmodules.add_module("pygmin/mindist/minperm.f90")
fmodules.add_module("pygmin/optimize/mylbfgs_fort.f90")
fmodules.add_module("pygmin/optimize/mylbfgs_updatestep.f90")
fmodules.add_module("pygmin/potentials/fortran/AT.f90")
fmodules.add_module("pygmin/potentials/fortran/ljpshiftfort.f90")
fmodules.add_module("pygmin/potentials/fortran/lj.f90")
fmodules.add_module("pygmin/potentials/fortran/ljcut.f90")
fmodules.add_module("pygmin/potentials/fortran/rmdrvt.f90")
fmodules.add_module("pygmin/potentials/fortran/soft_sphere_pot.f90")
fmodules.add_module("pygmin/potentials/fortran/maxneib_lj.f90")
fmodules.add_module("pygmin/potentials/fortran/maxneib_blj.f90")
fmodules.add_module("pygmin/potentials/fortran/lj_hess.f90")
fmodules.add_module("pygmin/potentials/fortran/magnetic_colloids.f90")
#fmodules.add_module("pygmin/potentials/rigid_bodies/rbutils.f90")
fmodules.add_module("pygmin/utils/_fortran_utils.f90")
fmodules.add_module("pygmin/transition_states/_orthogoptf.f90")
fmodules.add_module("pygmin/transition_states/_NEB_utils.f90")
fmodules.add_module("pygmin/angleaxis/_aadist.f90")
fmodules.add_module("pygmin/accept_tests/_spherical_container.f90")
fmodules.add_module("pygmin/wham/_wham_utils.f90")
cxx_modules = [ ]
fortran_modules = fmodules.module_list
ext_modules = fortran_modules + cxx_modules
setup(name='pygmin',
version='0.1',
description="Python implementation of GMIN, OPTIM, and PATHSAMPLE",
url='http://github.com/js850/PyGMIN.git',
packages=["pygmin",
"pygmin.application",
"pygmin.potentials",
"pygmin.gui",
"pygmin.gui.ui",
"pygmin.mindist",
"pygmin.optimize",
"pygmin.transition_states",
"pygmin.transition_states.nebtesting",
"pygmin.landscape",
"pygmin.printing",
"pygmin.takestep",
"pygmin.utils",
"pygmin.wham",
"pygmin.storage",
"pygmin.potentials.fortran",
"pygmin.accept_tests",
"pygmin.systems",
"pygmin.angleaxis",
"pygmin.thermodynamics",
],
ext_modules=ext_modules
)
#
# we have no cython files any more. so the following is commented
#
have_cython = False
if have_cython:
###########################################################
"""
programming note: f2py and cython are not mutually compatible with distutils.
To use f2py, we must use numpy.distutils, but numpy.distutils doesn't support
cython. There are several ways around this, but all of them are hacky.
1 Use numpy.distutils to compile the fortran extension modules and use
distutils to compile the .pyx files. This seems like an optimal solution,
but it fails when you pass a flag to numpy.distutils that distutils doesn't
understand, e.g. --fcompiler. A possible solution is to check for the
known incompatible flags and remove them when passing to distutils.
2. Compile cython .pyx files into .c files by hand and use numpy.distils
to include the .c as source files. This is the way scipy does it.
We could also have setup.py accept a flag --cython which does this for
all .pyx files.
Currently we are using method 1.
"""
###########################################################
import sys
#remove any flag incompatible with non-numpy distutils.
flag = "--fcompiler"
rmlist = []
for arg in sys.argv:
if flag in arg:
rmlist.append(arg)
for arg in rmlist:
sys.argv.remove(arg)
#now build the cython modules
#we have to do this separately because cython isn't supported by numpy.distutils
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
cython_modules = [
Extension("pygmin.potentials.rigid_bodies._rbutils_cython",
["pygmin/potentials/rigid_bodies/_rbutils_cython.pyx"])
]
setup(
ext_modules = cython_modules,
cmdclass = {'build_ext': build_ext},
include_dirs = [np.get_include()],
# script_args = ['build_ext', '--inplace'],
)