mirror of https://github.com/python/cpython
Fix sdist to always include setup.cfg (#11092), to comply with the spec
This commit is contained in:
parent
078368fe4d
commit
7373fccd50
|
@ -201,15 +201,20 @@ class sdist(Command):
|
||||||
self.filelist.write(self.manifest)
|
self.filelist.write(self.manifest)
|
||||||
|
|
||||||
def add_defaults(self):
|
def add_defaults(self):
|
||||||
"""Add all the default files to self.filelist:
|
"""Add all default files to self.filelist.
|
||||||
- all pure Python modules mentioned in setup script
|
|
||||||
- all files pointed by package_data (build_py)
|
In addition to the setup.cfg file, this will include all files returned
|
||||||
- all files defined in data_files.
|
by the get_source_files of every registered command. This will find
|
||||||
- all files defined as scripts.
|
Python modules and packages, data files listed in package_data_,
|
||||||
- all C sources listed as part of extensions or C libraries
|
data_files and extra_files, scripts, C sources of extension modules or
|
||||||
in the setup script (doesn't catch C headers!)
|
C libraries (headers are missing).
|
||||||
Everything is optional.
|
|
||||||
"""
|
"""
|
||||||
|
if os.path.exists('setup.cfg'):
|
||||||
|
self.filelist.append('setup.cfg')
|
||||||
|
else:
|
||||||
|
logger.warning("%s: standard 'setup.cfg' file not found",
|
||||||
|
self.get_command_name())
|
||||||
|
|
||||||
for cmd_name in get_command_names():
|
for cmd_name in get_command_names():
|
||||||
try:
|
try:
|
||||||
cmd_obj = self.get_finalized_command(cmd_name)
|
cmd_obj = self.get_finalized_command(cmd_name)
|
||||||
|
|
|
@ -34,6 +34,7 @@ setup(name='fake')
|
||||||
MANIFEST = """\
|
MANIFEST = """\
|
||||||
# file GENERATED by packaging, do NOT edit
|
# file GENERATED by packaging, do NOT edit
|
||||||
inroot.txt
|
inroot.txt
|
||||||
|
setup.cfg
|
||||||
data%(sep)sdata.dt
|
data%(sep)sdata.dt
|
||||||
scripts%(sep)sscript.py
|
scripts%(sep)sscript.py
|
||||||
some%(sep)sfile.txt
|
some%(sep)sfile.txt
|
||||||
|
@ -173,6 +174,7 @@ class SDistTestCase(support.TempdirManager,
|
||||||
# in package_data
|
# in package_data
|
||||||
dist.package_data = {'': ['*.cfg', '*.dat'],
|
dist.package_data = {'': ['*.cfg', '*.dat'],
|
||||||
'somecode': ['*.txt']}
|
'somecode': ['*.txt']}
|
||||||
|
self.write_file((self.tmp_dir, 'setup.cfg'), '#')
|
||||||
self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
|
self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
|
||||||
self.write_file((self.tmp_dir, 'somecode', 'doc.dat'), '#')
|
self.write_file((self.tmp_dir, 'somecode', 'doc.dat'), '#')
|
||||||
|
|
||||||
|
@ -212,8 +214,8 @@ class SDistTestCase(support.TempdirManager,
|
||||||
content = zip_file.namelist()
|
content = zip_file.namelist()
|
||||||
|
|
||||||
# Making sure everything was added. This includes 8 code and data
|
# Making sure everything was added. This includes 8 code and data
|
||||||
# files in addition to PKG-INFO.
|
# files in addition to PKG-INFO and setup.cfg
|
||||||
self.assertEqual(len(content), 9)
|
self.assertEqual(len(content), 10)
|
||||||
|
|
||||||
# Checking the MANIFEST
|
# Checking the MANIFEST
|
||||||
with open(join(self.tmp_dir, 'MANIFEST')) as fp:
|
with open(join(self.tmp_dir, 'MANIFEST')) as fp:
|
||||||
|
@ -230,7 +232,7 @@ class SDistTestCase(support.TempdirManager,
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
cmd.run()
|
cmd.run()
|
||||||
warnings = self.get_logs(logging.WARN)
|
warnings = self.get_logs(logging.WARN)
|
||||||
self.assertEqual(len(warnings), 3)
|
self.assertEqual(len(warnings), 4)
|
||||||
|
|
||||||
# trying with a complete set of metadata
|
# trying with a complete set of metadata
|
||||||
self.loghandler.flush()
|
self.loghandler.flush()
|
||||||
|
@ -242,8 +244,9 @@ class SDistTestCase(support.TempdirManager,
|
||||||
# removing manifest generated warnings
|
# removing manifest generated warnings
|
||||||
warnings = [warn for warn in warnings if
|
warnings = [warn for warn in warnings if
|
||||||
not warn.endswith('-- skipping')]
|
not warn.endswith('-- skipping')]
|
||||||
# the remaining warning is about the use of the default file list
|
# the remaining warnings are about the use of the default file list and
|
||||||
self.assertEqual(len(warnings), 1)
|
# the absence of setup.cfg
|
||||||
|
self.assertEqual(len(warnings), 2)
|
||||||
|
|
||||||
def test_show_formats(self):
|
def test_show_formats(self):
|
||||||
__, stdout = captured_stdout(show_formats)
|
__, stdout = captured_stdout(show_formats)
|
||||||
|
|
|
@ -66,10 +66,15 @@ class CreateTestCase(support.TempdirManager,
|
||||||
# building the structure
|
# building the structure
|
||||||
tempdir = self.wdir
|
tempdir = self.wdir
|
||||||
dirs = ['pkg1', 'data', 'pkg2', 'pkg2/sub']
|
dirs = ['pkg1', 'data', 'pkg2', 'pkg2/sub']
|
||||||
files = ['README', 'setup.cfg', 'foo.py',
|
files = [
|
||||||
'pkg1/__init__.py', 'pkg1/bar.py',
|
'README',
|
||||||
'data/data1', 'pkg2/__init__.py',
|
'data/data1',
|
||||||
'pkg2/sub/__init__.py']
|
'foo.py',
|
||||||
|
'pkg1/__init__.py',
|
||||||
|
'pkg1/bar.py',
|
||||||
|
'pkg2/__init__.py',
|
||||||
|
'pkg2/sub/__init__.py',
|
||||||
|
]
|
||||||
|
|
||||||
for dir_ in dirs:
|
for dir_ in dirs:
|
||||||
os.mkdir(os.path.join(tempdir, dir_))
|
os.mkdir(os.path.join(tempdir, dir_))
|
||||||
|
@ -86,8 +91,8 @@ class CreateTestCase(support.TempdirManager,
|
||||||
['pkg1', 'pkg2', 'pkg2.sub'])
|
['pkg1', 'pkg2', 'pkg2.sub'])
|
||||||
self.assertEqual(mainprogram.data['modules'], ['foo'])
|
self.assertEqual(mainprogram.data['modules'], ['foo'])
|
||||||
data_fn = os.path.join('data', 'data1')
|
data_fn = os.path.join('data', 'data1')
|
||||||
self.assertEqual(set(mainprogram.data['extra_files']),
|
self.assertEqual(mainprogram.data['extra_files'],
|
||||||
set(['setup.cfg', 'README', data_fn]))
|
['README', data_fn])
|
||||||
|
|
||||||
def test_convert_setup_py_to_cfg(self):
|
def test_convert_setup_py_to_cfg(self):
|
||||||
self.write_file((self.wdir, 'setup.py'),
|
self.write_file((self.wdir, 'setup.py'),
|
||||||
|
|
Loading…
Reference in New Issue