summaryrefslogtreecommitdiff
path: root/wheel
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2019-05-11 16:46:44 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2019-05-11 16:46:44 +0300
commit357e31d916299959b954c25c1275469f7e5e7299 (patch)
treed25d8a56ace83a41b18a160b0ef9a58ad24d2353 /wheel
parent7b782219d5322ee66cef293c5c5b49fbd4133a0d (diff)
downloadwheel-git-directoryfix.tar.gz
Only add directory entries for empty directoriesdirectoryfix
Diffstat (limited to 'wheel')
-rw-r--r--wheel/wheelfile.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/wheel/wheelfile.py b/wheel/wheelfile.py
index 486e17e..37754b4 100644
--- a/wheel/wheelfile.py
+++ b/wheel/wheelfile.py
@@ -109,15 +109,17 @@ class WheelFile(ZipFile):
logger.info("creating '%s' and adding '%s' to it", self.filename, base_dir)
deferred = []
for root, dirnames, filenames in os.walk(base_dir):
+ if not dirnames and not filenames:
+ # For an empty directory, just add the directory entry
+ path = os.path.normpath(root)
+ arcname = os.path.relpath(path, base_dir)
+ self.mkdir(path, arcname)
+ continue
+
# Sort the directory names so that `os.walk` will walk them in a
# defined order on the next iteration.
dirnames.sort()
- for name in dirnames:
- path = os.path.normpath(os.path.join(root, name))
- arcname = os.path.relpath(path, base_dir)
- self.mkdir(path, arcname)
-
for name in sorted(filenames):
path = os.path.normpath(os.path.join(root, name))
if os.path.isfile(path):