Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fad268

Browse files
committed
Bullet-proofing of 'make_release_tree()':
- 'mkpath()' the distribution dir in case of empty manifest - warn if empty manifest - detect, warn about, and skip non-regular files in manifest
1 parent d3b76a8 commit 5fad268

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Lib/distutils/command/sdist.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,11 @@ def make_release_tree (self, base_dir, files):
405405
to be distributed.
406406
"""
407407
# Create all the directories under 'base_dir' necessary to
408-
# put 'files' there.
409-
dir_util.create_tree (base_dir, files,
410-
verbose=self.verbose, dry_run=self.dry_run)
408+
# put 'files' there; the 'mkpath()' is just so we don't die
409+
# if the manifest happens to be empty.
410+
self.mkpath(base_dir)
411+
dir_util.create_tree(base_dir, files,
412+
verbose=self.verbose, dry_run=self.dry_run)
411413

412414
# And walk over the list of files, either making a hard link (if
413415
# os.link exists) to each one that doesn't already exist in its
@@ -423,10 +425,16 @@ def make_release_tree (self, base_dir, files):
423425
link = None
424426
msg = "copying files to %s..." % base_dir
425427

426-
self.announce (msg)
428+
if not files:
429+
self.warn("no files to distribute -- empty manifest?")
430+
else:
431+
self.announce (msg)
427432
for file in files:
428-
dest = os.path.join (base_dir, file)
429-
self.copy_file (file, dest, link=link)
433+
if not os.path.isfile(file):
434+
self.warn("'%s' not a regular file -- skipping" % file)
435+
else:
436+
dest = os.path.join (base_dir, file)
437+
self.copy_file (file, dest, link=link)
430438

431439
# make_release_tree ()
432440

0 commit comments

Comments
 (0)