Skip to content

Commit 65f882c

Browse files
technicalpicklesballoob
authored andcommitted
Add documentation on how to test requirements (home-assistant#811)
It's possible to test different requirement versions in development by using `pip install` to the Home Assistant's config directory's dep, and then `hass --skip-pip`
1 parent ec4f61e commit 65f882c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

source/developers/component_deps_and_reqs.markdown

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,33 @@ footer: true
1111

1212
Home Assistant allows components and platforms to specify their dependencies and requirements using the variables `DEPENDENCIES` and `REQUIREMENTS`. Both are lists that contain strings.
1313

14+
## Dependencies
15+
1416
Dependencies are other Home Assistant components that should be setup before the platform is loaded. An example is the MQTT sensor component, which requires an active connection to an MQTT broker. If Home Assistant is unable to load and setup the MQTT component, it will not setup the MQTT sensor component.
1517

1618
```python
1719
DEPENDENCIES = ['mqtt']
1820
```
1921

20-
Requirements are Python libraries that you would normally install using `pip`. If Home Assistant is unable to install the requirements or verify it is installed, the component will fail to load.
22+
## Requirements
23+
24+
Requirements are Python libraries that you would normally install using `pip` for your component. Home Assistant will try to install the requirements into the `deps` subdirectory of the Home Assistant configuration directory (`.home-assistant` by default) or verify it is already installed at startup. If that fails, the component will fail to load.
2125

2226
Requirements is a list of strings. Each entry is a pip compatible string. For example, the media player Cast platform depends on the Python package PyChromecast v0.6.12:
2327

2428
```python
2529
REQUIREMENTS = ['pychromecast==0.6.12']
2630
```
31+
32+
During development of a component, it can be useful to test against different versions of a requirement. This can be done in two steps, using pychromecast as an example:
33+
34+
* `pip install pychromecast==0.6.13 --target ~/.homeassistant/deps`
35+
* `hass --skip-pip`
36+
37+
This will use the specified version, and prevent Home Assistant from trying to override it with what is currently in `REQUIREMENTS`.
38+
39+
If you need to make changes to a requirement to support your component, it's also possible to pip install from a checkout of the requirement.
40+
41+
* `git clone https://github.com/balloob/pychromecast.git`
42+
* `pip install ./pychromecast`
43+
* `hass --skip-pip`

0 commit comments

Comments
 (0)