[Zope-Checkins] SVN: Zope/trunk/test.py Merged 2.9 branch r71304:71305 into the trunk.

Stefan H. Holek stefan at epy.co.at
Sat Nov 25 07:43:52 EST 2006


Log message for revision 71307:
  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.
  

Changed:
  U   Zope/trunk/test.py

-=-
Modified: Zope/trunk/test.py
===================================================================
--- Zope/trunk/test.py	2006-11-25 12:42:35 UTC (rev 71306)
+++ Zope/trunk/test.py	2006-11-25 12:43:51 UTC (rev 71307)
@@ -21,22 +21,22 @@
 
 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 @@
     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)



More information about the Zope-Checkins mailing list