]> granicus.if.org Git - python/commitdiff
A hack to augment sys.path with the build/lib.<platform> directory
authorGuido van Rossum <guido@python.org>
Fri, 19 Jan 2001 21:54:59 +0000 (21:54 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 19 Jan 2001 21:54:59 +0000 (21:54 +0000)
created by Andrew's setup.py script, *if* we're actually running from
the build directory.  (The test for that: whether the sys.path[-1]
ends in "/Modules".)

This has one disadvantage: it imports a fair amount of code from the
distutils package, just in order to be able to calculate the correct
pathname.  See if I care. :-)

Lib/site.py

index 3f4e8304c00317417295ba7d0d9b920ec906273d..12fe71d4599de5d8e91ca495caa3661d641235e2 100644 (file)
@@ -79,6 +79,15 @@ for dir in sys.path:
 sys.path[:] = L
 del dir, L
 
+# Append ./build/lib.<platform> in case we're running in the build dir
+# (especially for Guido :-)
+if os.name == "posix" and os.path.basename(sys.path[-1]) == "Modules":
+    from distutils.util import get_platform
+    s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
+    s = os.path.join(os.path.dirname(sys.path[-1]), s)
+    sys.path.append(s)
+    del get_platform, s
+
 def addsitedir(sitedir):
     sitedir = makepath(sitedir)
     if sitedir not in sys.path: