Skip to content

Commit

Permalink
CentOS 7: read_text(encoding='utf-8')
Browse files Browse the repository at this point in the history
With CentOS 7 Python 3.6, running install from source with pip failed:

    sudo podman run -ti --rm centos:7
    yum -y update
    yum -y install epel-release
    yum -y install git python3 python3-devel python3-pip python3-setuptools python3-wheel
    git clone https://github.com/samuelcolvin/pydantic.git
    cd pydantic
    pip3 install .

With following error message:

    [root@c99d0585636c pydantic]# pip3 install .
    Processing /pydantic
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-91v_ixvz-build/setup.py", line 62, in <module>
            history = (THIS_DIR / 'HISTORY.md').read_text()
          File "/usr/lib64/python3.6/pathlib.py", line 1197, in read_text
            return f.read()
          File "/usr/lib64/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 14648: ordinal not in range(128)

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-91v_ixvz-build/

This PR add the required `read_text(encoding='utf-8')` for `setup.py`.

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
  • Loading branch information
hswong3i committed Jan 5, 2022
1 parent 6f46a5a commit 15287e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/3625-read_text-encoding-utf-8.md
@@ -0,0 +1 @@
Add `read_text(encoding='utf-8')` for `setup.py`
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -59,12 +59,12 @@ def extra(self):
description = 'Data validation and settings management using python type hints'
THIS_DIR = Path(__file__).resolve().parent
try:
history = (THIS_DIR / 'HISTORY.md').read_text()
history = (THIS_DIR / 'HISTORY.md').read_text(encoding='utf-8')
history = re.sub(r'#(\d+)', r'[#\1](https://github.com/samuelcolvin/pydantic/issues/\1)', history)
history = re.sub(r'( +)@([\w\-]+)', r'\1[@\2](https://github.com/\2)', history, flags=re.I)
history = re.sub('@@', '@', history)

long_description = (THIS_DIR / 'README.md').read_text() + '\n\n' + history
long_description = (THIS_DIR / 'README.md').read_text(encoding='utf-8') + '\n\n' + history
except FileNotFoundError:
long_description = description + '.\n\nSee https://pydantic-docs.helpmanual.io/ for documentation.'

Expand Down

0 comments on commit 15287e4

Please sign in to comment.