aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/wheel.py
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2017-11-30 19:46:16 +0100
committerBenoit Pierre <benoit.pierre@gmail.com>2017-11-30 19:46:16 +0100
commit35c0e9c2d67cbda4033ba0e0b1c20e4df8c24ce7 (patch)
tree507b4dcac95ba5ee57bfce409e343d02efd653c4 /setuptools/wheel.py
parentb729553a6c6b92dfc7cfd9c577f2399bfde3000e (diff)
downloadexternal_python_setuptools-35c0e9c2d67cbda4033ba0e0b1c20e4df8c24ce7.tar.gz
external_python_setuptools-35c0e9c2d67cbda4033ba0e0b1c20e4df8c24ce7.tar.bz2
external_python_setuptools-35c0e9c2d67cbda4033ba0e0b1c20e4df8c24ce7.zip
fix `data_files` handling when installing from wheel
Diffstat (limited to 'setuptools/wheel.py')
-rw-r--r--setuptools/wheel.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/setuptools/wheel.py b/setuptools/wheel.py
index c2327213..9ffe434a 100644
--- a/setuptools/wheel.py
+++ b/setuptools/wheel.py
@@ -28,6 +28,28 @@ except ImportError:
'''
+def unpack(src_dir, dst_dir):
+ '''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
+ for dirpath, dirnames, filenames in os.walk(src_dir):
+ subdir = os.path.relpath(dirpath, src_dir)
+ for f in filenames:
+ src = os.path.join(dirpath, f)
+ dst = os.path.join(dst_dir, subdir, f)
+ os.renames(src, dst)
+ for n, d in reversed(list(enumerate(dirnames))):
+ src = os.path.join(dirpath, d)
+ dst = os.path.join(dst_dir, subdir, d)
+ if not os.path.exists(dst):
+ # Directory does not exist in destination,
+ # rename it and prune it from os.walk list.
+ os.renames(src, dst)
+ del dirnames[n]
+ # Cleanup.
+ for dirpath, dirnames, filenames in os.walk(src_dir, topdown=True):
+ assert not filenames
+ os.rmdir(dirpath)
+
+
class Wheel(object):
def __init__(self, filename):
@@ -125,10 +147,7 @@ class Wheel(object):
os.path.join(dist_data, d)
for d in ('data', 'headers', 'purelib', 'platlib')
)):
- for entry in os.listdir(subdir):
- os.rename(os.path.join(subdir, entry),
- os.path.join(destination_eggdir, entry))
- os.rmdir(subdir)
+ unpack(subdir, destination_eggdir)
if os.path.exists(dist_data):
os.rmdir(dist_data)
# Fix namespace packages.