summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>1999-12-12 17:07:22 (GMT)
committerGreg Ward <gward@python.net>1999-12-12 17:07:22 (GMT)
commit1d0495e05c3c1155e5a1830bdeddf4ad9d4afc87 (patch)
treed2a0d93c08dad8fff0eb8cb903078469fe42b1d3 /Lib
parent9b45443c1bdf99b0f27b12baf06fea475b60e145 (diff)
downloadcpython-1d0495e05c3c1155e5a1830bdeddf4ad9d4afc87.zip
cpython-1d0495e05c3c1155e5a1830bdeddf4ad9d4afc87.tar.gz
cpython-1d0495e05c3c1155e5a1830bdeddf4ad9d4afc87.tar.bz2
Catch missing MANIFEST file and warn rather than blowing up.
Added 'nuke_release_tree()' method to blow away the directory from which the archive file(s) are created, and call it (conditionally) from 'make_distribution()'. Added 'keep_tree' option (false by default) to disable the call to 'nuke_release_tree()'.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/dist.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/Lib/distutils/command/dist.py b/Lib/distutils/command/dist.py
index abbd625..cdd4dfc 100644
--- a/Lib/distutils/command/dist.py
+++ b/Lib/distutils/command/dist.py
@@ -10,6 +10,7 @@ import sys, os, string, re
import fnmatch
from types import *
from glob import glob
+from shutil import rmtree
from distutils.core import Command
from distutils.text_file import TextFile
@@ -135,6 +136,9 @@ class Dist (Command):
"name of manifest file"),
('list-only', 'l',
"just list files that would be distributed"),
+ ('keep-tree', 'k',
+ "keep the distribution tree around after creating " +
+ "archive file(s)"),
]
default_format = { 'posix': 'gztar',
@@ -147,6 +151,7 @@ class Dist (Command):
self.formats = None
self.manifest = None
self.list_only = 0
+ self.keep_tree = 0
def set_final_options (self):
@@ -202,8 +207,8 @@ class Dist (Command):
self.warn ("missing meta-data: if 'maintainer' supplied, " +
"'maintainer_email' must be supplied too")
else:
- self.warn ("missing meta-data: either author (and author_email) " +
- "or maintainer (and maintainer_email) " +
+ self.warn ("missing meta-data: either (author and author_email) " +
+ "or (maintainer and maintainer_email) " +
"must be supplied")
# check_metadata ()
@@ -296,7 +301,18 @@ class Dist (Command):
# README, setup script, ...)
assert self.files is not None
- manifest = self.open_manifest (self.manifest)
+ try:
+ manifest = self.open_manifest (self.manifest)
+ except IOError, exc:
+ if type (exc) is InstanceType and hasattr (exc, 'strerror'):
+ msg = "could not open MANIFEST (%s)" % \
+ string.lower (exc.strerror)
+ else:
+ msg = "could not open MANIFST"
+
+ self.warn (msg + ": using default file list")
+ return
+
while 1:
pattern = manifest.readline()
@@ -385,6 +401,11 @@ class Dist (Command):
# make_release_tree ()
+ def nuke_release_tree (self, base_dir):
+ self.execute (rmtree, (base_dir,),
+ "removing %s" % base_dir)
+
+
def make_tarball (self, base_dir, compress="gzip"):
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
@@ -441,6 +462,9 @@ class Dist (Command):
elif fmt == 'zip':
self.make_zipfile (base_dir)
+ if not self.keep_tree:
+ self.nuke_release_tree (base_dir)
+
# class Dist