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

Function packages_already_installed

ci/util/pio_package_client.py:180–217  ·  view source on GitHub ↗

Quick check if packages are already installed. This is a fast-path optimization to skip daemon interaction when packages are already present. Args: project_dir: PlatformIO project directory environment: PlatformIO environment name (or None for all) Returns:

(project_dir: Path, environment: str | None)

Source from the content-addressed store, hash-verified

178
179
180def packages_already_installed(project_dir: Path, environment: str | None) -> bool:
181 """Quick check if packages are already installed.
182
183 This is a fast-path optimization to skip daemon interaction when
184 packages are already present.
185
186 Args:
187 project_dir: PlatformIO project directory
188 environment: PlatformIO environment name (or None for all)
189
190 Returns:
191 True if packages appear to be installed, False otherwise
192 """
193 # Run quick PlatformIO check
194 # We use 'pio pkg list' which is fast when packages are installed
195 try:
196 cmd = ["pio", "pkg", "list", "--project-dir", str(project_dir)]
197 if environment:
198 cmd.extend(["--environment", environment])
199
200 result = subprocess.run(
201 cmd,
202 capture_output=True,
203 text=True,
204 timeout=10,
205 )
206
207 # If command succeeds and has output, packages are likely installed
208 # PlatformIO will trigger install if needed, but we want to avoid that
209 # So we just check if the command runs successfully
210 return result.returncode == 0
211
212 except KeyboardInterrupt as ki:
213 handle_keyboard_interrupt(ki)
214 raise
215 except Exception:
216 # If check fails, assume packages need installation
217 return False
218
219
220def ensure_packages_installed(

Callers 1

Calls 2

runMethod · 0.45

Tested by

no test coverage detected