From fdeb8bf292fb0734548174002b59abe9f1a0ac76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 19:57:02 +0200 Subject: [PATCH 1/6] Fix documentation of requires-python field in setup.cfg (#11041) --- Doc/packaging/setupcfg.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/packaging/setupcfg.rst b/Doc/packaging/setupcfg.rst index 92ddb8bdf46..d3fc07a944c 100644 --- a/Doc/packaging/setupcfg.rst +++ b/Doc/packaging/setupcfg.rst @@ -265,9 +265,9 @@ obsoletes-dist Same format than *requires-dist*. *optional*, *multi*, *environ* requires-python - Specifies the Python version the distribution requires. - The value is a version number, as described in PEP 345. - *optional*, *multi*, *environ* + Specifies the Python version the distribution requires. The value is a + comma-separated list of version predicates, as described in PEP 345. + *optional*, *environ* requires-externals a dependency in the system. This field is free-form, From 9808dac192601960916e4300633a1d1818be92c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 20:07:04 +0200 Subject: [PATCH 2/6] Update comments in sysconfig.cfg --- Lib/sysconfig.cfg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/sysconfig.cfg b/Lib/sysconfig.cfg index 1f6b8bcacc8..573b12e8daf 100644 --- a/Lib/sysconfig.cfg +++ b/Lib/sysconfig.cfg @@ -1,24 +1,24 @@ [globals] -# These are the useful categories that are sometimes referenced at runtime, -# using packaging.resources.get_file: +# These are useful categories that can be referenced at run time, +# using packaging.database.get_file. # Configuration files config = {confdir}/{distribution.name} # Non-writable data that is independent of architecture (images, many xml/text files) appdata = {datadir}/{distribution.name} # Non-writable data that is architecture-dependent (some binary data formats) appdata.arch = {libdir}/{distribution.name} -# Data, written by the package, that must be preserved (databases) +# Data, written by the app/lib, that must be preserved (databases) appdata.persistent = {statedir}/lib/{distribution.name} -# Data, written by the package, that can be safely discarded (cache) +# Data, written by the app/lib, that can be safely discarded (cache) appdata.disposable = {statedir}/cache/{distribution.name} -# Help or documentation files referenced at runtime +# Help or documentation files help = {datadir}/{distribution.name} icon = {datadir}/pixmaps scripts = {base}/bin # Non-runtime files. These are valid categories for marking files for -# install, but they should not be referenced by the app at runtime: -# Help or documentation files not referenced by the package at runtime +# install, but they should not be referenced by the app/lib at run time. +# Help or documentation files doc = {datadir}/doc/{distribution.name} # GNU info documentation files info = {datadir}/info From de7563bd3c0476b40869de0e75244052a3fc568d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 20:28:13 +0200 Subject: [PATCH 3/6] Fix comment --- Lib/packaging/tests/test_command_sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py index 41b2a24c8bf..82f4b30e59d 100644 --- a/Lib/packaging/tests/test_command_sdist.py +++ b/Lib/packaging/tests/test_command_sdist.py @@ -211,7 +211,7 @@ class SDistTestCase(support.TempdirManager, with zipfile.ZipFile(join(dist_folder, 'fake-1.0.zip')) as zip_file: content = zip_file.namelist() - # Making sure everything was added. This includes 9 code and data + # Making sure everything was added. This includes 8 code and data # files in addition to PKG-INFO. self.assertEqual(len(content), 9) From 078368fe4d9955890bf317481483b56752fb4ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 20:59:56 +0200 Subject: [PATCH 4/6] Use strings instead of sets of lines in packaging.create tests. Using sets in tests did not check whether the values were written in the right section or with the right key. --- Lib/packaging/tests/test_create.py | 116 +++++++++++++++-------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/Lib/packaging/tests/test_create.py b/Lib/packaging/tests/test_create.py index 906ca8fa539..92a3ea4299f 100644 --- a/Lib/packaging/tests/test_create.py +++ b/Lib/packaging/tests/test_create.py @@ -13,6 +13,7 @@ class CreateTestCase(support.TempdirManager, support.EnvironRestorer, unittest.TestCase): + maxDiff = None restore_environ = ['PLAT'] def setUp(self): @@ -130,43 +131,45 @@ class CreateTestCase(support.TempdirManager, main() with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp: - lines = set(line.rstrip() for line in fp) + contents = fp.read() - # FIXME don't use sets - self.assertEqual(lines, set(['', - '[metadata]', - 'version = 0.2', - 'name = pyxfoil', - 'maintainer = André Espaze', - 'description = My super Death-scription', - ' |barbar is now on the public domain,', - ' |ho, baby !', - 'maintainer_email = andre.espaze@logilab.fr', - 'home_page = http://www.python-science.org/project/pyxfoil', - 'download_url = UNKNOWN', - 'summary = Python bindings for the Xfoil engine', - '[files]', - 'modules = my_lib', - ' mymodule', - 'packages = pyxfoil', - ' babar', - ' me', - 'extra_files = Martinique/Lamentin/dady', - ' Martinique/Lamentin/mumy', - ' Martinique/Lamentin/sys', - ' Martinique/Lamentin/bro', - ' Pom', - ' Flora', - ' Alexander', - ' setup.py', - ' README', - ' pyxfoil/fengine.so', - 'scripts = my_script', - ' bin/run', - 'resources =', - ' README.rst = {doc}', - ' pyxfoil.1 = {man}', - ])) + self.assertEqual(contents, dedent("""\ + [metadata] + name = pyxfoil + version = 0.2 + summary = Python bindings for the Xfoil engine + download_url = UNKNOWN + home_page = http://www.python-science.org/project/pyxfoil + maintainer = André Espaze + maintainer_email = andre.espaze@logilab.fr + description = My super Death-scription + |barbar is now on the public domain, + |ho, baby ! + + [files] + packages = pyxfoil + babar + me + modules = my_lib + mymodule + scripts = my_script + bin/run + extra_files = Martinique/Lamentin/dady + Martinique/Lamentin/mumy + Martinique/Lamentin/sys + Martinique/Lamentin/bro + setup.py + README + Pom + Flora + Alexander + pyxfoil/fengine.so + + resources = + README.rst = {doc} + pyxfoil.1 = {man} + + """)) def test_convert_setup_py_to_cfg_with_description_in_readme(self): self.write_file((self.wdir, 'setup.py'), @@ -203,26 +206,29 @@ ho, baby! # FIXME Out of memory error. main() with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp: - lines = set(line.rstrip() for line in fp) + contents = fp.read() - self.assertEqual(lines, set(['', - '[metadata]', - 'version = 0.2', - 'name = pyxfoil', - 'maintainer = André Espaze', - 'maintainer_email = andre.espaze@logilab.fr', - 'home_page = http://www.python-science.org/project/pyxfoil', - 'download_url = UNKNOWN', - 'summary = Python bindings for the Xfoil engine', - 'description-file = README.txt', - '[files]', - 'packages = pyxfoil', - 'extra_files = pyxfoil/fengine.so', - ' pyxfoil/babar.so', - 'resources =', - ' README.rst = {doc}', - ' pyxfoil.1 = {man}', - ])) + self.assertEqual(contents, dedent("""\ + [metadata] + name = pyxfoil + version = 0.2 + summary = Python bindings for the Xfoil engine + download_url = UNKNOWN + home_page = http://www.python-science.org/project/pyxfoil + maintainer = André Espaze + maintainer_email = andre.espaze@logilab.fr + description-file = README.txt + + [files] + packages = pyxfoil + extra_files = pyxfoil/fengine.so + pyxfoil/babar.so + + resources = + README.rst = {doc} + pyxfoil.1 = {man} + + """)) def test_suite(): From 7373fccd50516909574fc67bb92a899963e96ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 21:55:43 +0200 Subject: [PATCH 5/6] Fix sdist to always include setup.cfg (#11092), to comply with the spec --- Lib/packaging/command/sdist.py | 21 +++++++++++++-------- Lib/packaging/tests/test_command_sdist.py | 13 ++++++++----- Lib/packaging/tests/test_create.py | 17 +++++++++++------ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Lib/packaging/command/sdist.py b/Lib/packaging/command/sdist.py index a19203fe6a6..09b26db2d87 100644 --- a/Lib/packaging/command/sdist.py +++ b/Lib/packaging/command/sdist.py @@ -201,15 +201,20 @@ class sdist(Command): self.filelist.write(self.manifest) def add_defaults(self): - """Add all the default files to self.filelist: - - all pure Python modules mentioned in setup script - - all files pointed by package_data (build_py) - - all files defined in data_files. - - all files defined as scripts. - - all C sources listed as part of extensions or C libraries - in the setup script (doesn't catch C headers!) - Everything is optional. + """Add all default files to self.filelist. + + In addition to the setup.cfg file, this will include all files returned + by the get_source_files of every registered command. This will find + Python modules and packages, data files listed in package_data_, + data_files and extra_files, scripts, C sources of extension modules or + C libraries (headers are missing). """ + 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(): try: cmd_obj = self.get_finalized_command(cmd_name) diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py index 82f4b30e59d..7be349f1ece 100644 --- a/Lib/packaging/tests/test_command_sdist.py +++ b/Lib/packaging/tests/test_command_sdist.py @@ -34,6 +34,7 @@ setup(name='fake') MANIFEST = """\ # file GENERATED by packaging, do NOT edit inroot.txt +setup.cfg data%(sep)sdata.dt scripts%(sep)sscript.py some%(sep)sfile.txt @@ -173,6 +174,7 @@ class SDistTestCase(support.TempdirManager, # in package_data dist.package_data = {'': ['*.cfg', '*.dat'], '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.dat'), '#') @@ -212,8 +214,8 @@ class SDistTestCase(support.TempdirManager, content = zip_file.namelist() # Making sure everything was added. This includes 8 code and data - # files in addition to PKG-INFO. - self.assertEqual(len(content), 9) + # files in addition to PKG-INFO and setup.cfg + self.assertEqual(len(content), 10) # Checking the MANIFEST with open(join(self.tmp_dir, 'MANIFEST')) as fp: @@ -230,7 +232,7 @@ class SDistTestCase(support.TempdirManager, cmd.ensure_finalized() cmd.run() warnings = self.get_logs(logging.WARN) - self.assertEqual(len(warnings), 3) + self.assertEqual(len(warnings), 4) # trying with a complete set of metadata self.loghandler.flush() @@ -242,8 +244,9 @@ class SDistTestCase(support.TempdirManager, # removing manifest generated warnings warnings = [warn for warn in warnings if not warn.endswith('-- skipping')] - # the remaining warning is about the use of the default file list - self.assertEqual(len(warnings), 1) + # the remaining warnings are about the use of the default file list and + # the absence of setup.cfg + self.assertEqual(len(warnings), 2) def test_show_formats(self): __, stdout = captured_stdout(show_formats) diff --git a/Lib/packaging/tests/test_create.py b/Lib/packaging/tests/test_create.py index 92a3ea4299f..a82ab43254e 100644 --- a/Lib/packaging/tests/test_create.py +++ b/Lib/packaging/tests/test_create.py @@ -66,10 +66,15 @@ class CreateTestCase(support.TempdirManager, # building the structure tempdir = self.wdir dirs = ['pkg1', 'data', 'pkg2', 'pkg2/sub'] - files = ['README', 'setup.cfg', 'foo.py', - 'pkg1/__init__.py', 'pkg1/bar.py', - 'data/data1', 'pkg2/__init__.py', - 'pkg2/sub/__init__.py'] + files = [ + 'README', + 'data/data1', + 'foo.py', + 'pkg1/__init__.py', + 'pkg1/bar.py', + 'pkg2/__init__.py', + 'pkg2/sub/__init__.py', + ] for dir_ in dirs: os.mkdir(os.path.join(tempdir, dir_)) @@ -86,8 +91,8 @@ class CreateTestCase(support.TempdirManager, ['pkg1', 'pkg2', 'pkg2.sub']) self.assertEqual(mainprogram.data['modules'], ['foo']) data_fn = os.path.join('data', 'data1') - self.assertEqual(set(mainprogram.data['extra_files']), - set(['setup.cfg', 'README', data_fn])) + self.assertEqual(mainprogram.data['extra_files'], + ['README', data_fn]) def test_convert_setup_py_to_cfg(self): self.write_file((self.wdir, 'setup.py'), From 69cdf9294fee18e3b38278f2baf00c15c7bdbd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Mon, 6 Jun 2011 22:24:19 +0200 Subject: [PATCH 6/6] Fix UnboundLocalError in a finally block of one packaging test --- Lib/packaging/tests/test_command_upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/packaging/tests/test_command_upload.py b/Lib/packaging/tests/test_command_upload.py index d7609a28f8d..dbb4db784bb 100644 --- a/Lib/packaging/tests/test_command_upload.py +++ b/Lib/packaging/tests/test_command_upload.py @@ -140,8 +140,8 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer, cmd.upload_docs = True cmd.ensure_finalized() cmd.repository = self.pypi.full_address + prev_dir = os.getcwd() try: - prev_dir = os.getcwd() os.chdir(self.tmp_dir) cmd.run() finally: