diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-05-03 11:46:21 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-05-03 11:46:21 -0400 |
commit | 36addf1ea62cde1ab5884f91e18ac4d1954529cc (patch) | |
tree | 668f907aba4c4e2afefef2bce55b11e49d362c16 | |
parent | 9551d30ebf4e6c735504c59673a90ea837e05345 (diff) | |
download | external_python_setuptools-36addf1ea62cde1ab5884f91e18ac4d1954529cc.tar.gz external_python_setuptools-36addf1ea62cde1ab5884f91e18ac4d1954529cc.tar.bz2 external_python_setuptools-36addf1ea62cde1ab5884f91e18ac4d1954529cc.zip |
Monkey-patch the write_pkg_info method on Python 3.1 DistributionMetadata. Fixes #197
-rw-r--r-- | CHANGES.txt | 7 | ||||
-rw-r--r-- | setuptools/dist.py | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 1c54ea5e..cf8b0898 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,13 @@ CHANGES ======= +--- +3.5 +--- + +* Issue #197: On Python 3.1, PKG-INFO is now saved in a UTF-8 encoding instead + of ``sys.getpreferredencoding`` to match the behavior on Python 2.6-3.4. + ----- 3.4.4 ----- diff --git a/setuptools/dist.py b/setuptools/dist.py index 0801ae74..59a89236 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -7,6 +7,7 @@ import warnings import distutils.log import distutils.core import distutils.cmd +import distutils.dist from distutils.core import Distribution as _Distribution from distutils.errors import (DistutilsOptionError, DistutilsPlatformError, DistutilsSetupError) @@ -31,6 +32,26 @@ def _get_unpatched(cls): _Distribution = _get_unpatched(_Distribution) +def _patch_distribution_metadata_write_pkg_info(): + """ + Workaround issue #197 - Python 3.1 uses an environment-local encoding to + save the pkg_info. Monkey-patch its write_pkg_info method to correct + this undesirable behavior. + """ + if sys.version_info[:2] != (3,1): + return + + # from Python 3.4 + def write_pkg_info(self, base_dir): + """Write the PKG-INFO file into the release tree. + """ + with open(os.path.join(base_dir, 'PKG-INFO'), 'w', + encoding='UTF-8') as pkg_info: + self.write_pkg_file(pkg_info) + + distutils.dist.DistributionMetadata.write_pkg_info = write_pkg_info +_patch_distribution_metadata_write_pkg_info() + sequence = tuple, list def check_importable(dist, attr, value): |