summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/install.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-06-10 16:31:40 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-06-10 16:31:40 (GMT)
commitfa6cfbc4f73100714bca79280d51836f2bac4bdc (patch)
tree3fa5ca9211b9d64ac1c1c6943923183859461538 /Lib/packaging/install.py
parent2b612220e4ddaea89058065f98735590b710550d (diff)
downloadcpython-fa6cfbc4f73100714bca79280d51836f2bac4bdc.zip
cpython-fa6cfbc4f73100714bca79280d51836f2bac4bdc.tar.gz
cpython-fa6cfbc4f73100714bca79280d51836f2bac4bdc.tar.bz2
Don’t try to install something when running from uninstalled source (#12246).
Original patch by Tshepang Lekhonkhobe.
Diffstat (limited to 'Lib/packaging/install.py')
-rw-r--r--Lib/packaging/install.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/packaging/install.py b/Lib/packaging/install.py
index 2317645..c5bda45 100644
--- a/Lib/packaging/install.py
+++ b/Lib/packaging/install.py
@@ -13,7 +13,7 @@ import errno
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,20 +488,31 @@ def install(project):
Returns True on success, False on failure
"""
+ if is_python_build():
+ # Python would try to install into the site-packages directory under
+ # $PREFIX, but when running from an uninstalled code checkout we don't
+ # want to create directories under the installation root
+ message = ('installing third-party projects from an uninstalled '
+ 'Python is not supported')
+ logger.error(message)
+ return False
+
logger.info('Checking the installation location...')
purelib_path = get_path('purelib')
+
# trying to write a file there
try:
with tempfile.NamedTemporaryFile(suffix=project,
dir=purelib_path) as testfile:
testfile.write(b'test')
except OSError:
- # was unable to write a file
+ # FIXME this should check the errno, or be removed altogether (race
+ # condition: the directory permissions could be changed between here
+ # and the actual install)
logger.info('Unable to write in "%s". Do you have the permissions ?'
% purelib_path)
return False
-
logger.info('Getting information about %r...', project)
try:
info = get_infos(project)