Changeset 175:28e7ea5314e4


Ignore:
Timestamp:
May 15, 2012, 2:43:37 PM (8 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Make sure 'twisted' doesn't appear in the egg-info top_level.txt file.

Wokkel provides a plugin for twistd. As with all twisted plugins, these
need to be placed in a directory twisted/plugins so that the plugin mechanism
can find them. This is not a real package, and when building eggs the
directory must appear in the egg. However, 'twisted' should not occur in the
top_level.txt file as this causes warnings when importing twisted, and
triggers a bug in pip that removes all of twisted when a package with a
twisted plugin is removed.

This change overrides the way the top_level.txt file is written, by explicitly
excluding 'twisted'.

Author: ralphm.
Fixes: #76.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r167 r175  
    55
    66from setuptools import setup
     7
     8# Make sure 'twisted' doesn't appear in top_level.txt
     9
     10try:
     11    from setuptools.command import egg_info
     12    egg_info.write_toplevel_names
     13except (ImportError, AttributeError):
     14    pass
     15else:
     16    def _top_level_package(name):
     17        return name.split('.', 1)[0]
     18
     19    def _hacked_write_toplevel_names(cmd, basename, filename):
     20        pkgs = dict.fromkeys(
     21            [_top_level_package(k)
     22                for k in cmd.distribution.iter_distribution_names()
     23                if _top_level_package(k) != "twisted"
     24            ]
     25        )
     26        cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n')
     27
     28    egg_info.write_toplevel_names = _hacked_write_toplevel_names
    729
    830setup(name='wokkel',
Note: See TracChangeset for help on using the changeset viewer.