I've been trying to figure out how to setup Unicode long descriptions
in setup.py
. I often use Unicode in my README
files and then use
the contents of the README
to set the long description with
something like:
…
_this_dir = os.path.dirname(__file__)
…
setup(
…
long_description=codecs.open(
os.path.join(_this_dir, 'README'), 'r', encoding='utf-8').read(),
)
This crashed in Python 2.7 with a UnicodeDecodeError
when I tried to
register the package on PyPI. The problem is that packages are
checked before registration to avoid being registered with broken
metadata, and Unicode handling was broken in distutils (bug
13114). Unfortunately, there haven't yet been Python
releases containing the fixes (applied in October 2011).
How do you work around this issue until get a more recent Python 2.7? Just use Python 3.x, where Unicode handling is much cleaner. You may need hide Python-3-incompatible code inside:
if _sys.version_info < (3,0):
blocks, but you shouldn't be pulling in huge amounts of code for
setup.py
anyway.