[Python-checkins] cpython (merge default -> default): Branch merge: packaging fixes

eric.araujo python-checkins at python.org
Tue Jun 7 17:32:05 CEST 2011


http://hg.python.org/cpython/rev/324dd279f3f2
changeset: 70708:324dd279f3f2
parent: 70701:b410d013e7a8
parent: 70707:e0534a0846ca
user: Éric Araujo <merwok at netwok.org>
date: Tue Jun 07 17:31:39 2011 +0200
summary:
 Branch merge: packaging fixes
files:
 Doc/packaging/setupcfg.rst | 6 +-
 Lib/packaging/command/sdist.py | 21 +-
 Lib/packaging/tests/test_command_sdist.py | 15 +-
 Lib/packaging/tests/test_command_upload.py | 2 +-
 Lib/packaging/tests/test_create.py | 133 +++++----
 Lib/sysconfig.cfg | 14 +-
 6 files changed, 105 insertions(+), 86 deletions(-)
diff --git a/Doc/packaging/setupcfg.rst b/Doc/packaging/setupcfg.rst
--- a/Doc/packaging/setupcfg.rst
+++ b/Doc/packaging/setupcfg.rst
@@ -265,9 +265,9 @@
 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,
diff --git a/Lib/packaging/command/sdist.py b/Lib/packaging/command/sdist.py
--- a/Lib/packaging/command/sdist.py
+++ b/Lib/packaging/command/sdist.py
@@ -201,15 +201,20 @@
 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
--- a/Lib/packaging/tests/test_command_sdist.py
+++ b/Lib/packaging/tests/test_command_sdist.py
@@ -34,6 +34,7 @@
 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 @@
 # 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 @@
 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 @@
 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 @@
 # 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
--- a/Lib/packaging/tests/test_command_upload.py
+++ b/Lib/packaging/tests/test_command_upload.py
@@ -140,8 +140,8 @@
 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
--- a/Lib/packaging/tests/test_create.py
+++ b/Lib/packaging/tests/test_create.py
@@ -13,6 +13,7 @@
 support.EnvironRestorer,
 unittest.TestCase):
 
+ maxDiff = None
 restore_environ = ['PLAT']
 
 def setUp(self):
@@ -65,10 +66,15 @@
 # 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 @@
 ['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 @@
 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 at 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 at 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 @@
 # 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 at 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 at 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
--- 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
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /