[Distutils] Encoding error installing my own package from PyPI

Lele Gaifax lele at metapensiero.it
Thu Dec 12 21:11:36 CET 2013


Hi all,

for the first time I'm trying to use PyPI to distribute one of my
packages, and I'm having encoding problems with the package metadata
when I install it in a Python 3.3 environment using pip 1.4.1.

I tried to google around, but didn't find any definitive solution.

The package setup.py[1] builds the long_description reading and
concatenating the content of two files, respectively README.rst and
CHANGES.rst, both encoded in UTF-8.

A first attempt used a plain open() call to read the files failed and I
thought to understand the reason, as CHANGES.rst effectively contains a
few non-ascii characters. I then used codecs.open() with an explicit
utf-8 encoding, but that too fails, although in a different place:

  Downloading/unpacking metapensiero.sqlalchemy.proxy==1.9.6 (from -r requirements.txt (line 15))
    Downloading metapensiero.sqlalchemy.proxy-1.9.6.tar.gz
    Running setup.py egg_info for package metapensiero.sqlalchemy.proxy

  Cleaning up...
  Exception:
  Traceback (most recent call last):
    File "/opt/python333/lib/python3.3/site-packages/pip/basecommand.py", line 134, in main
      status = self.run(options, args)
    File "/opt/python333/lib/python3.3/site-packages/pip/commands/install.py", line 236, in run
      requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
    File "/opt/python333/lib/python3.3/site-packages/pip/req.py", line 1139, in prepare_files
      req_to_install.assert_source_matches_version()
    File "/opt/python333/lib/python3.3/site-packages/pip/req.py", line 394, in assert_source_matches_version
      version = self.installed_version
    File "/opt/python333/lib/python3.3/site-packages/pip/req.py", line 390, in installed_version
      return self.pkg_info()['version']
    File "/opt/python333/lib/python3.3/site-packages/pip/req.py", line 357, in pkg_info
      data = self.egg_info_data('PKG-INFO')
    File "/opt/python333/lib/python3.3/site-packages/pip/req.py", line 297, in egg_info_data
      data = fp.read()
    File "/opt/python333/lib/python3.3/encodings/ascii.py", line 26, in decode
      return codecs.ascii_decode(input, self.errors)[0]
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3072: ordinal not in range(128)

and this time I cannot see a way out, as egg_info_data() does

  fp = open(filename, 'r')
  data = fp.read()

to read PKG-INFO content, that AFAICT was encoded in utf-8 by the sdist
command...

So the question is: how can I solve the issue? Should I make sure that
all the meta data information is plain ASCII (which of course I can do
quite easily), or am I doing something wrong?

Thanks in advance for any hint,
ciao, lele.

[1] https://bitbucket.org/lele/metapensiero.sqlalchemy.proxy/src/608bf172973986d003e953ba4e46448363f60e44/setup.py?at=master
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.



More information about the Distutils-SIG mailing list