manrajgrover / halo

💫 Beautiful spinners for terminal, IPython and Jupyter
MIT License
2.86k stars 148 forks source link

Bug: Halo install requires UTF-8 locale to be set #124

Closed adamtheturtle closed 5 years ago

adamtheturtle commented 5 years ago

Thank you for the software. I recently added it to an internal tool and now am installing Halo on CI.

I hit this issue when installing Halo on some CI machines. Some systems do not have UTF-8 set as the default locale. Halo does not work in these cases. This is because "README.md" is a UTF-8 encoded file, but open() uses the default encoding.

One way to reproduce this is with Docker:

$ docker run -it ubuntu /bin/bash

# apt-get -qq update
# apt-get -qq install -y python3 python3-pip
# python3 -c 'import locale; print(locale.getpreferredencoding(False))'
ANSI_X3.4-1968 # << Note, this is not UTF-8
# pip3 install halo
Collecting halo
  Downloading https://files.pythonhosted.org/packages/d5/14/e2b6180addc38803b8170afb798a06c2e407e79efb8e14591e8820e718d3/halo-0.0.23.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-5gyk692_/halo/setup.py", line 10, in <module>
        long_description = infile.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 3604: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5gyk692_/halo