summaryrefslogtreecommitdiffstats
path: root/emulator/install.py
blob: 65a756c24a6bf384e3501bc962b22dc53cba2997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python

import sys
from shutil import *
from dircache import *

bases = ( "/", "/usr", "/usr/local", "/opt" )
instfiles = ( "pyrazer.so", )


def usage():
	print "Usage: %s MOD_SRC_DIR" % sys.argv[0]

try:
	srcdir = sys.argv[1]
except IndexError:
	usage()
	sys.exit(1)

pyver = sys.version.split()[0] # pyver == "X.X.X"
pyver = pyver.split(".")
major = pyver[0]
minor = pyver[1]
pydir = "python%s.%s" % (major, minor)
modpath = "/lib/" + pydir + "/site-packages"

for base in bases:
	try:
		if not pydir in listdir(base + "/lib"):
			continue
		full_modpath = base + modpath
		# Probe whether it exists
		listdir(full_modpath)
	except OSError:
		continue
	print "Python module path found in " + full_modpath
	try:
		for f in instfiles:
			copy(srcdir + "/" + f, full_modpath)
			print "Installed \"%s\"" % f
	except IOError, e:
		print "ERROR: Could not install module \"%s\"" % f
		print e
		sys.exit(1)
	sys.exit(0)


print "ERROR: Python module install path not found."
print "Python modules are usually found in /usr/lib/pythonX.X/site-packages"
sys.exit(1)
bues.ch cgit interface