From 9024011400615187e03e4ed14d713a629909d1b0 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 21 May 2020 17:18:21 +0800 Subject: [PATCH] Fix for source directory reuse --- src/pip/_internal/req/req_install.py | 11 ++++++----- tests/functional/test_new_resolver.py | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 3b28209b1bd..7bd7a05521c 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -7,6 +7,7 @@ import os import shutil import sys +import uuid import zipfile from pip._vendor import pkg_resources, six @@ -354,16 +355,16 @@ def ensure_build_location(self, build_dir, autodelete): ) return self._temp_build_dir.path - if self.editable: - name = self.name.lower() - else: - name = self.name + dir_name = "{}_{}".format( + canonicalize_name(self.name), + uuid.uuid4().hex, + ) # FIXME: Is there a better place to create the build_dir? (hg and bzr # need this) if not os.path.exists(build_dir): logger.debug('Creating directory %s', build_dir) os.makedirs(build_dir) - actual_build_dir = os.path.join(build_dir, name) + actual_build_dir = os.path.join(build_dir, dir_name) # `None` indicates that we respect the globally-configured deletion # settings, which is what we actually want when auto-deleting. delete_arg = None if autodelete else False diff --git a/tests/functional/test_new_resolver.py b/tests/functional/test_new_resolver.py index 686c5f6953e..406b6460cac 100644 --- a/tests/functional/test_new_resolver.py +++ b/tests/functional/test_new_resolver.py @@ -809,7 +809,6 @@ def test_new_resolver_extra_merge_in_package( assert_installed(script, pkg="1.0.0", dep="1.0.0", depdev="1.0.0") -@pytest.mark.xfail(reason="pre-existing build directory") def test_new_resolver_build_directory_error_zazo_19(script): """https://github.com/pradyunsg/zazo/issues/19#issuecomment-631615674