From 2c92ab97904efdd73d72040bffabd9dcdebdfa18 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" <stefan@epy.co.at> Date: Sat, 25 Nov 2006 12:43:51 +0000 Subject: [PATCH] Merged 2.9 branch r71304:71305 into the trunk. - test.py lives in ZOPE_HOME for checkouts and ZOPE_HOME/bin for installations. - Comparing abspaths does not fly when symlinks are involved; use realpaths instead. --- test.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test.py b/test.py index 5976cbf06..8237c8e1b 100644 --- a/test.py +++ b/test.py @@ -21,22 +21,22 @@ $Id: test.py 33303 2005-07-13 22:28:33Z jim $ import os.path, sys -# Remove this directory from path: -here = os.path.abspath(os.path.dirname(sys.argv[0])) -sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here] +# Remove script directory from path: +scriptdir = os.path.realpath(os.path.dirname(sys.argv[0])) +sys.path[:] = [p for p in sys.path if os.path.realpath(p) != scriptdir] shome = os.environ.get('SOFTWARE_HOME') zhome = os.environ.get('ZOPE_HOME') ihome = os.environ.get('INSTANCE_HOME') if zhome: - zhome = os.path.abspath(zhome) + zhome = os.path.realpath(zhome) if shome: - shome = os.path.abspath(shome) + shome = os.path.realpath(shome) else: shome = os.path.join(zhome, 'lib', 'python') elif shome: - shome = os.path.abspath(shome) + shome = os.path.realpath(shome) zhome = os.path.dirname(os.path.dirname(shome)) elif ihome: print >> sys.stderr, ''' @@ -44,8 +44,13 @@ elif ihome: must be set ''' else: - # No zope home, assume that it is the script directory - zhome = os.path.abspath(os.path.dirname(sys.argv[0])) + # No zope home, derive it from script directory: + # (test.py lives in either ZOPE_HOME or ZOPE_HOME/bin) + parentdir, lastpart = os.path.split(scriptdir) + if lastpart == 'bin': + zhome = parentdir + else: + zhome = scriptdir shome = os.path.join(zhome, 'lib', 'python') sys.path.insert(0, shome) -- 2.30.9