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

Skip to content

Commit b2db0eb

Browse files
committed
Fix inspired by Rene Liebscher: if setup script is newer than the
manifest, regenerate the manifest.
1 parent f6451c4 commit b2db0eb

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

Lib/distutils/command/sdist.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,37 @@ def get_file_list (self):
173173
reading the manifest, or just using the default file set -- it all
174174
depends on the user's options and the state of the filesystem.
175175
"""
176+
177+
# If we have a manifest template, see if it's newer than the
178+
# manifest; if so, we'll regenerate the manifest.
176179
template_exists = os.path.isfile (self.template)
177180
if template_exists:
178181
template_newer = newer (self.template, self.manifest)
179182

183+
# The contents of the manifest file almost certainly depend on the
184+
# setup script as well as the manifest template -- so if the setup
185+
# script is newer than the manifest, we'll regenerate the manifest
186+
# from the template. (Well, not quite: if we already have a
187+
# manifest, but there's no template -- which will happen if the
188+
# developer elects to generate a manifest some other way -- then we
189+
# can't regenerate the manifest, so we don't.)
190+
setup_newer = newer(sys.argv[0], self.manifest)
191+
192+
# cases:
193+
# 1) no manifest, template exists: generate manifest
194+
# (covered by 2a: no manifest == template newer)
195+
# 2) manifest & template exist:
196+
# 2a) template or setup script newer than manifest:
197+
# regenerate manifest
198+
# 2b) manifest newer than both:
199+
# do nothing (unless --force or --manifest-only)
200+
# 3) manifest exists, no template:
201+
# do nothing (unless --force or --manifest-only)
202+
# 4) no manifest, no template: generate w/ warning ("defaults only")
203+
180204
# Regenerate the manifest if necessary (or if explicitly told to)
181-
if ((template_exists and template_newer) or
182-
self.force_manifest or
183-
self.manifest_only):
205+
if ((template_exists and (template_newer or setup_newer)) or
206+
self.force_manifest or self.manifest_only):
184207

185208
if not template_exists:
186209
self.warn (("manifest template '%s' does not exist " +

0 commit comments

Comments
 (0)