Commit 87788f7b authored by Tres Seaver's avatar Tres Seaver

Merge 'tseaver-suppress_allow_hosts_noise' branch.

parents d2beb63d dd1052d7
......@@ -4,6 +4,9 @@ Change History
2.2.0dev (unreleased)
=====================
- Suppress the useless ``Link to <URL> ***BLOCKED*** by --allow-hosts``
error message being emitted by distribute / setuptools.
- Extend distutils script generation to support module docstrings and
__future__ imports.
......
......@@ -82,6 +82,25 @@ buildout_and_setuptools_path = [
FILE_SCHEME = re.compile('file://', re.I).match
class _Monkey(object):
def __init__(self, module, **kw):
mdict = self._mdict = module.__dict__
self._before = mdict.copy()
self._overrides = kw
def __enter__(self):
self._mdict.update(self._overrides)
return self
def __exit__(self, exc_type, exc_value, traceback):
self._mdict.clear()
self._mdict.update(self._before)
class _NoWarn(object):
def warn(self, *args, **kw):
pass
_no_warn = _NoWarn()
class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
"""Will allow urls that are local to the system.
......@@ -91,7 +110,12 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
def url_ok(self, url, fatal=False):
if FILE_SCHEME(url):
return True
return setuptools.package_index.PackageIndex.url_ok(self, url, False)
# distutils has its own logging, which can't be hooked / suppressed,
# so we monkey-patch the 'log' submodule to suppress the stupid
# "Link to <URL> ***BLOCKED*** by --allow-hosts" message.
with _Monkey(setuptools.package_index, log=_no_warn):
return setuptools.package_index.PackageIndex.url_ok(
self, url, False)
_indexes = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment