@@ -1046,6 +1046,35 @@ This adds a new folder ``config/pyscript_modules`` to Python's module search pat
1046
1046
modules (files ending in ``.py ``) to that folder, which will contain native python that is compiled
1047
1047
when imported (note that none of the pyscript-specific features are available).
1048
1048
1049
+ Pyscript can install required Python packages if they are missing. Depending on how you run HASS
1050
+ (eg, using a minimal Docker container) it might not be convenient to manually install Python packages
1051
+ using `pip `. If your pyscript code requires particular Python packages that are not already installed
1052
+ by HASS, add a ``requirements.txt `` file the ``<config>/pyscript `` directory. This file lists each
1053
+ required package one per line, with an optional version if you require a specific version or minimum
1054
+ version of that package, eg:
1055
+
1056
+ .. code ::
1057
+
1058
+ # this is a comment
1059
+ aiohttp
1060
+ amazing_stuff>=3.1
1061
+ another_package==5.1.2
1062
+
1063
+ Each app's or module's directory (assuming they use the directory-form of a package) can also
1064
+ contain an optional ``requirements.txt `` file:
1065
+
1066
+ - ``<config>/pyscript/modules/PACKAGE_NAME/requirements.txt ``
1067
+ - ``<config>/pyscript/apps/APP_NAME/requirements.txt ``
1068
+
1069
+ That allows you to specify the specific requirements for each pyscript module or app. If you release
1070
+ or share your module or app, all its code and requirements are self-contained, and any user can
1071
+ simply install the files in that directory and the requirements will be checked on the next
1072
+ start of HASS or reload of pyscript.
1073
+
1074
+ If a required package version differs from the installed one, no change is made since it's likely
1075
+ HASS has a requirement that pyscript should not change. In that case a warning message will be
1076
+ logged and the requirement will be skipped.
1077
+
1049
1078
Trigger Closures
1050
1079
^^^^^^^^^^^^^^^^
1051
1080
0 commit comments