mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Fixed #8688: Distutils now recalculates MANIFEST everytime.
This commit is contained in:
parent
1b553473ed
commit
422545f0e7
3 changed files with 66 additions and 55 deletions
|
@ -179,66 +179,34 @@ class sdist(Command):
|
||||||
distribution, and put it in 'self.filelist'. This might involve
|
distribution, and put it in 'self.filelist'. This might involve
|
||||||
reading the manifest template (and writing the manifest), or just
|
reading the manifest template (and writing the manifest), or just
|
||||||
reading the manifest, or just using the default file set -- it all
|
reading the manifest, or just using the default file set -- it all
|
||||||
depends on the user's options and the state of the filesystem.
|
depends on the user's options.
|
||||||
"""
|
"""
|
||||||
# If we have a manifest template, see if it's newer than the
|
# new behavior:
|
||||||
# manifest; if so, we'll regenerate the manifest.
|
# the file list is recalculated everytime because
|
||||||
|
# even if MANIFEST.in or setup.py are not changed
|
||||||
|
# the user might have added some files in the tree that
|
||||||
|
# need to be included.
|
||||||
|
#
|
||||||
|
# This makes --force the default and only behavior.
|
||||||
template_exists = os.path.isfile(self.template)
|
template_exists = os.path.isfile(self.template)
|
||||||
|
if not template_exists:
|
||||||
|
self.warn(("manifest template '%s' does not exist " +
|
||||||
|
"(using default file list)") %
|
||||||
|
self.template)
|
||||||
|
self.filelist.findall()
|
||||||
|
|
||||||
|
if self.use_defaults:
|
||||||
|
self.add_defaults()
|
||||||
|
|
||||||
if template_exists:
|
if template_exists:
|
||||||
template_newer = dep_util.newer(self.template, self.manifest)
|
self.read_template()
|
||||||
|
|
||||||
# The contents of the manifest file almost certainly depend on the
|
if self.prune:
|
||||||
# setup script as well as the manifest template -- so if the setup
|
self.prune_file_list()
|
||||||
# script is newer than the manifest, we'll regenerate the manifest
|
|
||||||
# from the template. (Well, not quite: if we already have a
|
|
||||||
# manifest, but there's no template -- which will happen if the
|
|
||||||
# developer elects to generate a manifest some other way -- then we
|
|
||||||
# can't regenerate the manifest, so we don't.)
|
|
||||||
self.debug_print("checking if %s newer than %s" %
|
|
||||||
(self.distribution.script_name, self.manifest))
|
|
||||||
setup_newer = dep_util.newer(self.distribution.script_name,
|
|
||||||
self.manifest)
|
|
||||||
|
|
||||||
# cases:
|
self.filelist.sort()
|
||||||
# 1) no manifest, template exists: generate manifest
|
self.filelist.remove_duplicates()
|
||||||
# (covered by 2a: no manifest == template newer)
|
self.write_manifest()
|
||||||
# 2) manifest & template exist:
|
|
||||||
# 2a) template or setup script newer than manifest:
|
|
||||||
# regenerate manifest
|
|
||||||
# 2b) manifest newer than both:
|
|
||||||
# do nothing (unless --force or --manifest-only)
|
|
||||||
# 3) manifest exists, no template:
|
|
||||||
# do nothing (unless --force or --manifest-only)
|
|
||||||
# 4) no manifest, no template: generate w/ warning ("defaults only")
|
|
||||||
|
|
||||||
manifest_outofdate = (template_exists and
|
|
||||||
(template_newer or setup_newer))
|
|
||||||
force_regen = self.force_manifest or self.manifest_only
|
|
||||||
manifest_exists = os.path.isfile(self.manifest)
|
|
||||||
neither_exists = (not template_exists and not manifest_exists)
|
|
||||||
|
|
||||||
# Regenerate the manifest if necessary (or if explicitly told to)
|
|
||||||
if manifest_outofdate or neither_exists or force_regen:
|
|
||||||
if not template_exists:
|
|
||||||
self.warn(("manifest template '%s' does not exist " +
|
|
||||||
"(using default file list)") %
|
|
||||||
self.template)
|
|
||||||
self.filelist.findall()
|
|
||||||
|
|
||||||
if self.use_defaults:
|
|
||||||
self.add_defaults()
|
|
||||||
if template_exists:
|
|
||||||
self.read_template()
|
|
||||||
if self.prune:
|
|
||||||
self.prune_file_list()
|
|
||||||
|
|
||||||
self.filelist.sort()
|
|
||||||
self.filelist.remove_duplicates()
|
|
||||||
self.write_manifest()
|
|
||||||
|
|
||||||
# Don't regenerate the manifest, just read it in.
|
|
||||||
else:
|
|
||||||
self.read_manifest()
|
|
||||||
|
|
||||||
def add_defaults(self):
|
def add_defaults(self):
|
||||||
"""Add all the default files to self.filelist:
|
"""Add all the default files to self.filelist:
|
||||||
|
|
|
@ -346,6 +346,47 @@ class SDistTestCase(PyPIRCCommandTestCase):
|
||||||
finally:
|
finally:
|
||||||
archive.close()
|
archive.close()
|
||||||
|
|
||||||
|
def test_get_file_list(self):
|
||||||
|
# make sure MANIFEST is recalculated
|
||||||
|
dist, cmd = self.get_cmd()
|
||||||
|
|
||||||
|
# filling data_files by pointing files in package_data
|
||||||
|
dist.package_data = {'somecode': ['*.txt']}
|
||||||
|
self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
|
||||||
|
cmd.ensure_finalized()
|
||||||
|
cmd.run()
|
||||||
|
|
||||||
|
f = open(cmd.manifest)
|
||||||
|
try:
|
||||||
|
manifest = [line.strip() for line in f.read().split('\n')
|
||||||
|
if line.strip() != '']
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
self.assertEquals(len(manifest), 4)
|
||||||
|
|
||||||
|
# adding a file
|
||||||
|
self.write_file((self.tmp_dir, 'somecode', 'doc2.txt'), '#')
|
||||||
|
|
||||||
|
# make sure build_py is reinitinialized, like a fresh run
|
||||||
|
build_py = dist.get_command_obj('build_py')
|
||||||
|
build_py.finalized = False
|
||||||
|
build_py.ensure_finalized()
|
||||||
|
|
||||||
|
cmd.run()
|
||||||
|
|
||||||
|
f = open(cmd.manifest)
|
||||||
|
try:
|
||||||
|
manifest2 = [line.strip() for line in f.read().split('\n')
|
||||||
|
if line.strip() != '']
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
# do we have the new file in MANIFEST ?
|
||||||
|
self.assertEquals(len(manifest2), 5)
|
||||||
|
self.assertIn('doc2.txt', manifest2[-1])
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.makeSuite(SDistTestCase)
|
return unittest.makeSuite(SDistTestCase)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #8688: Distutils now recalculates MANIFEST everytime.
|
||||||
|
|
||||||
- Issue #5099: subprocess.Popen's __del__ method (and the methods it calls)
|
- Issue #5099: subprocess.Popen's __del__ method (and the methods it calls)
|
||||||
referenced global objects, causing errors to pop up during interpreter
|
referenced global objects, causing errors to pop up during interpreter
|
||||||
shutdown.
|
shutdown.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue