| 2423 |
jroman |
1 |
#
|
|
|
2 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
3 |
# SLEPc - Scalable Library for Eigenvalue Problem Computations
|
|
|
4 |
# Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
|
|
5 |
#
|
|
|
6 |
# This file is part of SLEPc.
|
|
|
7 |
#
|
|
|
8 |
# SLEPc is free software: you can redistribute it and/or modify it under the
|
|
|
9 |
# terms of version 3 of the GNU Lesser General Public License as published by
|
|
|
10 |
# the Free Software Foundation.
|
|
|
11 |
#
|
|
|
12 |
# SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
15 |
# more details.
|
|
|
16 |
#
|
|
|
17 |
# You should have received a copy of the GNU Lesser General Public License
|
|
|
18 |
# along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
20 |
#
|
|
|
21 |
|
|
|
22 |
import os
|
|
|
23 |
import sys
|
|
|
24 |
import log
|
|
|
25 |
import petscconf
|
|
|
26 |
import urllib
|
|
|
27 |
import urlparse
|
|
|
28 |
import commands
|
|
|
29 |
|
| 2478 |
jroman |
30 |
def Install(conf,vars,cmake,tmpdir,url,archdir):
|
| 2423 |
jroman |
31 |
'''
|
|
|
32 |
Download and uncompress the BLOPEX tarball
|
|
|
33 |
'''
|
|
|
34 |
log.write('='*80)
|
|
|
35 |
log.Println('Installing BLOPEX...')
|
|
|
36 |
|
| 2472 |
jroman |
37 |
if petscconf.PRECISION == 'single':
|
|
|
38 |
log.Exit('ERROR: BLOPEX does not support single precision.')
|
|
|
39 |
|
| 2423 |
jroman |
40 |
# Create externalpackages directory
|
|
|
41 |
externdir = 'externalpackages'
|
|
|
42 |
if not os.path.exists(externdir):
|
|
|
43 |
try:
|
|
|
44 |
os.mkdir(externdir)
|
|
|
45 |
except:
|
|
|
46 |
sys.exit('ERROR: cannot create directory ' + externdir)
|
|
|
47 |
|
|
|
48 |
# Download tarball
|
|
|
49 |
packagename = 'blopex-1.1.2'
|
|
|
50 |
if url=='':
|
|
|
51 |
url = 'http://www.grycap.upv.es/slepc/download/external/'+packagename+'.tar.gz'
|
| 2443 |
jroman |
52 |
archiveZip = 'blopex.tar.gz'
|
| 2423 |
jroman |
53 |
localFile = os.sep.join([externdir,archiveZip])
|
|
|
54 |
log.Println('Downloading '+url+' to '+localFile)
|
|
|
55 |
|
|
|
56 |
if os.path.exists(localFile):
|
|
|
57 |
os.remove(localFile)
|
|
|
58 |
try:
|
|
|
59 |
urllib.urlretrieve(url, localFile)
|
|
|
60 |
except Exception, e:
|
|
|
61 |
name = 'blopex'
|
|
|
62 |
filename = os.path.basename(urlparse.urlparse(url)[2])
|
|
|
63 |
failureMessage = '''\
|
|
|
64 |
Unable to download package %s from: %s
|
|
|
65 |
* If your network is disconnected - please reconnect and rerun config/configure.py
|
|
|
66 |
* Alternatively, you can download the above URL manually, to /yourselectedlocation/%s
|
|
|
67 |
and use the configure option:
|
|
|
68 |
--download-%s=/yourselectedlocation/%s
|
|
|
69 |
''' % (name, url, filename, name, filename)
|
|
|
70 |
raise RuntimeError(failureMessage)
|
|
|
71 |
|
|
|
72 |
# Uncompress tarball
|
|
|
73 |
destDir = os.sep.join([externdir,packagename])
|
|
|
74 |
log.Println('Uncompressing '+localFile+' to directory '+destDir)
|
|
|
75 |
if os.path.exists(destDir):
|
|
|
76 |
for root, dirs, files in os.walk(destDir, topdown=False):
|
|
|
77 |
for name in files:
|
|
|
78 |
os.remove(os.path.join(root, name))
|
|
|
79 |
for name in dirs:
|
|
|
80 |
os.rmdir(os.path.join(root, name))
|
|
|
81 |
try:
|
| 2444 |
jroman |
82 |
if sys.version_info >= (2,5):
|
|
|
83 |
import tarfile
|
|
|
84 |
tar = tarfile.open(localFile, "r:gz")
|
|
|
85 |
tar.extractall(path=externdir)
|
|
|
86 |
tar.close()
|
|
|
87 |
os.remove(localFile)
|
|
|
88 |
else:
|
|
|
89 |
result,output = commands.getstatusoutput('cd '+externdir+'; gunzip '+archiveZip+'; tar -xf '+archiveZip.split('.gz')[0])
|
|
|
90 |
os.remove(localFile.split('.gz')[0])
|
| 2423 |
jroman |
91 |
except RuntimeError, e:
|
|
|
92 |
raise RuntimeError('Error uncompressing '+archiveZip+': '+str(e))
|
|
|
93 |
|
|
|
94 |
# Configure
|
|
|
95 |
g = open(os.path.join(destDir,'Makefile.inc'),'w')
|
|
|
96 |
g.write('CC = '+petscconf.CC+'\n')
|
| 2426 |
jroman |
97 |
if petscconf.IND64: blopexint = ' -DBlopexInt="long long" '
|
|
|
98 |
else: blopexint = ''
|
|
|
99 |
g.write('CFLAGS = '+petscconf.CC_FLAGS.replace('-Wall','').replace('-Wshadow','')+blopexint+'\n')
|
| 2423 |
jroman |
100 |
g.write('AR = '+petscconf.AR+' '+petscconf.AR_FLAGS+'\n')
|
|
|
101 |
g.write('AR_LIB_SUFFIX = '+petscconf.AR_LIB_SUFFIX+'\n')
|
|
|
102 |
g.write('RANLIB = '+petscconf.RANLIB+'\n')
|
|
|
103 |
g.write('TARGET_ARCH = \n')
|
|
|
104 |
g.close()
|
|
|
105 |
|
|
|
106 |
# Build package
|
|
|
107 |
result,output = commands.getstatusoutput('cd '+destDir+'&&'+petscconf.MAKE+' clean &&'+petscconf.MAKE)
|
|
|
108 |
log.write(output)
|
|
|
109 |
|
|
|
110 |
# Move files
|
|
|
111 |
incDir = os.sep.join([archdir,'include'])
|
|
|
112 |
libDir = os.sep.join([archdir,'lib'])
|
|
|
113 |
os.rename(os.path.join(destDir,'lib/libBLOPEX.'+petscconf.AR_LIB_SUFFIX),os.path.join(libDir,'libBLOPEX.'+petscconf.AR_LIB_SUFFIX))
|
|
|
114 |
for root, dirs, files in os.walk(os.path.join(destDir,'include')):
|
|
|
115 |
for name in files:
|
|
|
116 |
os.rename(os.path.join(destDir,'include/'+name),os.path.join(incDir,name))
|
|
|
117 |
|
|
|
118 |
# Write configuration files
|
|
|
119 |
conf.write('#ifndef SLEPC_HAVE_BLOPEX\n#define SLEPC_HAVE_BLOPEX 1\n#endif\n\n')
|
|
|
120 |
vars.write('BLOPEX_LIB = -lBLOPEX\n')
|
|
|
121 |
cmake.write('set (SLEPC_HAVE_BLOPEX YES)\n')
|
|
|
122 |
cmake.write('find_library (BLOPEX_LIB BLOPEX)\n')
|
|
|
123 |
|
|
|
124 |
return ['-L' + libDir] + ['-I' + incDir]
|
|
|
125 |
|