paylogic / py2deb

Python to Debian package converter
https://py2deb.readthedocs.org/
MIT License
279 stars 30 forks source link

UnicodeDecodeError when attrs in requirements.txt #19

Open local-minimum opened 6 years ago

local-minimum commented 6 years ago

I'm attempting to use py2deb for a python 3 project and I run into the following error:

root@547626b5656f:/test# py2deb -r /tmp -- -r requirements.txt 
2018-06-26 13:00:01 547626b5656f pip_accel[7224] INFO Unpacking distribution(s) ..
2018-06-26 13:00:01 547626b5656f pip_accel[7224] INFO Executing command: pip install --download=/var/cache/pip-accel/sources --find-links=file:///var/cache/pip-accel/sources --no-binary=:all: --no-index --no-clean --build-directory=/tmp/pip-accel-build-dir-pfxjgqit --ignore-installed -r requirements.txt
2018-06-26 13:00:01 547626b5656f pip.commands.install[7224] INFO Ignoring indexes: https://pypi.python.org/simple
2018-06-26 13:00:01 547626b5656f pip.req.req_set[7224] INFO Collecting attrs==18.1.0 (from -r requirements.txt (line 1))
2018-06-26 13:00:01 547626b5656f pip.download[7224] INFO File was already downloaded /var/cache/pip-accel/sources/attrs-18.1.0.tar.gz
2018-06-26 13:00:02 547626b5656f pip.commands.install[7224] INFO Successfully downloaded attrs
2018-06-26 13:00:02 547626b5656f pip_accel[7224] INFO Finished unpacking 1 distribution in 0.32 seconds.
2018-06-26 13:00:02 547626b5656f py2deb.cli[7224] ERROR Caught an unhandled exception!
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/pkginfo/sdist.py", line 70, in read
    return f.read()
  File "/usr/lib/python3.5/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 4233: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/py2deb/cli.py", line 200, in main
    archives, relationships = converter.convert(arguments)
  File "/usr/local/lib/python3.5/dist-packages/py2deb/converter.py", line 546, in convert
    archive = package.convert()
  File "/usr/local/lib/python3.5/dist-packages/py2deb/package.py", line 415, in convert
    maintainer=self.debian_maintainer,
  File "/usr/local/lib/python3.5/dist-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.5/dist-packages/py2deb/package.py", line 130, in debian_maintainer
    maintainer = self.metadata.maintainer
  File "/usr/local/lib/python3.5/dist-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.5/dist-packages/py2deb/package.py", line 169, in metadata
    return UnpackedSDist(self.find_egg_info_file())
  File "/usr/local/lib/python3.5/dist-packages/pkginfo/sdist.py", line 65, in __init__
    filename, metadata_version=metadata_version)
  File "/usr/local/lib/python3.5/dist-packages/pkginfo/sdist.py", line 12, in __init__
    self.extractMetadata()
  File "/usr/local/lib/python3.5/dist-packages/pkginfo/distribution.py", line 108, in extractMetadata
    data = self.read()
  File "/usr/local/lib/python3.5/dist-packages/pkginfo/sdist.py", line 73, in read
    % (self.filename, e))
ValueError: Could not load /tmp/pip-accel-build-dir-pfxjgqit/attrs/pip-egg-info/attrs.egg-info/ as an unpacked sdist: 'ascii' codec can't decode byte 0xe2 in position 4233: ordinal not in range(128)

To reproduce make an empty project that just has the requirements.txt and no python code at all.

The contents of requirements.txt:

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --output-file requirements.txt requirements.in
#
attrs==18.1.0

And for reference:

root@547626b5656f:/test# pip -V
pip 7.1.2 from /usr/local/lib/python3.5/dist-packages (python 3.5)

Attempting the same but for one of the other requirements such as pymongo==3.5.1 works fine.

This was run inside an Ubuntu 16.04 and a Ubuntu 18.04 docker image.

The build/install steps inside the container:

mkdir builds
apt update
apt install -y python3-pip dpkg-dev fakeroot libpq-dev
pip3 install py2deb
py2deb -r ./builds -- -r requirements.txt
heschlie commented 6 years ago

I seem to be getting the same error when idna is a requirement:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pkginfo/sdist.py", line 70, in read
    return f.read()
  File "/usr/lib/python3.6/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 609: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/py2deb/cli.py", line 200, in main
    archives, relationships = converter.convert(arguments)
  File "/usr/local/lib/python3.6/dist-packages/py2deb/converter.py", line 546, in convert
    archive = package.convert()
  File "/usr/local/lib/python3.6/dist-packages/py2deb/package.py", line 415, in convert
    maintainer=self.debian_maintainer,
  File "/usr/local/lib/python3.6/dist-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.6/dist-packages/py2deb/package.py", line 130, in debian_maintainer
    maintainer = self.metadata.maintainer
  File "/usr/local/lib/python3.6/dist-packages/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.6/dist-packages/py2deb/package.py", line 169, in metadata
    return UnpackedSDist(self.find_egg_info_file())
  File "/usr/local/lib/python3.6/dist-packages/pkginfo/sdist.py", line 65, in __init__
    filename, metadata_version=metadata_version)
  File "/usr/local/lib/python3.6/dist-packages/pkginfo/sdist.py", line 12, in __init__
    self.extractMetadata()
  File "/usr/local/lib/python3.6/dist-packages/pkginfo/distribution.py", line 108, in extractMetadata
    data = self.read()
  File "/usr/local/lib/python3.6/dist-packages/pkginfo/sdist.py", line 73, in read
    % (self.filename, e))
ValueError: Could not load /tmp/pip-accel-build-dir-8u96bxpo/idna/pip-egg-info/idna.egg-info/ as an unpacked sdist: 'ascii' codec can't decode byte 0xe2 in position 609: ordinal not in range(128)