forked from ptools/ptools-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
142 lines (98 loc) · 3.83 KB
/
setup.py
File metadata and controls
142 lines (98 loc) · 3.83 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
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
135
136
137
138
139
140
141
142
# -*- coding: utf-8 -*-
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import os
import sys
import bzrrev
#### PLEASE override the following two variables
#### to define a custom path to required dependencies:
# user-defined path to libf2c.a
user_path_libf2c = ""
# user-defined path to f2c.h
user_path_f2c_h = ""
# user-defined path to boost library:
user_path_boost = ""
############################
### methods to locate headers and libraries:
def find_file(name,path, useEnvPath=False):
"""finds a file named 'name' in a serie of directories
given in 'path' """
if useEnvPath:
additional_path = os.environ['PATH'].split(':')
path.extend(additional_path)
for p in path:
fullfilepath = os.path.join(p,name)
if os.path.exists(fullfilepath):
return fullfilepath
return None #no file found
def find_header(names, paths, useEnvPath=False):
#find a library in a given set of directories
if useEnvPath:
additional_path = os.environ['PATH'].split(':')
paths.extend(additional_path)
for p in paths:
if os.path.exists(p):
for n in names:
if os.path.exists(os.path.join(p,n)):
return p
return None
print "Trying to locate the boost libraries, modify setup.py to change de default search path"
boostdir=find_header(["boost/shared_array.hpp"], [user_path_boost,"./ptools_dep/boost_1_55_0", "/usr/include", \
"/opt/local/include"] )
print "Trying to locate libf2c.a static library"
f2clib = find_file("libf2c.a", [user_path_libf2c, "./ptools_dep/f2c", "/usr/lib/", "/usr/local/lib/", "/usr/lib64/"])
f2c_header = find_header(["f2c.h"], [user_path_f2c_h, "./ptools_dep/f2c", "/usr/include", "/usr/local/f2c/"])
not_found_message = """Note: You can add a custom search path by editing this file (setup.py).
You can also install locally the missing dependencies by running: sh ./install-deps.sh"""
if boostdir is None:
print "Cannot locate boost library", not_found_message
sys.exit(1)
if f2clib is None:
print "Cannot locate libf2c", not_found_message
sys.exit(1)
print "using boost from", boostdir
print "using f2clib from", f2clib
sources = [
"cython_wrappers.cpp",
"atom.cpp",
"attractrigidbody.cpp",
"coordsarray.cpp",
"mcopff.cpp",
"rigidbody.cpp",
"surface.cpp",
"atomselection.cpp",
"basetypes.cpp",
"forcefield.cpp",
"pairlist.cpp",
"rmsd.cpp",
"version.cpp",
"attractforcefield.cpp",
"coord3d.cpp",
"geometry.cpp",
"pdbio.cpp",
"superpose.cpp",
"scorpionforcefield.cpp",
"minimizers/lbfgs_interface.cpp",
"minimizers/routines.c",
"minimizers/lbfgs_wrapper/lbfgsb_wrapper.cpp",
]
sources = [os.path.join('src', i) for i in sources ] #append the 'src' prefix to all files
sources.append("bindings/_ptools.pyx")
ptools = Extension("_ptools",
sources=sources,
language="c++",
library_dirs=[boostdir],
include_dirs=['headers', f2c_header, boostdir],
extra_objects=[f2clib])
cgopt = Extension("cgopt",
sources=["PyAttract/cgopt.pyx", "PyAttract/chrg_scorpion.c"],
language="c",
include_dirs=[f2c_header, 'PyAttract'],
extra_objects = [f2clib])
setup(ext_modules=[ptools, cgopt],
cmdclass={'build_ext': build_ext},
packages = ['.'],
name="ptools",
version = "1.2"
)