aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/dist.py
diff options
context:
space:
mode:
authorStefan H. Holek <stefan@epy.co.at>2012-10-08 20:32:46 +0200
committerStefan H. Holek <stefan@epy.co.at>2012-10-08 20:32:46 +0200
commit11270be66d228aacca12a211e3fdcb38988fb193 (patch)
treee552b6b9ccb05f439ce817ecc2b4babcbc1f416a /setuptools/dist.py
parentd76ec4bfdf2fe9a2bced5ca2a3610831020453c6 (diff)
downloadexternal_python_setuptools-11270be66d228aacca12a211e3fdcb38988fb193.tar.gz
external_python_setuptools-11270be66d228aacca12a211e3fdcb38988fb193.tar.bz2
external_python_setuptools-11270be66d228aacca12a211e3fdcb38988fb193.zip
Print metadata in UTF-8 independent of platform. Fixes #311.
--HG-- branch : distribute extra : rebase_source : 4ff0df4ad7d9ea8cee6342f9c642e4fe634b7f18
Diffstat (limited to 'setuptools/dist.py')
-rw-r--r--setuptools/dist.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 6607cf7b..afac180e 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -640,6 +640,38 @@ class Distribution(_Distribution):
name = name[:-6]
yield name
+
+ def handle_display_options(self, option_order):
+ """If there were any non-global "display-only" options
+ (--help-commands or the metadata display options) on the command
+ line, display the requested info and return true; else return
+ false.
+ """
+ import sys
+
+ if sys.version_info < (3,) or self.help_commands:
+ return _Distribution.handle_display_options(self, option_order)
+
+ # Stdout may be StringIO (e.g. in tests)
+ import io
+ if not isinstance(sys.stdout, io.TextIOWrapper):
+ return _Distribution.handle_display_options(self, option_order)
+
+ # Print metadata in UTF-8 no matter the platform
+ encoding = sys.stdout.encoding
+ errors = sys.stdout.errors
+ newline = sys.platform != 'win32' and '\n' or None
+ line_buffering = sys.stdout.line_buffering
+
+ sys.stdout = io.TextIOWrapper(
+ sys.stdout.detach(), 'utf-8', errors, newline, line_buffering)
+ try:
+ return _Distribution.handle_display_options(self, option_order)
+ finally:
+ sys.stdout = io.TextIOWrapper(
+ sys.stdout.detach(), encoding, errors, newline, line_buffering)
+
+
# Install it throughout the distutils
for module in distutils.dist, distutils.core, distutils.cmd:
module.Distribution = Distribution