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
if len(sys.argv) == 3: pydir = sys.argv[2] libdir = "/usr/local/lib"
else: libpaths = os.environ['LD_LIBRARY_PATH'].split(':')
paths = sys.path if not libdir in libpaths:
for i,path in enumerate(paths): libdir = libpaths[0]
index = path.rfind("site-packages")
if index < 0: continue
if index == len(path) - len("site-packages"): break
pydir = paths[i]
str = "cp ../src/liblammps.so %s" % libdir pydir = False
print str try:
outstr = commands.getoutput(str) libdir = sys.argv[1]
if len(outstr.strip()): print outstr pydir = sys.argv[2]
except IndexError:
pass
str = "cp ../python/lammps.py %s" % pydir # copy the C library into place
print str
outstr = commands.getoutput(str)
if len(outstr.strip()): print outstr
shutil.copy('../src/liblammps.so', libdir)
# 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"]
)