mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Fix the Windows build by printing content logs as UTF-8.
The content step crashed on cp1252 because the summary line contains Czech characters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
648cb8cad3
commit
51101a93e2
3 changed files with 19 additions and 0 deletions
|
|
@ -93,6 +93,8 @@ dependencies {
|
||||||
|
|
||||||
val buildContent = tasks.register<Exec>("buildContent") {
|
val buildContent = tasks.register<Exec>("buildContent") {
|
||||||
workingDir = rootProject.projectDir.parentFile
|
workingDir = rootProject.projectDir.parentFile
|
||||||
|
environment("PYTHONUTF8", "1")
|
||||||
|
environment("PYTHONIOENCODING", "utf-8")
|
||||||
commandLine("python3", "scripts/build-content.py")
|
commandLine("python3", "scripts/build-content.py")
|
||||||
inputs.dir(rootProject.projectDir.parentFile.resolve("content"))
|
inputs.dir(rootProject.projectDir.parentFile.resolve("content"))
|
||||||
inputs.file(rootProject.projectDir.parentFile.resolve("scripts/build-content.py"))
|
inputs.file(rootProject.projectDir.parentFile.resolve("scripts/build-content.py"))
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ val buildContent = tasks.register<Exec>("buildContent") {
|
||||||
workingDir = repoRoot
|
workingDir = repoRoot
|
||||||
val python = System.getenv("PYTHON")?.takeIf { it.isNotBlank() }
|
val python = System.getenv("PYTHON")?.takeIf { it.isNotBlank() }
|
||||||
?: if (System.getProperty("os.name").startsWith("Windows")) "python" else "python3"
|
?: if (System.getProperty("os.name").startsWith("Windows")) "python" else "python3"
|
||||||
|
environment("PYTHONUTF8", "1")
|
||||||
|
environment("PYTHONIOENCODING", "utf-8")
|
||||||
commandLine(python, "scripts/build-content.py", "--out", out.path)
|
commandLine(python, "scripts/build-content.py", "--out", out.path)
|
||||||
inputs.dir(repoRoot.resolve("content"))
|
inputs.dir(repoRoot.resolve("content"))
|
||||||
inputs.file(repoRoot.resolve("scripts/build-content.py"))
|
inputs.file(repoRoot.resolve("scripts/build-content.py"))
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,21 @@ import unicodedata
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _force_utf8_stdio() -> None:
|
||||||
|
"""Windows defaults stdout to cp1252, which cannot print Czech logs."""
|
||||||
|
for stream in (sys.stdout, sys.stderr):
|
||||||
|
reconfigure = getattr(stream, "reconfigure", None)
|
||||||
|
if reconfigure is None:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
reconfigure(encoding="utf-8", errors="replace")
|
||||||
|
except (OSError, ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
_force_utf8_stdio()
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
CONTENT = ROOT / "content"
|
CONTENT = ROOT / "content"
|
||||||
OUTS = [ROOT / "android" / "app" / "src" / "main" / "assets" / "content.json"]
|
OUTS = [ROOT / "android" / "app" / "src" / "main" / "assets" / "content.json"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue