Skip to content

Specified encoding in setup.py calls of open() #3137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2021
Merged

Specified encoding in setup.py calls of open() #3137

merged 2 commits into from
Jul 21, 2021

Conversation

ka-bo
Copy link
Contributor

@ka-bo ka-bo commented Jul 20, 2021

Description

The files of the project are encoded in UTF-8, yet the opening of files in the setup.py does not specify this encoding. When trying to install on a system with a non-UTF-8 locale using pip install pybind11/. the process fails with the the following error:

Processing /pybind11
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-mi6rymcm-build/setup.py", line 74, in <module>
        matches = dict(VERSION_REGEX.findall(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 16164: ordinal not in range(128)

Specifying that the files should be opened using UTF-8 encoding fixes the problem.

Suggested changelog entry:

Specified UTF8-encoding in setup.py calls of open()

Copy link
Collaborator

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the right syntax for Python2 @ka-bo

@ka-bo
Copy link
Contributor Author

ka-bo commented Jul 21, 2021

Thanks for the hint @henryiii, exactly that exec seemed to be the problem.

The updated version should work now.

@ka-bo ka-bo requested a review from Skylion007 July 21, 2021 08:56
@Skylion007 Skylion007 merged commit e58c689 into pybind:master Jul 21, 2021
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jul 21, 2021
henryiii pushed a commit to henryiii/pybind11 that referenced this pull request Jul 29, 2021
* Specified encoding in setup.py calls of open()

* Fix for Python2

Co-authored-by: Karsten Bock <[email protected]>
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants