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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
--- ADOL-C-releases-2.7.2/ADOL-C/swig/Makefile.am.bak 2023-12-15 11:55:27.486378611 +0100
+++ ADOL-C-releases-2.7.2/ADOL-C/swig/Makefile.am 2023-12-15 11:57:12.856375286 +0100
@@ -20,6 +20,6 @@
if PYTHONFOUND
if SPARSE
install:
- CXX=${CXX} ${PYTHON} setup.py install --prefix=${prefix} --only-swig
+ CXX=${CXX} ${PYTHON} setup.py build --only-swig --lib-prefix=${DESTDIR}/${prefix} --lib-libdir=${DESTDIR}/${libdir} install --prefix=${DESTDIR}/${prefix} --only-swig --optimize=1
endif
endif
--- ADOL-C-releases-2.7.2/ADOL-C/swig/setup.py.bak 2023-12-15 12:56:42.296266235 +0100
+++ ADOL-C-releases-2.7.2/ADOL-C/swig/setup.py 2023-12-15 12:57:20.999598329 +0100
@@ -11,6 +11,10 @@
##############################################################################
from __future__ import print_function
+import sys, os
+
+sys.path = [ os.path.dirname(os.path.abspath(__file__)) ] + sys.path
+
from swigprocess import prepare_flat_header
from numpy.distutils import misc_util as np_dist
from distutils.core import setup, Extension
@@ -18,10 +22,9 @@
from distutils.command.build_ext import build_ext
from distutils.command.build import build
from distutils.command.install import install
-import os
import subprocess
-def compile_dynlib(prefix,colpackdir,boostdir):
+def compile_dynlib(prefix,libdir,colpackdir,boostdir):
import subprocess
from multiprocessing import cpu_count
nproc = cpu_count()
@@ -32,6 +35,7 @@
print(out)
out = subprocess.check_output(['./configure',
'--prefix=%s' % prefix,
+ '--libdir=%s' % libdir,
'--with-colpack=%s' % colpackdir,
'--with-boost=%s' % boostdir ],
cwd=librootdir,
@@ -48,6 +52,7 @@
class build_adolc(Command):
user_options = [
('lib-prefix=', None, 'prefix to install adolc library'),
+ ('lib-libdir=', None, 'libdir to install adolc library (usually inside prefix)'),
('colpack-dir=', None, 'directory in which colpack is installed'),
('boost-dir=', None, 'directory in which boost is installed'),
('only-swig', None, 'only install this swig module, not adolc library') ]
@@ -55,6 +60,7 @@
def initialize_options(self):
self.lib_prefix = None
+ self.lib_libdir = None
self.colpack_dir = None
self.boost_dir = None
self.only_swig = None
@@ -62,13 +68,14 @@
def finalize_options(self):
self.set_undefined_options('build',
('lib_prefix','lib_prefix'),
+ ('lib_libdir','lib_libdir'),
('colpack_dir', 'colpack_dir'),
('boost_dir', 'boost_dir'),
('only_swig', 'only_swig') )
def run(self):
if not self.only_swig:
- compile_dynlib(self.lib_prefix,self.colpack_dir,self.boost_dir)
+ compile_dynlib(self.lib_prefix,self.lib_libdir,self.colpack_dir,self.boost_dir)
else:
print('skipping build of ADOL-C')
@@ -76,27 +83,47 @@
class build_swigadolc(build_ext,object):
command_name = 'build_ext'
user_options = build_ext.user_options + [
- ('lib-prefix=', None, 'prefix of installed adolc library') ]
+ ('lib-prefix=', None, 'prefix of installed adolc library'),
+ ('lib-libdir=', None, 'libdir to install adolc library (usually inside prefix)')
+ ]
def initialize_options(self):
super(build_swigadolc,self).initialize_options()
self.lib_prefix = None
+ self.lib_libdir = None
def finalize_options(self):
super(build_swigadolc,self).finalize_options()
self.set_undefined_options('build',
- ('lib_prefix','lib_prefix'))
+ ('lib_prefix','lib_prefix'),
+ ('lib_libdir','lib_libdir'))
prefix = self.lib_prefix
+ libdir = self.lib_libdir
print('prefix = ', prefix)
self.include_dirs.append(os.path.join(prefix,'include'))
- self.library_dirs.append(os.path.join(prefix,'lib64'))
- self.rpath.append(os.path.join(prefix,'lib64'))
- prepare_flat_header()
+ self.library_dirs.append(libdir)
+ # self.rpath.append(libdir)
+ buildobj = self.get_finalized_command('build')
+ self.src = buildobj.src
+ prepare_flat_header()
+ self.finalized = 1
+ def build_extension(self, ext):
+ if os.path.abspath(os.path.realpath(self.src)) != os.path.abspath('.'):
+ import shutil
+ sources = ext.sources
+ newSrc = []
+ for s in iter(sources):
+ shutil.copy(self.src + '/' + s, '.')
+ ext.include_dirs.append(self.src)
+ ext.swig_opts += ['-I' + self.src]
+ super(build_swigadolc,self).build_extension(ext)
class buildthis(build,object):
command_name = 'build'
user_options = build.user_options + [
+ ('src=', None, 'path of the source directory of swig module'),
('lib-prefix=', None, 'prefix to install adolc library'),
+ ('lib-libdir=', None, 'libdir to install adolc library (usually inside prefix)'),
('colpack-dir=', None, 'directory in which colpack is installed'),
('boost-dir=', None, 'directory in which boost is installed'),
('only-swig', None, 'only install this swig module, not adolc library') ]
@@ -106,16 +133,39 @@
from distutils.sysconfig import customize_compiler
compiler = new_compiler()
customize_compiler(compiler)
- lib_file = compiler.find_library_file([os.path.join(self.lib_prefix,'lib64')],'adolc')
+ lib_file = compiler.find_library_file([self.lib_libdir, os.path.join(self.lib_prefix,'lib64'), os.path.join(self.lib_prefix,'lib')],'adolc')
return lib_file is None
def initialize_options(self):
super(buildthis,self).initialize_options()
+ self.src = None
self.lib_prefix = None
+ self.lib_libdir = None
self.colpack_dir = None
self.boost_dir = None
self.only_swig = None
+ def finalize_options(self):
+ super(buildthis,self).finalize_options()
+ if self.src is None:
+ self.src = '.'
+ if self.lib_prefix is None:
+ self.lib_prefix = os.path.join(os.environ['HOME'],'adolc_base')
+ if self.lib_libdir is None:
+ import ctypes as c
+ plen = c.sizeof(c.c_void_p(0))
+ if plen == 8:
+ self.lib_libdir = os.path.join(self.lib_prefix,'lib64')
+ else:
+ self.lib_libdir = os.path.join(self.lib_prefix,'lib')
+ if self.colpack_dir is None:
+ self.colpack_dir = os.path.join(os.environ['HOME'],'adolc_base')
+ if self.boost_dir is None:
+ self.boost_dir = '/usr'
+ if self.only_swig is None:
+ self.only_swig = False
+ self.finalized = 1
+
#sub_commands = [ ('build_lib', lib_doesnot_exist),
# ('build_ext', None) ]
sub_commands = [ ('build_lib', None),
@@ -125,34 +175,28 @@
command_name = 'install'
user_options = install.user_options + [
('lib-prefix=', None, 'prefix to install adolc library'),
+ ('lib-libdir=', None, 'libdir to install adolc library (usually inside prefix)'),
('colpack-dir=', None, 'directory in which colpack is installed'),
('boost-dir=', None, 'directory in which boost is installed'),
('only-swig', None, 'only install this swig module, not adolc library')]
def initialize_options(self):
self.lib_prefix = None
+ self.lib_libdir = None
self.colpack_dir = None
self.boost_dir = None
self.only_swig = None
super(installthis,self).initialize_options()
def finalize_options(self):
+ self.set_undefined_options('build',
+ ('lib_prefix','lib_prefix'),
+ ('lib_libdir', 'lib_libdir'),
+ ('colpack_dir', 'colpack_dir'),
+ ('boost_dir', 'boost_dir'),
+ ('only_swig', 'only_swig'))
super(installthis,self).finalize_options()
- if self.lib_prefix is None:
- self.lib_prefix = os.path.join(os.environ['HOME'],'adolc_base')
- if self.colpack_dir is None:
- self.colpack_dir = os.path.join(os.environ['HOME'],'adolc_base')
- if self.boost_dir is None:
- self.boost_dir = '/usr'
- if self.only_swig is None:
- self.only_swig = False
self.finalized = 1
- buildobj = self.distribution.get_command_obj('build')
- buildobj.set_undefined_options('install',
- ('lib_prefix','lib_prefix'),
- ('colpack_dir', 'colpack_dir'),
- ('boost_dir', 'boost_dir'),
- ('only_swig', 'only_swig'))
incdirs = np_dist.get_numpy_include_dirs()
#python_ldflags = subprocess.check_output(['python-config','--ldflags'],universal_newlines=True)
@@ -170,7 +214,7 @@
setup(name='adolc',
ext_modules=[adolc_mod],
py_modules=['adolc'],
- version='2.7-trunk',
+ version='2.7.2',
cmdclass = { 'build_lib': build_adolc,
'build_ext': build_swigadolc,
'build': buildthis,
|