Request: Pre-install System Dependencies (e.g., `cairo`) for Enhanced Integration Support

Hi everyone,
I’m requesting consideration for pre-installing certain system-level dependencies within the Home Assistant Core. Specifically, dependencies like cairo (and potentially others) would greatly benefit developers and users of custom integrations.
Background:
I’ve developed a custom integration (GitHub - gaojiafamily/ha-trem2: TREM 2 for HA Integration) that relies on the cairo library for rendering graphics. Currently, users need to manually install this dependency, which can be a barrier to entry.
Proposed Solution:
Including these system dependencies directly in the Home Assistant Core would streamline the user experience and ensure compatibility across different environments.
Benefits:
• Simplified Setup: Reduces the need for manual configuration steps, making integrations easier to use.
• Improved Compatibility: Ensures that integrations relying on these dependencies work out-of-the-box.
• Developer Productivity: Simplifies the development and testing process for custom components.
Technical Details:
cairo is a widely used library for graphics rendering.
• It’s relatively lightweight and has minimal impact on the core size.
• Pre-installing it in the base image ensures consistency across environments.
Potential Considerations:
• There may be a slight increase in the core size.
• The dependencies would need to be maintained and updated as needed.
I believe that pre-installing these dependencies would significantly enhance the Home Assistant ecosystem and encourage the development of more sophisticated integrations.
Thank you for considering this request. I’m open to discussing this further and providing any additional information needed.

In the case of Python modules that your integration would demand, I understand that the PyCairo module requires the Cairo library on the system. And if it does not find the library on the system, then the PyCairo Python module is worthless. Is that correct?

This tends to be a fairly general problem with many Python extensions that depend on C libraries. There is no solution that allows a Python module to request that the operating system install the library that it needs. Additionally, there exists no mechanism that allows integrations to request Python’s or Home Assistant to install system libraries because Home Assistant itself is not able to install system libraries. About the only way I can see that such a thing could be fulfilled is by shipping an add-on, which in turn will install a totally independent container outside of the home assistant operating system, where you could ship the Cairo library. But obviously that’s not going to make the Cairo library available to your integration. Finally, installing any number of dependencies on the base operating system, just on the off chance that integrations which do not ship with Home Assistant might need them, is going to cause the operating system itself to bloat, it does not scale, and it would only work with HAOS.

Tough spot!

1 Like

Thank you for taking the time to respond to my question.

I need Cairo because my integration relies on cairosvg, which converts SVG files to PNG format, enabling ImageEntity to display properly.
While add-on might potentially fulfill my requirements, I still prefer the integration method.
Alternatively, are there other ways to allow SVG files to display directly in ImageEntity?

An add-on wouldn’t solve your problem — at least not with a hodgepodge of glue — because your integration code runs in the Home Assistant container, not in the add-on container.

My take on this? You could create a custom card that displays an SVG served by Home Assistant’s API, or make fixes to the Picture card to support SVG natively. I think the second avenue is probably the best since adding SVG support to the Picture card would help everyone.

I’ve decided to cancel the use of SVG images and explore alternative solutions. For example, I plan to deploy a subprogram on a VPS to handle and output PNG images.
This approach avoids relying on system-level Cairo libraries while providing more flexibility in managing the image generation process.

If anyone has other suggestions or relevant experiences to share, feel free to discuss!

But browsers support SVG natively…