[IPython-dev] Help needed: stumped by odd MANIFEST.in/distutils behavior

Paul Ivanov pivanov314@gmail....
Mon Oct 10 14:56:06 CDT 2011


On Sun, Oct 9, 2011 at 11:23 PM, Paul Ivanov <pivanov314@gmail.com> wrote:
> On Sun, Oct 9, 2011 at 1:51 PM, Fernando Perez <fperez.net@gmail.com> wrote:
>>
>> I'm pretty stumped, so any ideas would be very much appreciated.
>
> I took a brief look - it looks like something about distribute and
> setuptools being used together.

I poked around some more: looks like importing setuptools changes
distutils.dist.Distribution to point to setuptools.dist.Distribution,
and also does the same with command.sdist, with setuptools' version
not implementing user_options like 'manifest-only' (see
setuptools/dist.py:642-644)

Compare just the --help sdist command with and without importing setuptools.
$ python setup.py --help sdist

without setuptools:
---
Options for 'sdist' command:
  --template (-t)        name of manifest template file [default: MANIFEST.in]
  --manifest (-m)        name of manifest file [default: MANIFEST]
  --use-defaults         include the default file set in the manifest
                         [default; disable with --no-defaults]
  --no-defaults          don't include the default file set
  --prune                specifically exclude files/directories that should
                         not be distributed (build tree, RCS/CVS dirs, etc.)
                         [default; disable with --no-prune]
  --no-prune             don't automatically exclude anything
  --manifest-only (-o)   just regenerate the manifest and then stop (implies
                         --force-manifest)
  --force-manifest (-f)  forcibly regenerate the manifest and carry on as
                         usual. Deprecated: now the manifest is always
                         regenerated.
  --formats              formats for source distribution (comma-separated
                         list)
  --keep-temp (-k)       keep the distribution tree around after creating
                         archive file(s)
  --dist-dir (-d)        directory to put the source distribution archive(s)
                         in [default: dist]
  --metadata-check       Ensure that all required elements of meta-data are
                         supplied. Warn if any missing. [default]
  --owner (-u)           Owner name used when creating a tar file [default:
                         current user]
  --group (-g)           Group name used when creating a tar file [default:
                         current group]
  --help-formats         list available distribution formats
---

When setuptools is imported, the help string is much shorter, and
shows none of the usual user_options.
---
Options for 'sdist' command:
  --formats         formats for source distribution (comma-separated list)
  --keep-temp (-k)  keep the distribution tree around after creating archive
                    file(s)
  --dist-dir (-d)   directory to put the source distribution archive(s) in
                    [default: dist]
  --help-formats    list available distribution formats
---


I guess if setuptools really is needed to be imported, one way to get
back the functionality would be to reverse-monkeypatch distutils'
Distribution back in using the following patch (or something like it,
perhaps only if '--manifest-only' or '-o' flags are passed):

diff --git a/setup2.py b/setup2.py
index 1c12356..3a37c6c 100755
--- a/setup2.py
+++ b/setup2.py
@@ -212,6 +212,10 @@ if len(needs_setuptools.intersection(sys.argv)) > 0:
 setuptools_extra_args = {}

 if 'setuptools' in sys.modules:
+    # reverse monkeypatch setuptools/dist.py:643-644
+    import distutils
+    for module in distutils.dist, distutils.core, distutils.cmd:
+            module.Distribution = setuptools.dist._Distribution
     setuptools_extra_args['zip_safe'] = False
     setuptools_extra_args['entry_points'] = find_scripts(True)
     setup_args['extras_require'] = dict(

Doing the above, however, will cause these warnings to start showing up
distutils/dist.py:267: UserWarning: Unknown distribution option:
'install_requires'
  warnings.warn(msg)
distutils/dist.py:267: UserWarning: Unknown distribution option:
'extras_require'
  warnings.warn(msg)
python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
option: 'zip_safe'
  warnings.warn(msg)
python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
option: 'entry_points

hth,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


More information about the IPython-dev mailing list