summaryrefslogtreecommitdiff
path: root/pip/wheel.py
diff options
context:
space:
mode:
Diffstat (limited to 'pip/wheel.py')
-rw-r--r--pip/wheel.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/pip/wheel.py b/pip/wheel.py
index 839259df4..4e9803f23 100644
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -134,10 +134,11 @@ def get_entrypoints(filename):
def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
- pycompile=True):
+ pycompile=True, scheme=None):
"""Install a wheel"""
- scheme = distutils_scheme(name, user=user, home=home, root=root)
+ if not scheme:
+ scheme = distutils_scheme(name, user=user, home=home, root=root)
if root_is_purelib(name, wheeldir):
lib_dir = scheme['purelib']
@@ -177,6 +178,7 @@ def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
for dir, subdirs, files in os.walk(source):
basedir = dir[len(source):].lstrip(os.path.sep)
+ destdir = os.path.join(dest, basedir)
if is_base and basedir.split(os.path.sep, 1)[0].endswith('.data'):
continue
for s in subdirs:
@@ -190,15 +192,21 @@ def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
and s.lower().startswith(req.project_name.replace('-', '_').lower())):
assert not info_dir, 'Multiple .dist-info directories'
info_dir.append(destsubdir)
- if not os.path.exists(destsubdir):
- os.makedirs(destsubdir)
for f in files:
# Skip unwanted files
if filter and filter(f):
continue
srcfile = os.path.join(dir, f)
destfile = os.path.join(dest, basedir, f)
- shutil.move(srcfile, destfile)
+ # directory creation is lazy and after the file filtering above
+ # to ensure we don't install empty dirs; empty dirs can't be
+ # uninstalled.
+ if not os.path.exists(destdir):
+ os.makedirs(destdir)
+ # use copy2 (not move) to be extra sure we're not moving
+ # directories over; copy2 fails for directories. this would
+ # fail tests (not during released/user execution)
+ shutil.copy2(srcfile, destfile)
changed = False
if fixer:
changed = fixer(destfile)