summaryrefslogtreecommitdiff
path: root/py/python/Ice.py
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2008-03-12 20:37:19 -0700
committerMark Spruiell <mes@zeroc.com>2008-03-12 20:37:19 -0700
commitaba437bf7457b1953462154ea37e206a9e9d767b (patch)
tree24e6ac79b33e8e61cc587d8d665306c03c8d80c8 /py/python/Ice.py
parentFixed build against binary distribution (diff)
downloadice-aba437bf7457b1953462154ea37e206a9e9d767b.tar.bz2
ice-aba437bf7457b1953462154ea37e206a9e9d767b.tar.xz
ice-aba437bf7457b1953462154ea37e206a9e9d767b.zip
Python ICE_HOME fixes, incl. bug 2750
Diffstat (limited to 'py/python/Ice.py')
-rw-r--r--py/python/Ice.py64
1 files changed, 63 insertions, 1 deletions
diff --git a/py/python/Ice.py b/py/python/Ice.py
index 0eb4111ed7c..9826b82f7eb 100644
--- a/py/python/Ice.py
+++ b/py/python/Ice.py
@@ -99,7 +99,69 @@ class UserException(Exception):
pass
#
-# Utilities.
+# Convenience function for locating the directory containing the Slice files.
+#
+def getSliceDir():
+ #
+ # Check for <ICE_HOME>/slice first.
+ #
+ if os.environ.has_key("ICE_HOME"):
+ dir = os.path.join(os.environ["ICE_HOME"], "slice")
+ if os.path.exists(dir):
+ return dir
+
+ #
+ # Get the parent of the directory containing this file (Ice.py).
+ #
+ pyHome = os.path.join(os.path.dirname(__file__), "..")
+
+ #
+ # For an installation from a source distribution, a binary tarball, or a
+ # Windows installer, the "slice" directory is a sibling of the "python"
+ # directory.
+ #
+ dir = os.path.join(pyHome, "slice")
+ if os.path.exists(dir):
+ return os.path.normpath(dir)
+
+ #
+ # In a source distribution, the "slice" directory is one level higher.
+ #
+ dir = os.path.join(pyHome, "..", "slice")
+ if os.path.exists(dir):
+ return os.path.normpath(dir)
+
+ iceVer = version()
+
+ #
+ # Check platform-specific locations.
+ #
+ if sys.platform[:6] == "cygwin" or sys.platform == "win32":
+ dir = os.path.join("\\", "Ice-" + iceVer, "slice")
+ if os.path.exists(dir):
+ return dir
+ dir = os.path.join("C:\\", "Ice-" + iceVer, "slice")
+ if os.path.exists(dir):
+ return dir
+ else:
+ if sys.platform[:5] == "linux":
+ #
+ # Check the default RPM location.
+ #
+ dir = os.path.join("usr", "share", "Ice-" + iceVer, "slice")
+ if os.path.exists(dir):
+ return dir
+ #
+ # Check in /opt.
+ #
+ dir = os.path.join("opt", "Ice-" + iceVer, "slice")
+ if os.path.exists(dir):
+ return dir
+
+ return None
+
+#
+# Utilities for use by generated code.
#
def openModule(name):
if sys.modules.has_key(name):