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

Function install_with_platformio

ci/compiler/platformio_cache.py:657–720  ·  view source on GitHub ↗

Install extracted content using appropriate PlatformIO command.

(
    content_path: Path, is_framework: bool, env_section: str
)

Source from the content-addressed store, hash-verified

655
656
657def install_with_platformio(
658 content_path: Path, is_framework: bool, env_section: str
659) -> bool:
660 """Install extracted content using appropriate PlatformIO command."""
661 content_path_obj = Path(content_path)
662 command_path = get_platformio_command_path(content_path_obj)
663
664 # Create a cache key based on the installation type and path
665 cache_key = f"{'framework' if is_framework else 'platform'}:{command_path}"
666
667 # Check if we've already installed this in this session
668 if cache_key in _session_installation_cache:
669 print(
670 f"Skipping installation for {env_section}: already installed in this session ({command_path})"
671 )
672 return True
673
674 if is_framework:
675 # Framework installation - use pkg install
676 command = ["pio", "pkg", "install", "--global", command_path]
677 else:
678 # Platform installation - also use pkg install (new recommended way)
679 command = ["pio", "pkg", "install", "--global", "--platform", command_path]
680
681 try:
682 print(f"Installing for {env_section}: {' '.join(command)}")
683
684 # Use RunningProcess for streaming output
685 process = RunningProcess(
686 command,
687 check=False, # We'll handle errors ourselves
688 timeout=300, # 5 minute timeout
689 env=_get_utf8_env(),
690 )
691
692 # Stream output in real-time
693 for line in process.line_iter(timeout=300):
694 line_str = line
695 print(f"PIO: {line_str}")
696
697 # Wait for completion and check result
698 process.wait()
699
700 if process.returncode == 0:
701 print("PlatformIO installation successful")
702 # Add to session cache to avoid redundant installations
703 _session_installation_cache.add(cache_key)
704 return True
705 else:
706 logger.error(
707 f"PlatformIO installation failed with return code: {process.returncode}"
708 )
709 return False
710
711 except KeyboardInterrupt as ki:
712 handle_keyboard_interrupt(ki)
713 raise
714 except Exception as e:

Callers 2

unzip_and_installFunction · 0.85
handle_zip_artifactFunction · 0.85

Calls 7

_get_utf8_envFunction · 0.85
printFunction · 0.50
waitMethod · 0.45
addMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected