{"library":"platformio","title":"PlatformIO","description":"PlatformIO is a powerful, open-source ecosystem for embedded software development, offering a collaborative environment that embraces declarative principles, test-driven methodologies, and modern toolchains. It features a cross-platform build system, unified package manager, and supports various development platforms and frameworks for microcontrollers and IoT devices. The current stable version is 6.1.19, with active and frequent minor updates.","language":"python","status":"active","last_verified":"Sun Apr 12","install":{"commands":["pip install platformio"],"cli":{"name":"pio","version":"PlatformIO Core, version 6.1.19"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport os\n\n# Create a dummy project directory\nproject_dir = \"my_pio_project\"\nos.makedirs(project_dir, exist_ok=True)\nos.chdir(project_dir)\n\ntry:\n    # Initialize a PlatformIO project for a common board (e.g., esp32dev)\n    # This will download necessary frameworks and tools into the project's .pio folder\n    print(f\"Initializing PlatformIO project in {os.getcwd()}...\")\n    result = subprocess.run(\n        [\"pio\", \"project\", \"init\", \"--board\", \"esp32dev\"],\n        capture_output=True, text=True, check=True\n    )\n    print(\"\\n--- pio project init Output ---\")\n    print(result.stdout)\n    if result.stderr:\n        print(\"\\n--- pio project init Errors ---\")\n        print(result.stderr)\n\n    # List installed packages within the project\n    print(\"\\nListing installed packages...\")\n    result = subprocess.run(\n        [\"pio\", \"pkg\", \"list\"],\n        capture_output=True, text=True, check=True\n    )\n    print(\"\\n--- pio pkg list Output ---\")\n    print(result.stdout)\n\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error executing PlatformIO command: {e}\")\n    print(f\"Stdout: {e.stdout}\")\n    print(f\"Stderr: {e.stderr}\")\nexcept FileNotFoundError:\n    print(\"Error: 'pio' command not found. Ensure PlatformIO Core CLI is installed and in your PATH.\")\nfinally:\n    # Clean up the created project directory\n    os.chdir(\"..\")\n    # In a real scenario, you might want to remove the directory:\n    # import shutil\n    # shutil.rmtree(project_dir)\n    print(f\"\\nQuickstart finished. Project directory: {project_dir}\")","lang":"python","description":"This quickstart demonstrates how to programmatically interact with PlatformIO Core CLI from Python. It initializes a new PlatformIO project for an `esp32dev` board and then lists the packages installed for that project. This interaction pattern is common for integrating PlatformIO into automation scripts or custom applications, as PlatformIO's primary interface is its command-line tool (`pio`). Ensure 'pio' is in your system's PATH.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}