MCPcopy Create free account
hub / github.com/FastLED/FastLED / get_clean_windows_env

Function get_clean_windows_env

ci/util/pio_package_daemon.py:286–358  ·  view source on GitHub ↗

Create a clean Windows environment without Git Bash indicators. This removes Git Bash environment variables (MSYSTEM, TERM, SHELL, etc.) that might cause ESP-IDF tooling to detect Git Bash and abort installation. Returns: Clean environment dict suitable for running pio via cmd.

()

Source from the content-addressed store, hash-verified

284
285
286def get_clean_windows_env() -> dict[str, str]:
287 """Create a clean Windows environment without Git Bash indicators.
288
289 This removes Git Bash environment variables (MSYSTEM, TERM, SHELL, etc.)
290 that might cause ESP-IDF tooling to detect Git Bash and abort installation.
291
292 Returns:
293 Clean environment dict suitable for running pio via cmd.exe
294 """
295 # Start with minimal system environment
296 clean_env: dict[str, str] = {}
297
298 # Git Bash environment variables to EXCLUDE (these cause ESP-IDF to abort)
299 git_bash_vars = {
300 "MSYSTEM", # MSYS2/Git Bash indicator
301 "MSYSTEM_CARCH",
302 "MSYSTEM_CHOST",
303 "MSYSTEM_PREFIX",
304 "MINGW_CHOST",
305 "MINGW_PACKAGE_PREFIX",
306 "MINGW_PREFIX",
307 "TERM", # Often set to 'xterm' in Git Bash
308 "SHELL", # Points to bash.exe in Git Bash
309 "BASH",
310 "BASH_ENV",
311 "SHLVL",
312 "OLDPWD",
313 "LS_COLORS",
314 "ACLOCAL_PATH",
315 "MANPATH",
316 "INFOPATH",
317 "PKG_CONFIG_PATH",
318 "ORIGINAL_PATH",
319 "MSYS",
320 }
321
322 # Copy safe environment variables from parent
323 for key, value in os.environ.items():
324 # Skip Git Bash indicators
325 if key in git_bash_vars:
326 continue
327
328 # Skip variables starting with MSYS or MINGW prefixes
329 if key.startswith(("MSYS", "MINGW", "BASH_")):
330 continue
331
332 # Keep important system variables
333 clean_env[key] = value
334
335 # Ensure critical variables are set for Windows
336 if platform.system() == "Windows":
337 # Force UTF-8 encoding
338 clean_env["PYTHONIOENCODING"] = "utf-8:replace"
339 clean_env["PYTHONUTF8"] = "1"
340
341 # Set COMSPEC to cmd.exe if not already set
342 if "COMSPEC" not in clean_env:
343 clean_env["COMSPEC"] = "C:\\Windows\\System32\\cmd.exe"

Callers 1

Calls 4

itemsMethod · 0.80
debugMethod · 0.80
getMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected