git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8670 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2012-08-15 14:34:23 +00:00
parent 127f12e6fa
commit 4486372868
1 changed files with 42 additions and 25 deletions

View File

@ -1,35 +1,52 @@
#!/usr/local/bin/python #!/usr/bin/env python
# copy LAMMPS shared library src/liblammps.so and lammps.py to system dirs instructions = """copy LAMMPS shared library src/liblammps.so and lammps.py to system dirs
# Syntax: python install.py [libdir] [pydir] Syntax: python install.py [libdir] [pydir]
# libdir = target dir for src/liblammps.so, default = /usr/local/lib libdir = target dir for src/liblammps.so, default = /usr/local/lib, or the first
# pydir = target dir for lammps.py, default = Python site-packages dir item in LD_LIBRARY_PATH if it doesn't exist.
pydir = target dir for lammps.py, default = Python site-packages, via distutils."""
import sys,commands import sys, shutil, os
if len(sys.argv) > 3: if len(sys.argv) > 3:
print "Syntax: python install.py [libdir] [pydir]" print instructions
sys.exit() sys.exit()
if len(sys.argv) >= 2: libdir = sys.argv[1] # verify that our user-specified path is in LD_LIBRARY_PATH
else: libdir = "/usr/local/lib" # since if not, the install won't work
libdir = "/usr/local/lib"
libpaths = os.environ['LD_LIBRARY_PATH'].split(':')
if not libdir in libpaths:
libdir = libpaths[0]
if len(sys.argv) == 3: pydir = sys.argv[2] pydir = False
else: try:
paths = sys.path libdir = sys.argv[1]
for i,path in enumerate(paths): pydir = sys.argv[2]
index = path.rfind("site-packages") except IndexError:
if index < 0: continue pass
if index == len(path) - len("site-packages"): break
pydir = paths[i]
str = "cp ../src/liblammps.so %s" % libdir # copy the C library into place
print str
outstr = commands.getoutput(str)
if len(outstr.strip()): print outstr
str = "cp ../python/lammps.py %s" % pydir shutil.copy('../src/liblammps.so', libdir)
print str
outstr = commands.getoutput(str)
if len(outstr.strip()): print outstr
# if user-specified, copy lammps.py into directory
# else invoke setup from Distutils to add to site-packages
if pydir:
shutil.copy('../python/lammps.py', pydir)
sys.exit()
from distutils.core import setup
os.chdir('../python')
setup(name = "lammps",
version = "15Aug12",
author = "Steve Plimpton",
author_email = "sjplimp@sandia.gov",
url = "http://lammps.sandia.gov",
description = """LAMMPS molecular dynamics library""",
py_modules = ["lammps"]
)