diff --git a/lib/smd/.gitignore b/lib/smd/.gitignore new file mode 100644 index 0000000000..4ab7a789ec --- /dev/null +++ b/lib/smd/.gitignore @@ -0,0 +1,5 @@ +# ignore these entries with git +/eigen.tar.gz +/eigen-eigen-* +/includelink +/eigen3 diff --git a/lib/smd/Install.py b/lib/smd/Install.py index 0fa05375db..18986b4477 100644 --- a/lib/smd/Install.py +++ b/lib/smd/Install.py @@ -11,30 +11,28 @@ except: from urllib import urlretrieve as geturl # help message help = """ -Syntax from src dir: make lib-smd args="-h hpath hdir -g -l" -Syntax from lib dir: python Install.py -h hpath hdir -g -l +Syntax from src dir: make lib-smd + 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 - -h = set home dir of Eigen to be hpath/hdir - hpath can be full path, contain '~' or '.' chars - default hpath = . = lib/smd - 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 + -b = download and unpack/configure the Eigen library (default) + -p = specify folder holding an existing installation of Eigen + -v = set version of Eigen library to download and set up (default = 3.3.4) + 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 version = '3.3.4' -url = "http://bitbucket.org/eigen/eigen/get/%s.tar.gz" % version tarball = "eigen.tar.gz" # print error message or help @@ -46,59 +44,65 @@ def error(str=None): # expand to full path name # process leading '~' or relative path - + def fullpath(path): return os.path.abspath(os.path.expanduser(path)) - + # parse args args = sys.argv[1:] nargs = len(args) -if nargs == 0: error() homepath = "." -homedir = "ee" +homedir = "eigen3" -grabflag = 0 -linkflag = 0 +grabflag = True +buildflag = True +pathflag = False +linkflag = True iarg = 0 while iarg < nargs: - if args[iarg] == "-h": - if iarg+3 > nargs: error() - homepath = args[iarg+1] - homedir = args[iarg+2] - iarg += 3 - elif args[iarg] == "-g": - grabflag = 1 - iarg += 1 - elif args[iarg] == "-l": - linkflag = 1 + if args[iarg] == "-v": + if iarg+2 > nargs: error() + version = args[iarg+1] + iarg += 2 + elif args[iarg] == "-p": + if iarg+2 > nargs: error() + eigenpath = fullpath(args[iarg+1]) + pathflag = True + buildflag = False + iarg += 2 + elif args[iarg] == "-b": + buildflag = True iarg += 1 else: error() 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 -# 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 ...") + url = "http://bitbucket.org/eigen/eigen/get/%s.tar.gz" % version geturl(url,"%s/%s" % (homepath,tarball)) print("Unpacking Eigen tarball ...") edir = glob.glob("%s/eigen-eigen-*" % homepath) for one in edir: 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) - subprocess.check_output(cmd,shell=True) - if homedir != "ee": - if os.path.exists(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)) + subprocess.check_output(cmd,stderr=subprocess.STDOUT,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 @@ -106,9 +110,7 @@ if linkflag: print("Creating link to Eigen files") if os.path.isfile("includelink") or os.path.islink("includelink"): os.remove("includelink") - if homedir == "ee": - edir = glob.glob("%s/eigen-eigen-*" % homepath) - linkdir = edir[0] + if pathflag: linkdir = eigenpath else: linkdir = "%s/%s" % (homepath,homedir) cmd = "ln -s %s includelink" % linkdir - subprocess.check_output(cmd,shell=True) + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index 285e11fb9a..9d6c58d273 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -2,6 +2,7 @@ # 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 + from __future__ import print_function import sys,os,re,subprocess 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) -p = specify folder of existing Voro++ installation - -v = version of Voro++ to download and build - default version = voro++-0.4.6 (current as of Jan 2015) + -v = set version of Voro++ to download and build (default voro++-0.4.6) Example: @@ -51,7 +51,6 @@ def fullpath(path): args = sys.argv[1:] nargs = len(args) -if nargs == 0: error() homepath = "." homedir = version