feat: Windows portability - path separators, LF line endings, UTF-8 decoding and output, msvcrt lock fallback (#152)
Files changed: - .gitattributes - CHANGES.md - VERSION - raw/CONTRACT.md - tools/README.md - tools/chemenu/commands/_util.py - tools/chemenu/commands/dist_cmd.py - tools/chemenu/commands/docs_verify.py - tools/chemenu/commands/doctor.py - tools/chemenu/commands/eval_cmd.py - tools/chemenu/commands/git_publish.py - tools/chemenu/commands/index_build.py - tools/chemenu/commands/lint.py - tools/chemenu/commands/log_append.py - tools/chemenu/commands/migrate_cmd.py - tools/chemenu/commands/provenance_cmd.py - tools/chemenu/commands/raw_cmd.py - tools/chemenu/commands/run_budget.py - tools/chemenu/commands/upstream_cmd.py - tools/chemenu/commands/version_cmd.py - tools/chemenu/commands/work_cmd.py - tools/chemenu/config.py - tools/chemenu/corpus_cache.py - tools/chemenu/filelock.py - tools/chemenu/frontmatter_io.py - tools/chemenu/kb_scan.py - tools/chemenu/kb_state.py - tools/chemenu/lint_core.py - tools/chemenu/prerequisites.py - tools/chemenu/provenance.py - tools/chemenu/search/base.py - tools/chemenu/search/ripgrep.py - tools/chemenu/telemetry/writer.py - tools/chemenu/tests/test_dist_cmd.py - tools/chemenu/tests/test_portability.py - tools/chemenu/tests/test_search.py - tools/chemenu/tests/test_trace_ingest.py - tools/chemenu/type_resolver.py - tools/chemenu/upload.py - tools/chemenu/version.py - tools/run_wikitool.py - tools/trace_ingest.py
This commit is contained in:
1 parent
9d06050338
commit
d0f08d1fba
42 files changed
+780
-89
No files matched your search
@@ -7,8 +7,27 @@ on Windows, one more thing for two launchers to get right.
|
||||
The name deliberately does not start with `wikitool.`: the Windows Python
|
||||
installer can add `.PY` to `PATHEXT`, and a `tools/wikitool.py` could then be
|
||||
what PowerShell runs for `tools/wikitool`.
|
||||
|
||||
stdout and stderr are set to UTF-8 here, the one file both launchers run. On
|
||||
Windows, Python writes into a pipe in the locale's code page (cp1252), and every
|
||||
harness reads its commands' output through a pipe: Git Bash passes the bytes on
|
||||
unchanged, and PowerShell decodes them with `[Console]::OutputEncoding`, which is
|
||||
UTF-8 under the harnesses (measured, Gitea #152). Without this, `Fußnoten` arrives
|
||||
as `Fu�noten`. A console is unaffected: Python writes to one through the Windows
|
||||
console API, whatever the encoding says. On Linux and macOS the locale is UTF-8
|
||||
already, so nothing changes there.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from chemenu.cli import main
|
||||
|
||||
|
||||
def use_utf8_output() -> None:
|
||||
for stream in (sys.stdout, sys.stderr):
|
||||
if stream is not None and hasattr(stream, "reconfigure"):
|
||||
stream.reconfigure(encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
use_utf8_output()
|
||||
main()
|
||||
Reference in new issue
Block a user