Commit 14653524 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

some cleanups and small bugfixes to conform better with python conventions

parent 0cae6193
Loading
Loading
Loading
Loading
+22 −16
Original line number Diff line number Diff line
#!/usr/bin/env python

# install.py tool to do a generic build of a library
# soft linked to by many of the lib/Install.py files
# used to automate the steps described in the corresponding lib/README
"""
Install.py tool to do a generic build of a library
soft linked to by many of the lib/Install.py files
used to automate the steps described in the corresponding lib/README
"""

from __future__ import print_function
import sys, os, subprocess
from argparse import ArgumentParser

sys.path.append('..')
from install_helpers import get_cpus, fullpath
from argparse import ArgumentParser

parser = ArgumentParser(prog='Install.py',
                        description="LAMMPS library build wrapper script")

help = """
HELP = """
Syntax from src dir: make lib-libname args="-m machine -e suffix"
Syntax from lib dir: python Install.py -m machine -e suffix

@@ -39,10 +42,11 @@ args = parser.parse_args()
# print help message and exit, if neither build nor path options are given
if not args.machine and not args.extramake:
  parser.print_help()
  sys.exit(help)
  sys.exit(HELP)

machine = args.machine
extraflag = args.extramake
extraflag = not args.extramake
suffix = args.extramake

# set lib from working dir

@@ -81,8 +85,10 @@ except subprocess.CalledProcessError as e:
  print("Make failed with:\n %s" % e.output.decode('UTF-8'))
  sys.exit(1)

if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
if os.path.exists("lib%s.a" % lib):
  print("Build was successful")
else:
  sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib, lib))

if has_extramake and not os.path.exists("Makefile.lammps"):
  print("WARNING: lib/%s/Makefile.lammps was NOT created" % lib)
+26 −21
Original line number Diff line number Diff line
#!/usr/bin/env python

# Install.py tool to build the GPU library
# used to automate the steps described in the README file in this dir
"""
Install.py tool to build the GPU library
used to automate the steps described in the README file in this dir
"""

from __future__ import print_function
import sys, os, subprocess, shutil
from argparse import ArgumentParser

sys.path.append('..')
from install_helpers import get_cpus
from argparse import ArgumentParser

parser = ArgumentParser(prog='Install.py',
                        description="LAMMPS library build wrapper script")

# help message

help = """
HELP = """
Syntax from src dir: make lib-gpu args="-m machine -h hdir -a arch -p precision -e esuffix -b -o osuffix"
Syntax from lib dir: python Install.py -m machine -h hdir -a arch -p precision -e esuffix -b -o osuffix

@@ -56,9 +59,9 @@ parser.add_argument("-o", "--output",
args = parser.parse_args()

# print help message and exit, if neither build nor output options are given
if args.build == False and not args.output:
if not args.build and not args.output:
  parser.print_help()
  sys.exit(help)
  sys.exit(HELP)

hflag = 0
eflag = 0
@@ -71,9 +74,12 @@ if args.build:
isuffix = args.machine
arch = args.arch

if args.precision == "double": precstr = "-D_DOUBLE_DOUBLE"
elif args.precision == "mixed": precstr = "-D_SINGLE_DOUBLE"
else: precstr = "-D_SINGLE_SINGLE"
if args.precision == "double":
  precstr = "-D_DOUBLE_DOUBLE"
elif args.precision == "mixed":
  precstr = "-D_SINGLE_DOUBLE"
else:
  precstr = "-D_SINGLE_SINGLE"

lmpsuffix = args.extramake

@@ -138,4 +144,3 @@ if makeflag:
if outflag:
  print("Creating new Makefile.%s" % osuffix)
  shutil.copyfile("Makefile.auto", "Makefile.%s" % osuffix)
+47 −37
Original line number Diff line number Diff line
#!/usr/bin/env python

# install.py tool to download, compile, and setup the kim-api library
# used to automate the steps described in the README file in this dir
"""
Install.py tool to download, compile, and setup the kim-api library
used to automate the steps described in the README file in this dir
"""

from __future__ import print_function
import sys,os,re,subprocess,shutil
import sys, os, subprocess, shutil
from argparse import ArgumentParser

sys.path.append('..')
from install_helpers import fullpath, geturl
from argparse import ArgumentParser

parser = ArgumentParser(prog='Install.py',
                        description="LAMMPS library build wrapper script")
@@ -19,7 +22,7 @@ version = "kim-api-v1.9.5"

# help message

help = """
HELP = """
Syntax from src dir: make lib-kim args="-b -v version  -a kim-name"
                 or: make lib-kim args="-b -a everything"
                 or: make lib-kim args="-n -a kim-name"
@@ -64,13 +67,13 @@ parser.add_argument("-vv", "--verbose", action="store_true",
args = parser.parse_args()

# print help message and exit, if neither build nor path options are given
if args.build == False and not args.path and args.nobuild == False:
if not args.build and not args.path and not args.nobuild:
  parser.print_help()
  sys.exit(help)
  sys.exit(HELP)

buildflag = args.build
pathflag = args.path != None
addflag = args.add != None
pathflag = args.path is not None
addflag = args.add is not None
addmodelname = args.add
everythingflag = False
if addflag and addmodelname == "everything":
@@ -81,7 +84,8 @@ verboseflag = args.verbose
if pathflag:
  buildflag = False
  kimdir = args.path
  if not os.path.isdir(kimdir): sys.exit("KIM API path %s does not exist" % kimdir)
  if not os.path.isdir(kimdir):
    sys.exit("KIM API path %s does not exist" % kimdir)
  kimdir = fullpath(kimdir)

url = "https://s3.openkim.org/kim-api/%s.txz" % version
@@ -139,24 +143,28 @@ if buildflag:
  print("Building kim-api ...")
  cmd = 'cd "%s/%s"; make' % (thisdir, version)
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  if verboseflag: print(txt.decode("UTF-8"))
  if verboseflag:
    print(txt.decode("UTF-8"))

  # install kim-api

  print("Installing kim-api ...")
  cmd = 'cd "%s/%s"; make install' % (thisdir, version)
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  if verboseflag: print(txt.decode("UTF-8"))
  if verboseflag:
    print(txt.decode("UTF-8"))

  # remove source files

  print("Building and installing example Models")
  cmd = 'cd "%s/%s/examples"; make model-drivers-all-system' % (thisdir, version)
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  if verboseflag: print (txt.decode("UTF-8"))
  if verboseflag:
    print(txt.decode("UTF-8"))
  cmd = 'cd "%s/%s/examples"; make models-all-system' % (thisdir, version)
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  if verboseflag: print (txt.decode("UTF-8"))
  if verboseflag:
    print(txt.decode("UTF-8"))

  print("Removing kim-api source and build files ...")
  cmd = 'cd "%s"; rm -rf %s; rm -rf %s.txz' % (thisdir, version, version)
@@ -167,7 +175,8 @@ if buildflag:
    print("Adding all OpenKIM models, this will take a while ...")
    cmd = '%s/bin/kim-api-v1-collections-management install system OpenKIM' % (kimdir)
    txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
    if verboseflag: print(txt.decode("UTF-8"))
    if verboseflag:
      print(txt.decode("UTF-8"))

# add single OpenKIM model
if addflag:
@@ -183,4 +192,5 @@ if addflag:
  # download single model
  cmd = '%s/bin/kim-api-v1-collections-management install system %s' % (kimdir.decode("UTF-8"), addmodelname)
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  if verboseflag: print (txt.decode("UTF-8"))
  if verboseflag:
    print(txt.decode("UTF-8"))
+25 −20
Original line number Diff line number Diff line
#!/usr/bin/env python

# Install.py tool to download, unpack, build, and link to the LATTE library
# used to automate the steps described in the README file in this dir
"""
Install.py tool to download, unpack, build, and link to the LATTE library
used to automate the steps described in the README file in this dir
"""

from __future__ import print_function
import sys,os,re,subprocess,shutil,tarfile
sys.path.append('..')
from install_helpers import get_cpus,fullpath,geturl,checkmd5sum
import sys, os, subprocess, shutil, tarfile
from argparse import ArgumentParser

sys.path.append('..')
from install_helpers import fullpath, geturl, checkmd5sum

parser = ArgumentParser(prog='Install.py',
                        description="LAMMPS library build wrapper script")

@@ -26,7 +29,7 @@ checksums = { \

# help message

help = """
HELP = """
Syntax from src dir: make lib-latte args="-b"
                 or: make lib-latte args="-p /usr/local/latte"
                 or: make lib-latte args="-m gfortran"
@@ -57,21 +60,22 @@ parser.add_argument("-v", "--version", default=version,
args = parser.parse_args()

# print help message and exit, if neither build nor path options are given
if args.build == False and not args.path:
if not args.build and not args.path:
  parser.print_help()
  sys.exit(help)
  sys.exit(HELP)

homepath = fullpath(".")

buildflag = args.build
pathflag = args.path != None
pathflag = args.path is not None
version = args.version
suffixflag = args.machine != None
suffixflag = args.machine is not None
suffix = args.machine

if pathflag:
  lattedir = args.path
  if not os.path.isdir(lattedir): sys.exit("LATTE path %s does not exist" % lattedir)
  if not os.path.isdir(lattedir):
    sys.exit("LATTE path %s does not exist" % lattedir)
  lattedir = fullpath(lattedir)

homedir = "LATTE-%s" % version
@@ -127,7 +131,8 @@ os.symlink(os.path.join(lattedir,'src','latte_c_bind.o'),'filelink.o')
# copy Makefile.lammps.suffix to Makefile.lammps

if suffixflag or not os.path.exists("Makefile.lammps"):
  if suffix == None: suffix = 'gfortran'
  if suffix is None:
    suffix = 'gfortran'
  print("Creating Makefile.lammps")
  if os.path.exists("Makefile.lammps.%s" % suffix):
    shutil.copyfile("Makefile.lammps.%s" % suffix, 'Makefile.lammps')
+22 −17
Original line number Diff line number Diff line
#!/usr/bin/env python

# Install.py tool to build the CSlib library
# used to automate the steps described in the README file in this dir
"""
Install.py tool to build the CSlib library
used to automate the steps described in the README file in this dir
"""

from __future__ import print_function
import sys,os,re,subprocess,shutil
sys.path.append('..')
from install_helpers import get_cpus,fullpath
import sys, os, subprocess, shutil
from argparse import ArgumentParser

sys.path.append('..')
from install_helpers import fullpath

parser = ArgumentParser(prog='Install.py',
                        description="LAMMPS library build wrapper script")

# help message

help = """
HELP = """
Syntax from src dir: make lib-message args="-m"
                 or: make lib-message args="-s -z"
Syntax from lib dir: python Install.py -m
@@ -37,9 +40,9 @@ parser.add_argument("-z", "--zmq", default=False, action="store_true",
args = parser.parse_args()

# print help message and exit, if neither build nor path options are given
if args.mpi == False and args.serial == False:
if not args.mpi and not args.serial:
  parser.print_help()
  sys.exit(help)
  sys.exit(HELP)

mpiflag = args.mpi
serialflag = args.serial
@@ -70,10 +73,12 @@ except subprocess.CalledProcessError as e:
    sys.exit(1)

slb = os.path.join(srcdir, "libcsnompi.a")
if mpiflag: slb = os.path.join(srcdir,"libcsmpi.a")
if mpiflag:
  slb = os.path.join(srcdir, "libcsmpi.a")
shutil.copyfile(slb, os.path.join(srcdir, "libmessage.a"))

smk = "Makefile.lammps.nozmq"
if zmqflag: smk="Makefile.lammps.zmq"
if zmqflag:
  smk = "Makefile.lammps.zmq"
shutil.copyfile(smk, "Makefile.lammps")
print("Using %s for Makefile.lammps" % smk)
Loading