Skip to content

fix: read README.md and requirements as utf-8 in setup.py - #599

Open
adhavan18 wants to merge 1 commit into
roboflow:mainfrom
adhavan18:fix/setup-read-utf8
Open

adhavan18 wants to merge 1 commit into
roboflow:mainfrom
adhavan18:fix/setup-read-utf8

Conversation

@adhavan18

Copy link
Copy Markdown

What does this PR do?

installing from source on windows fails unless utf-8 mode is on:

> pip install -e .        (or pip install git+https://github.com/roboflow/roboflow-python)
...
  File "<string>", line 14, in <module>
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 8265: character maps to <undefined>

setup.py reads README.md without an encoding, so on a default windows install it's decoded as cp1252, and the readme now has a 🏆 (f0 9f 8f 86) that cp1252 can't decode. the wheel on pypi is built on linux so pip install roboflow is fine, this only hits source installs: editable dev setups, git+ installs and building the sdist on windows.

this is probably also why test.yml sets PYTHONUTF8: 1, the windows jobs run pip install ".[dev]".

changes

  • encoding="utf-8" on the three reads in setup.py and the same three in setup_slim.py

testing

windows 11, python 3.12, utf-8 mode off (sys.flags.utf8_mode == 0), clean venv, uv pip install --no-deps --reinstall .:

  • main (6e10039): fails with the error above
  • this branch: installs

notes

  • left PYTHONUTF8: 1 in ci alone. dropping it would make the windows jobs cover the default encoding, but some tests read fixtures without an encoding too, so that's a separate change
  • no changelog entry since it only touches packaging, happy to add one

README.md has non-cp1252 characters (the trophy emoji), so building from
source on windows without utf-8 mode failed with UnicodeDecodeError, e.g.
pip install -e . or pip install git+https://github.com/roboflow/roboflow-python.

This branch has not been deployed

No deployments
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.

1 participant