mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
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()'.
This commit is contained in:
parent
9b45443c1b
commit
1d0495e05c
1 changed files with 27 additions and 3 deletions
|
@ -10,6 +10,7 @@ import sys, os, string, re
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from types import *
|
from types import *
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
from shutil import rmtree
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.text_file import TextFile
|
from distutils.text_file import TextFile
|
||||||
|
|
||||||
|
@ -135,6 +136,9 @@ class Dist (Command):
|
||||||
"name of manifest file"),
|
"name of manifest file"),
|
||||||
('list-only', 'l',
|
('list-only', 'l',
|
||||||
"just list files that would be distributed"),
|
"just list files that would be distributed"),
|
||||||
|
('keep-tree', 'k',
|
||||||
|
"keep the distribution tree around after creating " +
|
||||||
|
"archive file(s)"),
|
||||||
]
|
]
|
||||||
|
|
||||||
default_format = { 'posix': 'gztar',
|
default_format = { 'posix': 'gztar',
|
||||||
|
@ -147,6 +151,7 @@ class Dist (Command):
|
||||||
self.formats = None
|
self.formats = None
|
||||||
self.manifest = None
|
self.manifest = None
|
||||||
self.list_only = 0
|
self.list_only = 0
|
||||||
|
self.keep_tree = 0
|
||||||
|
|
||||||
|
|
||||||
def set_final_options (self):
|
def set_final_options (self):
|
||||||
|
@ -202,8 +207,8 @@ class Dist (Command):
|
||||||
self.warn ("missing meta-data: if 'maintainer' supplied, " +
|
self.warn ("missing meta-data: if 'maintainer' supplied, " +
|
||||||
"'maintainer_email' must be supplied too")
|
"'maintainer_email' must be supplied too")
|
||||||
else:
|
else:
|
||||||
self.warn ("missing meta-data: either author (and author_email) " +
|
self.warn ("missing meta-data: either (author and author_email) " +
|
||||||
"or maintainer (and maintainer_email) " +
|
"or (maintainer and maintainer_email) " +
|
||||||
"must be supplied")
|
"must be supplied")
|
||||||
|
|
||||||
# check_metadata ()
|
# check_metadata ()
|
||||||
|
@ -296,7 +301,18 @@ class Dist (Command):
|
||||||
# README, setup script, ...)
|
# README, setup script, ...)
|
||||||
assert self.files is not None
|
assert self.files is not None
|
||||||
|
|
||||||
|
try:
|
||||||
manifest = self.open_manifest (self.manifest)
|
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:
|
while 1:
|
||||||
|
|
||||||
pattern = manifest.readline()
|
pattern = manifest.readline()
|
||||||
|
@ -385,6 +401,11 @@ class Dist (Command):
|
||||||
# make_release_tree ()
|
# 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"):
|
def make_tarball (self, base_dir, compress="gzip"):
|
||||||
|
|
||||||
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
|
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
|
||||||
|
@ -441,6 +462,9 @@ class Dist (Command):
|
||||||
elif fmt == 'zip':
|
elif fmt == 'zip':
|
||||||
self.make_zipfile (base_dir)
|
self.make_zipfile (base_dir)
|
||||||
|
|
||||||
|
if not self.keep_tree:
|
||||||
|
self.nuke_release_tree (base_dir)
|
||||||
|
|
||||||
# class Dist
|
# class Dist
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue