Skip to content

Latest commit

Β 

History

History
154 lines (106 loc) Β· 4.85 KB

File metadata and controls

154 lines (106 loc) Β· 4.85 KB

Dependencies Overview

This custom integration uses multiple requirements files to separate different types of dependencies:

πŸ“ Files

requirements.txt - Runtime Dependencies

Purpose: Python packages needed by the integration at runtime Installed by: Home Assistant when loading the integration Also defined in: custom_components/ecole_directe/manifest.json

Note: This file is typically empty if this integration has no additional runtime dependencies beyond Home Assistant core.

Example:

aiohttp>=3.8.0
async-timeout>=4.0.0

requirements_dev.txt - Development Tools

Purpose: Additional development tools beyond what Home Assistant core provides Installed by: script/setup/bootstrap Used by: Developers, IDEs

Includes:

  • pyright - Type checker (we prefer pyright over HA's mypy for better IDE integration)
  • colorlog - Colored logging for development scripts
  • Performance tools (zlib_ng, isal) - Optional optimization packages

Note: Most development tools (ruff, pre-commit, codespell, pylint) are already provided by Home Assistant core's requirements_test.txt and requirements_test_pre_commit.txt, which are installed automatically via script/setup/bootstrap.

requirements_test.txt - Testing Framework

Purpose: Additional testing tools beyond what Home Assistant core provides Installed by: script/setup/bootstrap Used by: Test runners, CI/CD

Includes:

  • pytest-homeassistant-custom-component - Additional fixtures and utilities for custom component testing

Note: Core testing tools (pytest, pytest-asyncio, pytest-aiohttp, pytest-cov, pytest-timeout, pytest-xdist, coverage, freezegun, requests-mock, respx) are already provided by Home Assistant core's requirements_test.txt, which is installed automatically via script/setup/bootstrap.

πŸ”„ Relationship with manifest.json

manifest.json requirements field

{
  "requirements": ["aiohttp>=3.8.0"]
}
  • βœ… Runtime dependencies for end users
  • βœ… Automatically installed by Home Assistant
  • βœ… Should match requirements.txt content
  • ℹ️ Optional: If this integration doesn't need additional packages beyond Home Assistant core, you can omit this field

When to add dependencies

Add to When
manifest.json + requirements.txt Runtime dependency (end users need it)
requirements_dev.txt Development tool (linting, formatting, type checking)
requirements_test.txt Testing tool (pytest plugins, test utilities)

πŸ“ Maintenance

When you add a runtime dependency:

  1. βœ… Add to manifest.json requirements field
  2. βœ… Add to requirements.txt (same version constraint)
  3. ❌ Don't add to requirements_dev.txt or requirements_test.txt

Example:

// manifest.json
{
  "requirements": ["aiohttp>=3.8.0"]
}
# requirements.txt
aiohttp>=3.8.0

πŸš€ Bootstrap Script

The script/setup/bootstrap automatically installs dependencies from multiple sources:

From Home Assistant Core

Version: Configured via HA_VERSION in .devcontainer/devcontainer.json (currently 2026.12.3)

  1. Runtime dependencies (requirements_all.txt)

    • All packages that Home Assistant integrations might need
    • Includes aiohttp, async-timeout, and hundreds of other packages
  2. Test dependencies (requirements_test.txt)

    • pytest and all pytest plugins (pytest-asyncio, pytest-aiohttp, pytest-cov, pytest-timeout, pytest-xdist)
    • Testing utilities (coverage, freezegun, requests-mock, respx)
    • mypy-dev for type checking (we use pyright instead)
  3. Pre-commit dependencies (requirements_test_pre_commit.txt)

    • ruff (linting and formatting)
    • codespell (spell checking)
    • pre-commit (hook framework)
    • pylint (linting)
  4. Home Assistant core (homeassistant==$HA_VERSION)

    • The full Home Assistant installation

From This Project

  • requirements_dev.txt - Additional development tools this project uses (pyright, colorlog, performance packages)
  • requirements_test.txt - Custom component testing utilities
  • requirements.txt - This integration's runtime dependencies (if any)

This approach means this project only needs to maintain a minimal set of dependencies that are specific to this integration, while leveraging the comprehensive dependency management from Home Assistant core.

πŸ” hacs.json vs manifest.json

hacs.json

{
  "name": "Integration Name",
  "homeassistant": "2026.11.0",
  "hacs": "2.0.5"
}
  • ❌ No Python dependencies - only metadata
  • βœ… Minimum Home Assistant version
  • βœ… Minimum HACS version

manifest.json

{
  "requirements": ["package>=1.0.0"]
}
  • βœ… Python package dependencies
  • βœ… Installed by Home Assistant

No duplication needed! hacs.json only contains version constraints for HA/HACS, not Python packages.