]> granicus.if.org Git - python/commitdiff
Catch failure to open installed Makefile, and report it as a
authorGreg Ward <gward@python.net>
Tue, 23 May 2000 23:14:00 +0000 (23:14 +0000)
committerGreg Ward <gward@python.net>
Tue, 23 May 2000 23:14:00 +0000 (23:14 +0000)
DistutilsPlatformError: "invalid Python installation".  (This will
happen on Red Hat-ish systems where the python-devel package is not
installed.)

Lib/distutils/sysconfig.py

index 5cc71dc0ba918caabed48d63f3d7a55eb16b1363..a5f3816a163f5b118f8f0c69fc8240ce6824a35b 100644 (file)
@@ -229,7 +229,17 @@ def _init_posix():
     """Initialize the module as appropriate for POSIX systems."""
     g = globals()
     # load the installed Makefile:
-    parse_makefile(open(get_makefile_filename()), g)
+    try:
+        filename = get_makefile_filename()
+        file = open(filename)
+    except IOError, msg:
+        my_msg = "invalid Python installation: unable to open %s" % filename
+        if hasattr(msg, "strerror"):
+            my_msg = my_msg + " (%s)" % msg.strerror
+
+        raise DistutilsPlatformError, my_msg
+              
+    parse_makefile(file, g)
 
 
 def _init_nt():