2012-08-14 23:40:43 +08:00
|
|
|
#!/usr/local/bin/python
|
|
|
|
|
2012-08-15 04:13:20 +08:00
|
|
|
# copy LAMMPS shared library src/liblmp.so and lammps.py to system dirs
|
|
|
|
# Syntax: python install.py [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
|
|
|
|
|
|
|
import sys,commands
|
|
|
|
|
2012-08-15 04:13:20 +08:00
|
|
|
if len(sys.argv) > 3:
|
|
|
|
print "Syntax: python install.py [libdir] [pydir]"
|
|
|
|
sys.exit()
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-15 04:13:20 +08:00
|
|
|
if len(sys.argv) >= 2: libdir = sys.argv[1]
|
|
|
|
else: libdir = "/usr/local/lib"
|
2012-08-14 23:40:43 +08:00
|
|
|
|
2012-08-15 04:13:20 +08:00
|
|
|
if len(sys.argv) == 3: pydir = sys.argv[2]
|
|
|
|
else:
|
|
|
|
paths = sys.path
|
|
|
|
for i,path in enumerate(paths):
|
|
|
|
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
|
2012-08-14 23:40:43 +08:00
|
|
|
print str
|
|
|
|
outstr = commands.getoutput(str)
|
|
|
|
if len(outstr.strip()): print outstr
|
|
|
|
|
2012-08-15 04:13:20 +08:00
|
|
|
str = "cp ../python/lammps.py %s" % pydir
|
2012-08-14 23:40:43 +08:00
|
|
|
print str
|
|
|
|
outstr = commands.getoutput(str)
|
|
|
|
if len(outstr.strip()): print outstr
|
2012-08-15 04:13:20 +08:00
|
|
|
|