summaryrefslogtreecommitdiff
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
parent7b782219d5322ee66cef293c5c5b49fbd4133a0d (diff)
downloadwheel-git-directoryfix.tar.gz
Only add directory entries for empty directoriesdirectoryfix
-rw-r--r--tests/test_bdist_wheel.py1
-rw-r--r--tests/test_wheelfile.py1
-rw-r--r--wheel/wheelfile.py12
3 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py
index 3df16db..959dfa0 100644
--- a/tests/test_bdist_wheel.py
+++ b/tests/test_bdist_wheel.py
@@ -8,7 +8,6 @@ import pytest
from wheel.wheelfile import WheelFile
DEFAULT_FILES = {
- 'dummy_dist-1.0.dist-info/',
'dummy_dist-1.0.dist-info/top_level.txt',
'dummy_dist-1.0.dist-info/METADATA',
'dummy_dist-1.0.dist-info/WHEEL',
diff --git a/tests/test_wheelfile.py b/tests/test_wheelfile.py
index 9fe3ce2..a6f09d9 100644
--- a/tests/test_wheelfile.py
+++ b/tests/test_wheelfile.py
@@ -194,5 +194,4 @@ def test_directories(tmpdir, wheel_path):
infos = zf.infolist()
names = set(map(operator.attrgetter('filename'), infos))
- assert 'sub/' in names
assert 'empty/' in names
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):