make Install.py for lib/smd and lib/voronoi consistent

This commit is contained in:
Axel Kohlmeyer
2017-07-28 14:03:29 -04:00
parent f3850da9fe
commit ffb778cf9b
3 changed files with 52 additions and 46 deletions

5
lib/smd/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# ignore these entries with git
/eigen.tar.gz
/eigen-eigen-*
/includelink
/eigen3

View File

@ -11,30 +11,28 @@ except: from urllib import urlretrieve as geturl
# help message # help message
help = """ help = """
Syntax from src dir: make lib-smd args="-h hpath hdir -g -l" Syntax from src dir: make lib-smd
Syntax from lib dir: python Install.py -h hpath hdir -g -l or: make lib-smd args="-p /usr/include/eigen3"
Syntax from lib dir: python Install.py
or: python Install.py -p /usr/include/eigen3"
or: python Install.py -v 3.3.4 -b
specify one or more options, order does not matter specify one or more options, order does not matter
-h = set home dir of Eigen to be hpath/hdir -b = download and unpack/configure the Eigen library (default)
hpath can be full path, contain '~' or '.' chars -p = specify folder holding an existing installation of Eigen
default hpath = . = lib/smd -v = set version of Eigen library to download and set up (default = 3.3.4)
default hdir = "ee" = what tarball unpacks to (eigen-eigen-*)
-g = grab (download) tarball from http://eigen.tuxfamily.org website
unpack it to hpath/hdir
hpath must already exist
if hdir already exists, it will be deleted before unpack
-l = create softlink (includelink) in lib/smd to Eigen src dir
Example: Example:
make lib-smd args="-g -l" # download/build in default lib/smd/eigen-eigen-* make lib-smd args="-b" # download/build in default lib/smd/eigen-eigen-*
""" """
# settings # settings
version = '3.3.4' version = '3.3.4'
url = "http://bitbucket.org/eigen/eigen/get/%s.tar.gz" % version
tarball = "eigen.tar.gz" tarball = "eigen.tar.gz"
# print error message or help # print error message or help
@ -46,59 +44,65 @@ def error(str=None):
# expand to full path name # expand to full path name
# process leading '~' or relative path # process leading '~' or relative path
def fullpath(path): def fullpath(path):
return os.path.abspath(os.path.expanduser(path)) return os.path.abspath(os.path.expanduser(path))
# parse args # parse args
args = sys.argv[1:] args = sys.argv[1:]
nargs = len(args) nargs = len(args)
if nargs == 0: error()
homepath = "." homepath = "."
homedir = "ee" homedir = "eigen3"
grabflag = 0 grabflag = True
linkflag = 0 buildflag = True
pathflag = False
linkflag = True
iarg = 0 iarg = 0
while iarg < nargs: while iarg < nargs:
if args[iarg] == "-h": if args[iarg] == "-v":
if iarg+3 > nargs: error() if iarg+2 > nargs: error()
homepath = args[iarg+1] version = args[iarg+1]
homedir = args[iarg+2] iarg += 2
iarg += 3 elif args[iarg] == "-p":
elif args[iarg] == "-g": if iarg+2 > nargs: error()
grabflag = 1 eigenpath = fullpath(args[iarg+1])
iarg += 1 pathflag = True
elif args[iarg] == "-l": buildflag = False
linkflag = 1 iarg += 2
elif args[iarg] == "-b":
buildflag = True
iarg += 1 iarg += 1
else: error() else: error()
homepath = fullpath(homepath) homepath = fullpath(homepath)
if not os.path.isdir(homepath): error("Eigen path does not exist")
if (pathflag):
if not os.path.isdir(eigenpath): error("Eigen path does not exist")
if (buildflag and pathflag):
error("Cannot use -b and -p flag at the same time")
# download and unpack Eigen tarball # download and unpack Eigen tarball
# glob to find name of dir it unpacks to # use glob to find name of dir it unpacks to
if grabflag: if buildflag:
print("Downloading Eigen ...") print("Downloading Eigen ...")
url = "http://bitbucket.org/eigen/eigen/get/%s.tar.gz" % version
geturl(url,"%s/%s" % (homepath,tarball)) geturl(url,"%s/%s" % (homepath,tarball))
print("Unpacking Eigen tarball ...") print("Unpacking Eigen tarball ...")
edir = glob.glob("%s/eigen-eigen-*" % homepath) edir = glob.glob("%s/eigen-eigen-*" % homepath)
for one in edir: for one in edir:
if os.path.isdir(one): if os.path.isdir(one):
subprocess.check_output("rm -rf %s" % one,shell=True) subprocess.check_output("rm -rf %s" % one,stderr=subprocess.STDOUT,shell=True)
cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarball) cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarball)
subprocess.check_output(cmd,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if homedir != "ee": edir = glob.glob("%s/eigen-eigen-*" % homepath)
if os.path.exists(homedir): os.rename(edir[0],"%s/%s" % (homepath,homedir))
subprocess.check_output("rm -rf %s" % homedir,shell=True)
edir = glob.glob("%s/eigen-eigen-*" % homepath)
os.rename(edir[0],"%s/%s" % (homepath,homedir))
# create link in lib/smd to Eigen src dir # create link in lib/smd to Eigen src dir
@ -106,9 +110,7 @@ if linkflag:
print("Creating link to Eigen files") print("Creating link to Eigen files")
if os.path.isfile("includelink") or os.path.islink("includelink"): if os.path.isfile("includelink") or os.path.islink("includelink"):
os.remove("includelink") os.remove("includelink")
if homedir == "ee": if pathflag: linkdir = eigenpath
edir = glob.glob("%s/eigen-eigen-*" % homepath)
linkdir = edir[0]
else: linkdir = "%s/%s" % (homepath,homedir) else: linkdir = "%s/%s" % (homepath,homedir)
cmd = "ln -s %s includelink" % linkdir cmd = "ln -s %s includelink" % linkdir
subprocess.check_output(cmd,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)

View File

@ -2,6 +2,7 @@
# Install.py tool to download, unpack, build, and link to the Voro++ library # Install.py tool to download, unpack, build, and link to the Voro++ library
# used to automate the steps described in the README file in this dir # used to automate the steps described in the README file in this dir
from __future__ import print_function from __future__ import print_function
import sys,os,re,subprocess import sys,os,re,subprocess
try: from urllib.request import urlretrieve as geturl try: from urllib.request import urlretrieve as geturl
@ -21,8 +22,7 @@ specify one or more options, order does not matter
-b = download and build the Voro++ library (default) -b = download and build the Voro++ library (default)
-p = specify folder of existing Voro++ installation -p = specify folder of existing Voro++ installation
-v = version of Voro++ to download and build -v = set version of Voro++ to download and build (default voro++-0.4.6)
default version = voro++-0.4.6 (current as of Jan 2015)
Example: Example:
@ -51,7 +51,6 @@ def fullpath(path):
args = sys.argv[1:] args = sys.argv[1:]
nargs = len(args) nargs = len(args)
if nargs == 0: error()
homepath = "." homepath = "."
homedir = version homedir = version