2013-06-10 23:01:13 +08:00
|
|
|
#!/usr/bin/env python
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
# copy LAMMPS src/liblammps.so and lammps.py to system dirs
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
instructions = """
|
|
|
|
Syntax: python install.py [-h] [libdir] [pydir]
|
|
|
|
libdir = target dir for src/liblammps.so, default = /usr/local/lib
|
|
|
|
pydir = target dir for lammps.py, default = Python site-packages dir
|
|
|
|
"""
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
import sys,os,commands
|
|
|
|
|
|
|
|
if (len(sys.argv) > 1 and sys.argv[1] == "-h") or len(sys.argv) > 3:
|
2012-08-15 22:34:23 +08:00
|
|
|
print instructions
|
2012-08-15 04:13:20 +08:00
|
|
|
sys.exit()
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
if len(sys.argv) >= 2: libdir = sys.argv[1]
|
|
|
|
else: libdir = "/usr/local/lib"
|
|
|
|
|
|
|
|
if len(sys.argv) == 3: pydir = sys.argv[2]
|
|
|
|
else: pydir = ""
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
# copy C lib to libdir if it exists
|
|
|
|
# warn if not in LD_LIBRARY_PATH or LD_LIBRARY_PATH is undefined
|
2012-08-15 04:13:20 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
if not os.path.isdir(libdir):
|
|
|
|
print "ERROR: libdir %s does not exist" % libdir
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
if "LD_LIBRARY_PATH" not in os.environ:
|
|
|
|
print "WARNING: LD_LIBRARY_PATH undefined, cannot check libdir %s" % libdir
|
|
|
|
else:
|
|
|
|
libpaths = os.environ['LD_LIBRARY_PATH'].split(':')
|
|
|
|
if libdir not in libpaths:
|
|
|
|
print "WARNING: libdir %s not in LD_LIBRARY_PATH" % libdir
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
str = "cp ../src/liblammps.so %s" % libdir
|
|
|
|
print str
|
|
|
|
outstr = commands.getoutput(str)
|
|
|
|
if len(outstr.strip()): print outstr
|
2012-08-15 04:13:20 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
# copy lammps.py to pydir if it exists
|
|
|
|
# if pydir not specified, install in site-packages via distutils setup()
|
2012-08-15 22:34:23 +08:00
|
|
|
|
|
|
|
if pydir:
|
2012-08-16 03:49:01 +08:00
|
|
|
if not os.path.isdir(pydir):
|
|
|
|
print "ERROR: pydir %s does not exist" % pydir
|
2012-08-15 22:34:23 +08:00
|
|
|
sys.exit()
|
2012-08-16 03:49:01 +08:00
|
|
|
str = "cp ../python/lammps.py %s" % pydir
|
|
|
|
print str
|
|
|
|
outstr = commands.getoutput(str)
|
|
|
|
if len(outstr.strip()): print outstr
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
print "installing lammps.py in Python site-packages dir"
|
2012-08-15 22:34:23 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
os.chdir('../python') # in case invoked via make in src dir
|
2012-08-15 22:34:23 +08:00
|
|
|
|
2012-08-16 03:49:01 +08:00
|
|
|
from distutils.core import setup
|
|
|
|
sys.argv = ["setup.py","install"] # as if had run "python setup.py install"
|
2012-08-15 22:34:23 +08:00
|
|
|
setup(name = "lammps",
|
2012-08-16 03:49:01 +08:00
|
|
|
version = "15Aug12",
|
|
|
|
author = "Steve Plimpton",
|
|
|
|
author_email = "sjplimp@sandia.gov",
|
|
|
|
url = "http://lammps.sandia.gov",
|
|
|
|
description = "LAMMPS molecular dynamics library",
|
|
|
|
py_modules = ["lammps"])
|