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

Function get_required_packages

ci/util/package_validator.py:59–153  ·  view source on GitHub ↗

Extract required packages from platformio.ini for environment. Args: project_dir: PlatformIO project directory environment: Environment name Returns: List of required package directory names (e.g., ["framework-arduinoespressif32@3.20014.231124"])

(project_dir: Path, environment: str)

Source from the content-addressed store, hash-verified

57
58
59def get_required_packages(project_dir: Path, environment: str) -> list[str]:
60 """Extract required packages from platformio.ini for environment.
61
62 Args:
63 project_dir: PlatformIO project directory
64 environment: Environment name
65
66 Returns:
67 List of required package directory names (e.g., ["framework-arduinoespressif32@3.20014.231124"])
68 """
69 platformio_ini = project_dir / "platformio.ini"
70 if not platformio_ini.exists():
71 return []
72
73 # Parse platformio.ini (simple regex-based approach)
74 # This is not a full INI parser but works for our needs
75 try:
76 content = platformio_ini.read_text()
77
78 # Find environment section
79 env_section_pattern = rf"\[env:{re.escape(environment)}\]"
80 env_match = re.search(env_section_pattern, content)
81 if not env_match:
82 return []
83
84 # Extract platform from environment section
85 # Format: platform = espressif32
86 platform_pattern = r"platform\s*=\s*(\S+)"
87 platform_match = re.search(platform_pattern, content[env_match.start() :])
88
89 if not platform_match:
90 return []
91
92 platform = platform_match.group(1)
93
94 # Map platform to package names (heuristic-based)
95 # PlatformIO packages follow patterns like:
96 # - toolchain-<platform>
97 # - framework-<platform>
98 # - tool-<name>
99 package_prefixes: list[str] = []
100
101 if "espressif32" in platform:
102 package_prefixes.extend(
103 [
104 "framework-arduinoespressif32",
105 "toolchain-xtensa-esp32",
106 "tool-esptoolpy",
107 ]
108 )
109 elif "espressif8266" in platform:
110 package_prefixes.extend(
111 [
112 "framework-arduinoespressif8266",
113 "toolchain-xtensa",
114 "tool-esptoolpy",
115 ]
116 )

Callers 1

check_all_packagesFunction · 0.85

Calls 3

startMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected