diff options
author | Éric Araujo <merwok@netwok.org> | 2011-06-07 15:31:39 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-06-07 15:31:39 (GMT) |
commit | 313570a1851bbe8c44af07be2eceb021fea6c994 (patch) | |
tree | 19e92183602f61a4d6d107c8569440baf8cab213 /Lib | |
parent | 1752468d39a38ac73ec13fc1f8f6427623b69074 (diff) | |
parent | 69cdf9294fee18e3b38278f2baf00c15c7bdbd8e (diff) | |
download | cpython-313570a1851bbe8c44af07be2eceb021fea6c994.zip cpython-313570a1851bbe8c44af07be2eceb021fea6c994.tar.gz cpython-313570a1851bbe8c44af07be2eceb021fea6c994.tar.bz2 |
Branch merge: packaging fixes
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/packaging/command/sdist.py | 21 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_sdist.py | 15 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_upload.py | 2 | ||||
-rw-r--r-- | Lib/packaging/tests/test_create.py | 137 | ||||
-rw-r--r-- | Lib/sysconfig.cfg | 14 |
5 files changed, 104 insertions, 85 deletions
diff --git a/Lib/packaging/command/sdist.py b/Lib/packaging/command/sdist.py index a19203f..09b26db 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 41b2a24..7be349f 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'), '#') @@ -211,9 +213,9 @@ 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 - # files in addition to PKG-INFO. - self.assertEqual(len(content), 9) + # Making sure everything was added. This includes 8 code and data + # 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_command_upload.py b/Lib/packaging/tests/test_command_upload.py index d7609a2..dbb4db7 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: diff --git a/Lib/packaging/tests/test_create.py b/Lib/packaging/tests/test_create.py index 906ca8f..a82ab43 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): @@ -65,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_)) @@ -85,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'), @@ -130,43 +136,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) - - # 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}', - ])) + contents = fp.read() + + 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 +211,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) - - 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}', - ])) + contents = fp.read() + + 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(): diff --git a/Lib/sysconfig.cfg b/Lib/sysconfig.cfg index 1f6b8bc..573b12e 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 |