some cleanups and small bugfixes to conform better with python conventions

This commit is contained in:
Axel Kohlmeyer
2019-01-28 17:37:05 -05:00
parent 0cae619320
commit 1465352454
11 changed files with 846 additions and 234 deletions

View File

@ -1,20 +1,23 @@
#!/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
@ -50,7 +53,7 @@ zmqflag = args.zmq
# copy appropriate Makefile.lammps.* to Makefile.lammps
print("Building CSlib ...")
srcdir = fullpath(os.path.join("cslib","src"))
srcdir = fullpath(os.path.join("cslib", "src"))
if mpiflag and zmqflag:
cmd = "make -C %s lib_parallel" % srcdir
@ -60,20 +63,22 @@ elif not mpiflag and zmqflag:
cmd = "make -C %s lib_serial" % srcdir
elif not mpiflag and not zmqflag:
cmd = "make -C %s lib_serial zmq=no" % srcdir
print(cmd)
try:
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
print(txt.decode('UTF-8'))
except subprocess.CalledProcessError as e:
print("Make failed with:\n %s" % e.output.decode('UTF-8'))
sys.exit(1)
slb=os.path.join(srcdir,"libcsnompi.a")
if mpiflag: slb = os.path.join(srcdir,"libcsmpi.a")
shutil.copyfile(slb,os.path.join(srcdir,"libmessage.a"))
slb = os.path.join(srcdir, "libcsnompi.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"
shutil.copyfile(smk,"Makefile.lammps")
smk = "Makefile.lammps.nozmq"
if zmqflag:
smk = "Makefile.lammps.zmq"
shutil.copyfile(smk, "Makefile.lammps")
print("Using %s for Makefile.lammps" % smk)