Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use container mount for custom_components inside /config to avoid PYTHONPATH #205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bj00rn
Copy link

@bj00rn bj00rn commented Oct 31, 2024

Use container mount instead of relying on PYTHONPATH for integration to be found by hass.

Allow integration to be found by hass without polluting module search path.

It's quite common (good practice or not) in the wild for integrations and their lib requirement to share the same package name. Adding custom_components to PYTHONPATH does not support this scenario. Integrations that are currently based on this template will stop working if brought to sync with this repo. The error thrown is confusing since the requirement is installed by hass but will resolve to the integration package itself.

fixes #130

Allow integration to be found by HASS without polluting module search path
## This let's us have the structure we want <root>/custom_components/integration_blueprint
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this makes it only work in a devcontainer.
This repo exist as a starting point, not to catch every possible edge case out there.

If you want to showcase that, this repo is better.
https://github.com/home-assistant/example-custom-config

If you just want to share how you do things, there is this section on the forums:
https://community.home-assistant.io/c/community-guides/51

@bj00rn bj00rn force-pushed the chore/use-mount-for-custom_components branch from a794842 to 4fe9c06 Compare October 31, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integration cannot have the same name as package
2 participants