[PATCH] distutils: Monkeypatch distutils.commands.sdist to respect built MANIFEST

Mads Kiilerich mads at kiilerich.com
Wed Jun 8 18:03:16 CDT 2011


Stephen Thorne wrote, On 06/04/2011 12:12 PM:
> # HG changeset patch
> # User Stephen Thorne<stephen at thorne.id.au>
> # Date 1307182328 -36000
> # Node ID 086af4bc94ebac43a78f35cbeb36c7b75524b2f1
> # Parent  b4175b72bbd888c8f2bc9d9d6034d5f7bfbbeaba
> distutils: Monkeypatch distutils.commands.sdist to respect built MANIFEST
>
> When running 'python2.7 setup.py sdist' many files were omitted from the
> resulting tarball that are required for a complete build, including the .h file
> for the inotify extension.
>
> By changing the 'write_manifest' to be 'read_manifest', MANIFEST will be read
> properly and the build will succeed correctly.
>
> Unfortunately, this is due to Issue11104<http://bugs.python.org/issue11104>
> in the core python distribution. I have written a patch to fix the problem in
> python core, but anyone who is running 2.7.1 will be affected.

If I understand it correctly we should make it more clear: The issue is 
in 2.7, 2.7.1 and 2.7.2, and you hope to get your fix included in 2.7.3?

> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -388,6 +388,12 @@ if sys.platform == 'darwin' and os.path.
>           StrictVersion(version.split()[1])>= StrictVersion('4.0')):
>           os.environ['ARCHFLAGS'] = ''
>
> +if (2, 7, 0)<= sys.version_info<= (2, 7, 2):
> +    # Python 2.7 and 2.7.1 will not respect the MANIFEST built by the Makefile

2.7.2 should be mentioned here too so it doesn't look like a bug.

> +    # this monkeypatch will cause it to be read.
> +    from distutils.command.sdist import sdist
> +    sdist.write_manifest = sdist.read_manifest
> +
>   setup(name='mercurial',
>         version=setupversion,
>         author='Matt Mackall',

That is a real monkey patch, but I tend to agree that it is the most 
elegant way to hack around this issue.

I guess it will continue to work even if distributions start to backport 
workarounds for this issue.

Alternatively: The distutils code in 2.7 was obviously intended to be 
used with a .in file and that is what they have tested. A less hackish 
workaround would thus be to give distutils a .in file to process. That 
would however quickly become more intrusive than this monkey patch.

/Mads


More information about the Mercurial-devel mailing list