mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Make use of our own rmtree to work around an issue on Windows with readonly files.
This commit is contained in:
parent
f903eb0dd0
commit
afc2464772
5 changed files with 16 additions and 12 deletions
|
@ -24,8 +24,8 @@ __all__ = ['rmtree', 'display_path', 'backup_dir',
|
|||
'cache_download', 'unpack_file']
|
||||
|
||||
|
||||
def rmtree(dir):
|
||||
shutil.rmtree(dir, ignore_errors=True,
|
||||
def rmtree(dir, ignore_errors=True):
|
||||
shutil.rmtree(dir, ignore_errors=ignore_errors,
|
||||
onerror=rmtree_errorhandler)
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ else:
|
|||
|
||||
_base = os.path.supports_unicode_filenames and unicode or str
|
||||
|
||||
from pip.util import rmtree
|
||||
|
||||
class Path(_base):
|
||||
""" Models a path in an object oriented way. """
|
||||
|
@ -180,7 +181,7 @@ class Path(_base):
|
|||
|
||||
def rmtree(self, noerrors=True):
|
||||
""" Removes a directory tree. Ignores errors by default. """
|
||||
return shutil.rmtree(self, ignore_errors=noerrors)
|
||||
return rmtree(self, ignore_errors=noerrors)
|
||||
|
||||
def copy(self, to):
|
||||
shutil.copy(self, to)
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
from pip.backwardcompat import urllib
|
||||
from os.path import dirname, abspath
|
||||
|
||||
from pip.backwardcompat import urllib
|
||||
from pip.util import rmtree
|
||||
|
||||
|
||||
src_folder = dirname(dirname(abspath(__file__)))
|
||||
|
||||
|
@ -76,12 +78,12 @@ def _test_packages(output, pending_fn):
|
|||
print('Installation of %s succeeded' % package)
|
||||
add_package(os.path.join(output, 'success.txt'), package)
|
||||
pop_last_item(pending_fn, package)
|
||||
shutil.rmtree(dest_dir)
|
||||
rmtree(dest_dir)
|
||||
|
||||
|
||||
def create_venv(dest_dir):
|
||||
if os.path.exists(dest_dir):
|
||||
shutil.rmtree(dest_dir)
|
||||
rmtree(dest_dir)
|
||||
print('Creating virtualenv in %s' % dest_dir)
|
||||
code = subprocess.check_call(['virtualenv', '--no-site-packages', dest_dir])
|
||||
assert not code, "virtualenv failed"
|
||||
|
|
|
@ -8,6 +8,7 @@ import atexit
|
|||
import textwrap
|
||||
from scripttest import TestFileEnvironment
|
||||
from tests.path import Path, curdir, u
|
||||
from pip.util import rmtree
|
||||
|
||||
pyversion = sys.version[:3]
|
||||
|
||||
|
@ -96,7 +97,7 @@ def install_setuptools(env):
|
|||
shutil.copy2(f, tempdir)
|
||||
return env.run(os.path.join(tempdir, 'easy_install'), version)
|
||||
finally:
|
||||
shutil.rmtree(tempdir)
|
||||
rmtree(tempdir)
|
||||
|
||||
|
||||
env = None
|
||||
|
@ -129,7 +130,7 @@ class TestFailure(AssertionError):
|
|||
def _cleanup():
|
||||
global env
|
||||
del env
|
||||
shutil.rmtree(download_cache, ignore_errors=True)
|
||||
rmtree(download_cache, ignore_errors=True)
|
||||
|
||||
atexit.register(_cleanup)
|
||||
|
||||
|
@ -354,7 +355,7 @@ class TestPipEnvironment(TestFileEnvironment):
|
|||
return TestPipResult(super(TestPipEnvironment, self).run(cwd=cwd, *args, **kw), verbose=self.verbose)
|
||||
|
||||
def __del__(self):
|
||||
shutil.rmtree(str(self.root_path), ignore_errors=True)
|
||||
rmtree(str(self.root_path), ignore_errors=True)
|
||||
|
||||
def _use_cached_pypi_server(self):
|
||||
site_packages = self.root_path / self.site_packages
|
||||
|
@ -411,7 +412,7 @@ class FastTestPipEnvironment(TestPipEnvironment):
|
|||
self.environ['PATH'] = Path.pathsep.join((self.bin_path, self.environ['PATH']))
|
||||
|
||||
if self.root_path.exists:
|
||||
shutil.rmtree(self.root_path)
|
||||
rmtree(self.root_path)
|
||||
if self.backup_path.exists:
|
||||
shutil.copytree(self.backup_path, self.root_path, True)
|
||||
else:
|
||||
|
|
|
@ -99,7 +99,7 @@ def test_uninstall_editable_with_source_outside_venv():
|
|||
tmpdir = join(temp, 'virtualenv')
|
||||
_test_uninstall_editable_with_source_outside_venv(tmpdir)
|
||||
finally:
|
||||
shutil.rmtree(temp)
|
||||
rmtree(temp)
|
||||
|
||||
|
||||
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
|
||||
|
|
Loading…
Reference in a new issue