Add default config to constaint file (#24423)
This commit is contained in:
parent
1810e459ee
commit
168f20bdf4
2 changed files with 31 additions and 26 deletions
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Generate an updated requirements_all.txt."""
|
||||
import fnmatch
|
||||
import importlib
|
||||
import os
|
||||
import pathlib
|
||||
|
@ -155,13 +154,6 @@ TEST_REQUIREMENTS = (
|
|||
'bellows-homeassistant',
|
||||
)
|
||||
|
||||
IGNORE_PACKAGES = (
|
||||
'homeassistant.components.hangouts.hangups_utils',
|
||||
'homeassistant.components.cloud.client',
|
||||
'homeassistant.components.homekit.*',
|
||||
'homeassistant.components.recorder.models',
|
||||
)
|
||||
|
||||
IGNORE_PIN = ('colorlog>2.1,<3', 'keyring>=9.3,<10.0', 'urllib3')
|
||||
|
||||
IGNORE_REQ = (
|
||||
|
@ -185,10 +177,6 @@ pycrypto==1000000000.0.0
|
|||
|
||||
# Contains code to modify Home Assistant to work around our rules
|
||||
python-systemair-savecair==1000000000.0.0
|
||||
|
||||
# Newer version causes pylint to take forever
|
||||
# https://github.com/timothycrosley/isort/issues/848
|
||||
isort==4.3.4
|
||||
"""
|
||||
|
||||
|
||||
|
@ -218,6 +206,22 @@ def core_requirements():
|
|||
return re.findall(r"'(.*?)'", reqs_raw)
|
||||
|
||||
|
||||
def gather_recursive_requirements(domain, seen=None):
|
||||
"""Recursively gather requirements from a module."""
|
||||
if seen is None:
|
||||
seen = set()
|
||||
|
||||
seen.add(domain)
|
||||
integration = Integration(pathlib.Path(
|
||||
'homeassistant/components/{}'.format(domain)
|
||||
))
|
||||
integration.load_manifest()
|
||||
reqs = set(integration.manifest['requirements'])
|
||||
for dep_domain in integration.manifest['dependencies']:
|
||||
reqs.update(gather_recursive_requirements(dep_domain, seen))
|
||||
return reqs
|
||||
|
||||
|
||||
def comment_requirement(req):
|
||||
"""Comment out requirement. Some don't install on all systems."""
|
||||
return any(ign in req for ign in COMMENT_REQUIREMENTS)
|
||||
|
@ -274,12 +278,8 @@ def gather_requirements_from_modules(errors, reqs):
|
|||
try:
|
||||
module = importlib.import_module(package)
|
||||
except ImportError as err:
|
||||
for pattern in IGNORE_PACKAGES:
|
||||
if fnmatch.fnmatch(package, pattern):
|
||||
break
|
||||
else:
|
||||
print("{}: {}".format(package.replace('.', '/') + '.py', err))
|
||||
errors.append(package)
|
||||
print("{}: {}".format(package.replace('.', '/') + '.py', err))
|
||||
errors.append(package)
|
||||
continue
|
||||
|
||||
if getattr(module, 'REQUIREMENTS', None):
|
||||
|
@ -347,7 +347,8 @@ def requirements_test_output(reqs):
|
|||
|
||||
def gather_constraints():
|
||||
"""Construct output for constraint file."""
|
||||
return '\n'.join(core_requirements() + [''])
|
||||
return '\n'.join(sorted(core_requirements() + list(
|
||||
gather_recursive_requirements('default_config'))) + [''])
|
||||
|
||||
|
||||
def write_requirements_file(data):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue