Get environment for Docker commands, handling Git Bash/MSYS2 path conversion.
()
| 89 | |
| 90 | |
| 91 | def get_docker_env() -> dict[str, str]: |
| 92 | """Get environment for Docker commands, handling Git Bash/MSYS2 path conversion.""" |
| 93 | env = os.environ.copy() |
| 94 | # Set UTF-8 encoding environment variables for Windows |
| 95 | env["PYTHONIOENCODING"] = "utf-8" |
| 96 | env["PYTHONUTF8"] = "1" |
| 97 | # Only set MSYS_NO_PATHCONV if we're in a Git Bash/MSYS2 environment |
| 98 | if ( |
| 99 | "MSYSTEM" in os.environ |
| 100 | or os.environ.get("TERM") == "xterm" |
| 101 | or "bash.exe" in os.environ.get("SHELL", "") |
| 102 | ): |
| 103 | env["MSYS_NO_PATHCONV"] = "1" |
| 104 | return env |
| 105 | |
| 106 | |
| 107 | def run_subprocess_safe( |
no test coverage detected