Skip to content

Commit e9ef3e9

Browse files
fgreggpre-commit-ci[bot]mayeut
authored
fix: open setup.py as utf-8 in get_requires_python_str (#977)
* open setup.py as utf-8 in get_requires_python_str fix #976 * update test for UTF-8 setup.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: mayeut <[email protected]>
1 parent d6bede5 commit e9ef3e9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cibuildwheel/projectfiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_requires_python_str(package_dir: Path) -> Optional[str]:
7070
pass
7171

7272
try:
73-
with (package_dir / "setup.py").open() as f2:
73+
with (package_dir / "setup.py").open(encoding="utf8") as f2:
7474
return setup_py_python_requires(f2.read())
7575
except FileNotFoundError:
7676
pass

unit_test/projectfiles_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_read_setup_py_simple(tmp_path):
2525

2626

2727
def test_read_setup_py_full(tmp_path):
28-
with open(tmp_path / "setup.py", "w") as f:
28+
with open(tmp_path / "setup.py", "w", encoding="utf8") as f:
2929
f.write(
3030
dedent(
3131
"""
@@ -35,6 +35,7 @@ def test_read_setup_py_full(tmp_path):
3535
3636
setuptools.setup(
3737
name = "hello",
38+
description = "≥“”ü",
3839
other = 23,
3940
example = ["item", "other"],
4041
python_requires = "1.24",
@@ -43,7 +44,9 @@ def test_read_setup_py_full(tmp_path):
4344
)
4445
)
4546

46-
assert setup_py_python_requires(tmp_path.joinpath("setup.py").read_text()) == "1.24"
47+
assert (
48+
setup_py_python_requires(tmp_path.joinpath("setup.py").read_text(encoding="utf8")) == "1.24"
49+
)
4750
assert get_requires_python_str(tmp_path) == "1.24"
4851

4952

0 commit comments

Comments
 (0)