#
|
#
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# SLEPc - Scalable Library for Eigenvalue Problem Computations
|
# SLEPc - Scalable Library for Eigenvalue Problem Computations
|
# Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
# Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
#
|
#
|
# This file is part of SLEPc.
|
# This file is part of SLEPc.
|
#
|
#
|
# SLEPc is free software: you can redistribute it and/or modify it under the
|
# SLEPc is free software: you can redistribute it and/or modify it under the
|
# terms of version 3 of the GNU Lesser General Public License as published by
|
# terms of version 3 of the GNU Lesser General Public License as published by
|
# the Free Software Foundation.
|
# the Free Software Foundation.
|
#
|
#
|
# SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
# SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
# more details.
|
# more details.
|
#
|
#
|
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
# along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
# along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
#
|
#
|
|
|
import os
|
import os
|
import sys
|
import sys
|
import log
|
import log
|
import petscconf
|
import petscconf
|
import urllib
|
import urllib
|
import urlparse
|
import urlparse
|
import commands
|
import commands
|
|
|
def Install(conf,vars,cmake,url,archdir):
|
def Install(conf,vars,cmake,tmpdir,url,archdir):
|
'''
|
'''
|
Download and uncompress the BLOPEX tarball
|
Download and uncompress the BLOPEX tarball
|
'''
|
'''
|
log.write('='*80)
|
log.write('='*80)
|
log.Println('Installing BLOPEX...')
|
log.Println('Installing BLOPEX...')
|
|
|
if petscconf.PRECISION == 'single':
|
if petscconf.PRECISION == 'single':
|
log.Exit('ERROR: BLOPEX does not support single precision.')
|
log.Exit('ERROR: BLOPEX does not support single precision.')
|
|
|
# Create externalpackages directory
|
# Create externalpackages directory
|
externdir = 'externalpackages'
|
externdir = 'externalpackages'
|
if not os.path.exists(externdir):
|
if not os.path.exists(externdir):
|
try:
|
try:
|
os.mkdir(externdir)
|
os.mkdir(externdir)
|
except:
|
except:
|
sys.exit('ERROR: cannot create directory ' + externdir)
|
sys.exit('ERROR: cannot create directory ' + externdir)
|
|
|
# Download tarball
|
# Download tarball
|
packagename = 'blopex-1.1.2'
|
packagename = 'blopex-1.1.2'
|
if url=='':
|
if url=='':
|
url = 'http://www.grycap.upv.es/slepc/download/external/'+packagename+'.tar.gz'
|
url = 'http://www.grycap.upv.es/slepc/download/external/'+packagename+'.tar.gz'
|
archiveZip = 'blopex.tar.gz'
|
archiveZip = 'blopex.tar.gz'
|
localFile = os.sep.join([externdir,archiveZip])
|
localFile = os.sep.join([externdir,archiveZip])
|
log.Println('Downloading '+url+' to '+localFile)
|
log.Println('Downloading '+url+' to '+localFile)
|
|
|
if os.path.exists(localFile):
|
if os.path.exists(localFile):
|
os.remove(localFile)
|
os.remove(localFile)
|
try:
|
try:
|
urllib.urlretrieve(url, localFile)
|
urllib.urlretrieve(url, localFile)
|
except Exception, e:
|
except Exception, e:
|
name = 'blopex'
|
name = 'blopex'
|
filename = os.path.basename(urlparse.urlparse(url)[2])
|
filename = os.path.basename(urlparse.urlparse(url)[2])
|
failureMessage = '''\
|
failureMessage = '''\
|
Unable to download package %s from: %s
|
Unable to download package %s from: %s
|
* If your network is disconnected - please reconnect and rerun config/configure.py
|
* If your network is disconnected - please reconnect and rerun config/configure.py
|
* Alternatively, you can download the above URL manually, to /yourselectedlocation/%s
|
* Alternatively, you can download the above URL manually, to /yourselectedlocation/%s
|
and use the configure option:
|
and use the configure option:
|
--download-%s=/yourselectedlocation/%s
|
--download-%s=/yourselectedlocation/%s
|
''' % (name, url, filename, name, filename)
|
''' % (name, url, filename, name, filename)
|
raise RuntimeError(failureMessage)
|
raise RuntimeError(failureMessage)
|
|
|
# Uncompress tarball
|
# Uncompress tarball
|
destDir = os.sep.join([externdir,packagename])
|
destDir = os.sep.join([externdir,packagename])
|
log.Println('Uncompressing '+localFile+' to directory '+destDir)
|
log.Println('Uncompressing '+localFile+' to directory '+destDir)
|
if os.path.exists(destDir):
|
if os.path.exists(destDir):
|
for root, dirs, files in os.walk(destDir, topdown=False):
|
for root, dirs, files in os.walk(destDir, topdown=False):
|
for name in files:
|
for name in files:
|
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
for name in dirs:
|
for name in dirs:
|
os.rmdir(os.path.join(root, name))
|
os.rmdir(os.path.join(root, name))
|
try:
|
try:
|
if sys.version_info >= (2,5):
|
if sys.version_info >= (2,5):
|
import tarfile
|
import tarfile
|
tar = tarfile.open(localFile, "r:gz")
|
tar = tarfile.open(localFile, "r:gz")
|
tar.extractall(path=externdir)
|
tar.extractall(path=externdir)
|
tar.close()
|
tar.close()
|
os.remove(localFile)
|
os.remove(localFile)
|
else:
|
else:
|
result,output = commands.getstatusoutput('cd '+externdir+'; gunzip '+archiveZip+'; tar -xf '+archiveZip.split('.gz')[0])
|
result,output = commands.getstatusoutput('cd '+externdir+'; gunzip '+archiveZip+'; tar -xf '+archiveZip.split('.gz')[0])
|
os.remove(localFile.split('.gz')[0])
|
os.remove(localFile.split('.gz')[0])
|
except RuntimeError, e:
|
except RuntimeError, e:
|
raise RuntimeError('Error uncompressing '+archiveZip+': '+str(e))
|
raise RuntimeError('Error uncompressing '+archiveZip+': '+str(e))
|
|
|
# Configure
|
# Configure
|
g = open(os.path.join(destDir,'Makefile.inc'),'w')
|
g = open(os.path.join(destDir,'Makefile.inc'),'w')
|
g.write('CC = '+petscconf.CC+'\n')
|
g.write('CC = '+petscconf.CC+'\n')
|
if petscconf.IND64: blopexint = ' -DBlopexInt="long long" '
|
if petscconf.IND64: blopexint = ' -DBlopexInt="long long" '
|
else: blopexint = ''
|
else: blopexint = ''
|
g.write('CFLAGS = '+petscconf.CC_FLAGS.replace('-Wall','').replace('-Wshadow','')+blopexint+'\n')
|
g.write('CFLAGS = '+petscconf.CC_FLAGS.replace('-Wall','').replace('-Wshadow','')+blopexint+'\n')
|
g.write('AR = '+petscconf.AR+' '+petscconf.AR_FLAGS+'\n')
|
g.write('AR = '+petscconf.AR+' '+petscconf.AR_FLAGS+'\n')
|
g.write('AR_LIB_SUFFIX = '+petscconf.AR_LIB_SUFFIX+'\n')
|
g.write('AR_LIB_SUFFIX = '+petscconf.AR_LIB_SUFFIX+'\n')
|
g.write('RANLIB = '+petscconf.RANLIB+'\n')
|
g.write('RANLIB = '+petscconf.RANLIB+'\n')
|
g.write('TARGET_ARCH = \n')
|
g.write('TARGET_ARCH = \n')
|
g.close()
|
g.close()
|
|
|
# Build package
|
# Build package
|
result,output = commands.getstatusoutput('cd '+destDir+'&&'+petscconf.MAKE+' clean &&'+petscconf.MAKE)
|
result,output = commands.getstatusoutput('cd '+destDir+'&&'+petscconf.MAKE+' clean &&'+petscconf.MAKE)
|
log.write(output)
|
log.write(output)
|
|
|
# Move files
|
# Move files
|
incDir = os.sep.join([archdir,'include'])
|
incDir = os.sep.join([archdir,'include'])
|
libDir = os.sep.join([archdir,'lib'])
|
libDir = os.sep.join([archdir,'lib'])
|
os.rename(os.path.join(destDir,'lib/libBLOPEX.'+petscconf.AR_LIB_SUFFIX),os.path.join(libDir,'libBLOPEX.'+petscconf.AR_LIB_SUFFIX))
|
os.rename(os.path.join(destDir,'lib/libBLOPEX.'+petscconf.AR_LIB_SUFFIX),os.path.join(libDir,'libBLOPEX.'+petscconf.AR_LIB_SUFFIX))
|
for root, dirs, files in os.walk(os.path.join(destDir,'include')):
|
for root, dirs, files in os.walk(os.path.join(destDir,'include')):
|
for name in files:
|
for name in files:
|
os.rename(os.path.join(destDir,'include/'+name),os.path.join(incDir,name))
|
os.rename(os.path.join(destDir,'include/'+name),os.path.join(incDir,name))
|
|
|
# Write configuration files
|
# Write configuration files
|
conf.write('#ifndef SLEPC_HAVE_BLOPEX\n#define SLEPC_HAVE_BLOPEX 1\n#endif\n\n')
|
conf.write('#ifndef SLEPC_HAVE_BLOPEX\n#define SLEPC_HAVE_BLOPEX 1\n#endif\n\n')
|
vars.write('BLOPEX_LIB = -lBLOPEX\n')
|
vars.write('BLOPEX_LIB = -lBLOPEX\n')
|
cmake.write('set (SLEPC_HAVE_BLOPEX YES)\n')
|
cmake.write('set (SLEPC_HAVE_BLOPEX YES)\n')
|
cmake.write('find_library (BLOPEX_LIB BLOPEX)\n')
|
cmake.write('find_library (BLOPEX_LIB BLOPEX)\n')
|
|
|
return ['-L' + libDir] + ['-I' + incDir]
|
return ['-L' + libDir] + ['-I' + incDir]
|
|
|
|
|
|
|