aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2017-01-07 13:37:37 -0500
committerJason R. Coombs <jaraco@jaraco.com>2017-01-07 13:37:37 -0500
commita0d35d47761a8bd7394cb9f2738169b07be3a005 (patch)
tree375334a5e61eb137b5411f92942b510f6024cea3 /setuptools/command/easy_install.py
parentbbf6ac250a05fd51aa2a44ed3196837491bc9d60 (diff)
parent3c182f9f1eea89040fbfc88d1ccbed31ece6a00b (diff)
downloadexternal_python_setuptools-issue-97.tar.gz
external_python_setuptools-issue-97.tar.bz2
external_python_setuptools-issue-97.zip
Merge branch 'master' into issue-97issue-97
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 03dd6768..36e7f359 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -46,6 +46,7 @@ from setuptools.extern.six.moves import configparser, map
from setuptools import Command
from setuptools.sandbox import run_setup
from setuptools.py31compat import get_path, get_config_vars
+from setuptools.py27compat import rmtree_safe
from setuptools.command import setopt
from setuptools.archive_util import unpack_archive
from setuptools.package_index import (
@@ -627,12 +628,20 @@ class easy_install(Command):
(spec.key, self.build_directory)
)
+ @contextlib.contextmanager
+ def _tmpdir(self):
+ tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-"))
+ try:
+ # cast to str as workaround for #709 and #710 and #712
+ yield str(tmpdir)
+ finally:
+ os.path.exists(tmpdir) and rmtree(rmtree_safe(tmpdir))
+
def easy_install(self, spec, deps=False):
- tmpdir = tempfile.mkdtemp(prefix="easy_install-")
if not self.editable:
self.install_site_py()
- try:
+ with self._tmpdir() as tmpdir:
if not isinstance(spec, Requirement):
if URL_SCHEME(spec):
# It's a url, download it to tmpdir and process
@@ -664,10 +673,6 @@ class easy_install(Command):
else:
return self.install_item(spec, dist.location, tmpdir, deps)
- finally:
- if os.path.exists(tmpdir):
- rmtree(tmpdir)
-
def install_item(self, spec, download, tmpdir, deps, install_needed=False):
# Installation is also needed if file in tmpdir or is not an egg