Generate requirements_* from manifests (#22718)
## Description: Generate requirements_* from manifests (if present). If not, fallback to the current approach of reading `REQUIREMENTS` from the module attribute. I disabled exploring the children of the `homeassistant.components.*` packages since that will just add a dependency (from the manifest) due to each of the python files in the package. Just having one for the top level package should be sufficient. **Related issue (if applicable):** relates to #22700 ## Checklist: - [x] The code change is tested and works locally. - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass** - [x] There is no commented out code in this PR. [ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard/__init__.py#L14 [ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard/__init__.py#L23 Co-authored-by: Jason Hu <awaregit@gmail.com>
This commit is contained in:
parent
6c5f0b7434
commit
d15eedc0fb
4 changed files with 515 additions and 524 deletions
22
script/manifest/requirements.py
Normal file
22
script/manifest/requirements.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
"""Helpers to gather requirements from manifests."""
|
||||
from .manifest_helper import iter_manifests
|
||||
|
||||
|
||||
def gather_requirements_from_manifests(process_requirements, errors, reqs):
|
||||
"""Gather all of the requirements from manifests."""
|
||||
for manifest in iter_manifests():
|
||||
assert manifest['domain']
|
||||
|
||||
if manifest.get('requirements') is None:
|
||||
errors.append(
|
||||
'The manifest for component {} is invalid. Please run'
|
||||
'script/manifest/validate.py'.format(manifest['domain'])
|
||||
)
|
||||
continue
|
||||
|
||||
process_requirements(
|
||||
errors,
|
||||
manifest['requirements'],
|
||||
'homeassistant.components.{}'.format(manifest['domain']),
|
||||
reqs
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue