Julien Jehannet avatar Julien Jehannet committed d184b43

save fix-file-under-projet.diff

Comments (0)

Files changed (4)

fix-file-under-projet.diff

+# HG changeset patch
+# Parent d02ea09f24fa66fb2af14b5eae86aebfaae94dd9
+# User Julien Jehannet <julien@smaf.org>
+# Date 1296409793 -3600
+Avoid double-declaration in double-declaration in description- and extra- files
+
+Since changeset c8dfb3c63894, files in metadata must be declared in `extra_files`.
+In order to simplify the declaration, include automatically these files when
+under project directory.
+
+The detection is really done by these two conditions:
+- is not an absolute path
+- not in one of parent directory
+
+Note: the heuristic is quite fragile here.
+
+diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py
+--- a/distutils2/command/sdist.py
++++ b/distutils2/command/sdist.py
+@@ -193,6 +193,19 @@ class sdist(Command):
+         reading the manifest, or just using the default file set -- it all
+         depends on the user's options.
+         """
++        # Remark: external path files are allowed in setup.cfg
++        # This implies declarations in `extra_files` to include them in the
++        # source distribution but we want make them implicit when files are
++        # already under the project path (i.e. not absolute paths or not in
++        # parent directory)
++        for file in self.distribution.metadata.requires_files:
++            # XXX fragile heuristic: file cannot starts with '..'
++            if (not os.path.isabs(file) and
++                not os.path.normpath(file).startswith('..')):
++                 self.distribution.metadata.requires_files.remove(file)
++                 self.distribution.extra_files.append(file)
++                 self.filelist.append(file)
++
+         template_exists = len(self.distribution.extra_files) > 0
+         if not template_exists:
+             self.warn('Using default file list')
+@@ -200,6 +213,7 @@ class sdist(Command):
+ 
+         if self.use_defaults:
+             self.add_defaults()
++
+         if template_exists:
+             template = '\n'.join(self.distribution.extra_files)
+             self.filelist.read_template(StringIO(template))
+diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py
+--- a/distutils2/tests/test_config.py
++++ b/distutils2/tests/test_config.py
+@@ -3,6 +3,7 @@
+ import os
+ import sys
+ from StringIO import StringIO
++import tempfile
+ 
+ from distutils2.tests import unittest, support, run_unittest
+ from distutils2.command.sdist import sdist
+@@ -302,6 +303,29 @@ class ConfigTestCase(support.TempdirMana
+         self.assertEqual(ext.extra_compile_args, ['-fPIC', '-O2'])
+         self.assertEqual(ext.language, 'cxx')
+ 
++    def test_metadata_requires_external_description_files(self):
++        tmpdir = tempfile.mkdtemp()
++        readme = os.path.join(tmpdir, 'README')
++        self.write_setup({'description-file': readme + '\n'})
++        self.write_file(readme, 'yeah')
++        self.write_file('haven.py', '#')
++        self.write_file('script1.py', '#')
++        os.mkdir('scripts')
++        self.write_file(os.path.join('scripts', 'find-coconuts'), '#')
++        os.mkdir('bin')
++        self.write_file(os.path.join('bin', 'taunt'), '#')
++
++        os.mkdir('src')
++        for pkg in ('one', 'two', 'three'):
++            pkg = os.path.join('src', pkg)
++            os.mkdir(pkg)
++            self.write_file(os.path.join(pkg, '__init__.py'), '#')
++
++        dist = self.run_setup('--version')
++        cmd = sdist(dist)
++        cmd.finalize_options()
++        cmd.get_file_list()
++        self.assertRaises(DistutilsFileError, cmd.make_distribution)
+ 
+     def test_metadata_requires_description_files_missing(self):
+         self.write_setup({'description-file': 'README\n  README2'})
+@@ -350,8 +374,10 @@ class ConfigTestCase(support.TempdirMana
+         cmd = sdist(dist)
+         cmd.finalize_options()
+         cmd.get_file_list()
+-        self.assertRaises(DistutilsFileError, cmd.make_distribution)
++        cmd.make_distribution()
++        self.assertIn('README\nREADME2\n', open('MANIFEST').read())
+ 
++        # test if double-declaration in description- and extra- files
+         self.write_setup({'description-file': 'README\n  README2',
+                           'extra-files': '\n  README2\n    README'})
+         dist = self.run_setup('--description')

make_directory.diff

-# HG changeset patch
-# Date 1296380094 -3600
-# User Julien Jehannet <julien@smaf.org>
-# Parent 7dc4323bb9652aab1667431eb62e25c4236b57a6
-Add new format `files` in source distribution command (sdist). Used in debugging.
-
-diff --git a/distutils2/_backport/shutil.py b/distutils2/_backport/shutil.py
---- a/distutils2/_backport/shutil.py
-+++ b/distutils2/_backport/shutil.py
-@@ -328,6 +328,18 @@ def _get_uid(name):
-         return result[2]
-     return None
- 
-+def _make_directory(archive_dir, base_dir, verbose=0, dry_run=0, owner=None,
-+                    group=None, logger=None):
-+    """Create a directory full of files coming from 'base_dir'.
-+
-+    The output directory name will be named 'base_dir'
-+
-+    Returns the output directory.
-+    """
-+    if not dry_run:
-+        copytree(base_dir, archive_dir)
-+    return archive_dir
-+
- def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
-                   owner=None, group=None, logger=None):
-     """Create a (possibly compressed) tar file from all the files under
-@@ -473,6 +485,7 @@ def _make_zipfile(base_name, base_dir, v
-     return zip_filename
- 
- _ARCHIVE_FORMATS = {
-+    'files': (_make_directory, [], "a directory full of files"),
-     'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
-     'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
-     'ztar':  (_make_tarball, [('compress', 'compress')],
-make_directory.diff
-setupcfg.diff
+fix-file-under-projet.diff

setupcfg.diff

-# HG changeset patch
-# Date 1296379767 -3600
-# User Julien Jehannet <julien@smaf.org>
-# Parent 95d726a89a02ea4c51b820b697875c2781f64468
-update setupcfg documentation page
-
-diff --git a/docs/source/distutils/sourcedist.rst b/docs/source/distutils/sourcedist.rst
---- a/docs/source/distutils/sourcedist.rst
-+++ b/docs/source/distutils/sourcedist.rst
-@@ -86,8 +86,8 @@ source distribution:
-   distributions, but in the future there will be a standard for testing Python
-   module distributions)
- 
--* :file:`README.txt` (or :file:`README`), :file:`setup.py` (or whatever  you
--  called your setup script), and :file:`setup.cfg`
-+* :file:`setup.py` (or whatever you called your setup script), and
-+  :file:`setup.cfg`
- 
- * all files that matches the ``package_data`` metadata.
-   See :ref:`distutils-installing-package-data`.
-@@ -95,6 +95,10 @@ source distribution:
- * all files that matches the ``data_files`` metadata.
-   See :ref:`distutils-additional-files`.
- 
-+.. Warning::
-+    In Distutils2, README or README.txt files are not more included in source
-+    distribution by default
-+
- Sometimes this is enough, but usually you will want to specify additional files
- to distribute.  The typical way to do this is to write a *manifest template*,
- called :file:`MANIFEST.in` by default.  The manifest template is just a list of
-diff --git a/docs/source/setupcfg.rst b/docs/source/setupcfg.rst
---- a/docs/source/setupcfg.rst
-+++ b/docs/source/setupcfg.rst
-@@ -7,8 +7,8 @@ Distutils2 to replace the :file:`setup.p
- 
- Each section contains a description of its options.
- 
--- Options that are marked *\*multi* can have multiple values, one value
--  per line.
-+- Options that are marked *\*multi* can have multiple values, one value per
-+  line.
- - Options that are marked *\*optional* can be omited.
- - Options that are marked *\*environ* can use environment markers, as described
-   in :PEP:`345`.
-@@ -49,7 +49,7 @@ Contains global options for Distutils2. 
-   *\*optional* *\*multi*
- 
- - **compilers**: Defined Distutils2 compiler. A compiler is defined by its fully
--  qualified name. 
-+  qualified name.
- 
-   Example::
- 
-@@ -66,7 +66,8 @@ Contains global options for Distutils2. 
-   Example::
- 
-     [global]
--    setup_hook = distutils2.tests.test_config.hook
-+    setup_hook =
-+        distutils2.tests.test_config.hook
- 
- 
- metadata
-@@ -142,7 +143,7 @@ Example::
- 
- .. Note::
-     Some metadata fields seen in :PEP:`345` are automatically generated
--    as the Metadata-Version value for instance.
-+    (for instance Metadata-Version value).
- 
- 
- files
-@@ -170,6 +171,14 @@ Example::
- 
-     extra_files =
-             setup.py
-+            README
-+
-+.. Note::
-+    In Distutils2, setup.cfg will be implicitly included.
-+
-+.. Warning::
-+    In Distutils2, README or README.txt files are not more included in source
-+    distribution by default
- 
- 
- `command` sections
-@@ -183,7 +192,7 @@ Example::
-     manifest-builders = package.module.Maker
- 
- 
--To override the building class in order to compile your python2 files to python3::
-+To override the build class in order to generate Python3 code from your Python2 base::
- 
-     [build_py]
-     use-2to3 = True
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.