diff -r 5392be94ea65 Lib/packaging/install.py --- a/Lib/packaging/install.py Tue Jun 07 17:58:50 2011 +0200 +++ b/Lib/packaging/install.py Wed Jun 08 00:26:14 2011 +0200 @@ -13,7 +13,7 @@ import shutil import logging import tempfile -from sysconfig import get_config_var, get_path +from sysconfig import get_config_var, get_path, is_python_build from packaging import logger from packaging.dist import Distribution @@ -488,6 +488,13 @@ Returns True on success, False on failure """ + if is_python_build(): + message = """You are running this from an uninstalled Python. +This likely implies that you are trying to install a 3rd-party package +without a working Python installation. That is unsupported.""" + logger.error(message) + return False + logger.info('Checking the installation location...') purelib_path = get_path('purelib') # trying to write a file there diff -r 5392be94ea65 Lib/packaging/tests/test_install.py --- a/Lib/packaging/tests/test_install.py Tue Jun 07 17:58:50 2011 +0200 +++ b/Lib/packaging/tests/test_install.py Wed Jun 08 00:26:14 2011 +0200 @@ -1,5 +1,7 @@ """Tests for the packaging.install module.""" import os +import logging +from sysconfig import is_python_build from tempfile import mkstemp from packaging import install @@ -356,6 +358,8 @@ finally: install._install_dist = old_install_dist + @unittest.skipIf(is_python_build(), + 'test not relevant for an uninstalled Python') def test_install_permission_denied(self): # if we don't have the access to the installation # path, we should abort immediatly @@ -371,6 +375,13 @@ os.chmod(install_path, old_mod) install.get_path = old_get_path + @unittest.skipUnless(is_python_build(), + 'test only relevant for an uninstalled Python') + def test_install_from_build(self): + project = os.path.join(os.path.dirname(__file__), 'package.tgz') + self.assertFalse(install.install(project)) + self.assertEqual(1, len(self.get_logs(logging.ERROR))) + def test_suite(): suite = unittest.TestSuite()