[Python-checkins] distutils2: now sdist uses the extra_files option from setup.cfg, and the Distribution

tarek.ziade python-checkins at python.org
Sun Oct 17 22:27:43 CEST 2010


tarek.ziade pushed b62d428316a8 to distutils2:

http://hg.python.org/distutils2/rev/b62d428316a8
changeset:   772:b62d428316a8
tag:         tip
user:        Tarek Ziade <tarek at ziade.org>
date:        Sun Oct 17 22:27:05 2010 +0200
summary:     now sdist uses the extra_files option from setup.cfg, and the Distribution object has it as an attribute
files:       CHANGES.txt, distutils2/command/sdist.py, distutils2/config.py, distutils2/dist.py, distutils2/tests/test_command_sdist.py

diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,9 +2,14 @@
 CHANGES
 =======
 
-1.0a3 - ?
+1.0a4 - ?
 ---------
 
+- The setup runner supports more options:
+
+1.0a3 - 2010-10-08
+------------------
+
 - Provided a Tox configuration for cross-python testing [holger]
 - Fixed the installation when using easy_install and Pip by switching
   setup.py to distutils1 [holger/tarek]
diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py
--- a/distutils2/command/sdist.py
+++ b/distutils2/command/sdist.py
@@ -1,8 +1,6 @@
 """distutils.command.sdist
 
 Implements the Distutils 'sdist' command (create a source distribution)."""
-
-
 import os
 import string
 import sys
@@ -10,6 +8,7 @@
 from warnings import warn
 from shutil import rmtree
 import re
+from StringIO import StringIO
 
 try:
     from shutil import get_archive_formats
@@ -44,8 +43,6 @@
     description = "create a source distribution (tarball, zip file, etc.)"
 
     user_options = [
-        ('template=', 't',
-         "name of manifest template file [default: MANIFEST.in]"),
         ('manifest=', 'm',
          "name of manifest file [default: MANIFEST]"),
         ('use-defaults', None,
@@ -93,9 +90,6 @@
                       'nt': 'zip' }
 
     def initialize_options(self):
-        # 'template' and 'manifest' are, respectively, the names of
-        # the manifest template and manifest file.
-        self.template = None
         self.manifest = None
 
         # 'use_defaults': if true, we will include the default file set
@@ -123,8 +117,6 @@
     def finalize_options(self):
         if self.manifest is None:
             self.manifest = "MANIFEST"
-        if self.template is None:
-            self.template = "MANIFEST.in"
 
         self.ensure_string_list('formats')
         if self.formats is None:
@@ -176,18 +168,16 @@
         reading the manifest, or just using the default file set -- it all
         depends on the user's options.
         """
-        template_exists = os.path.isfile(self.template)
+        template_exists = len(self.distribution.extra_files) > 0
         if not template_exists:
-            self.warn(("manifest template '%s' does not exist " +
-                        "(using default file list)") %
-                        self.template)
-
+            self.warn('Using default file list')
         self.filelist.findall()
 
         if self.use_defaults:
             self.add_defaults()
         if template_exists:
-            self.filelist.read_template(self.template)
+            template = '\n'.join(self.distribution.extra_files)
+            self.filelist.read_template(StringIO(template))
         if self.prune:
             self.prune_file_list()
 
diff --git a/distutils2/config.py b/distutils2/config.py
--- a/distutils2/config.py
+++ b/distutils2/config.py
@@ -176,7 +176,7 @@
                 self.dist.data_files.append((key, values))
 
             # manifest template
-            # XXX see later
+            self.dist.extra_files = files.get('extra_files', [])
 
     def parse_config_files(self, filenames=None):
         if filenames is None:
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -202,6 +202,7 @@
         self.password = ''
         self.use_2to3 = False
         self.convert_2to3_doctests = []
+        self.extra_files = []
 
         # And now initialize bookkeeping stuff that can't be supplied by
         # the caller at all.  'command_obj' maps command names to
diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py
--- a/distutils2/tests/test_command_sdist.py
+++ b/distutils2/tests/test_command_sdist.py
@@ -279,7 +279,6 @@
 
         # default options set by finalize
         self.assertEqual(cmd.manifest, 'MANIFEST')
-        self.assertEqual(cmd.template, 'MANIFEST.in')
         self.assertEqual(cmd.dist_dir, 'dist')
 
         # formats has to be a string splitable on (' ', ',') or
@@ -415,6 +414,21 @@
 
         self.assertEqual(manifest, ['README.manual'])
 
+    def test_template(self):
+        dist, cmd = self.get_cmd()
+        dist.extra_files = ['include yeah']
+        cmd.ensure_finalized()
+        self.write_file((self.tmp_dir, 'yeah'), 'xxx')
+        cmd.run()
+        f = open(cmd.manifest)
+        try:
+            content = f.read()
+        finally:
+            f.close()
+
+        self.assertIn('yeah', content)
+
+
 def test_suite():
     return unittest.makeSuite(SDistTestCase)
 

--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list