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
Check if a script requirement is available before install #20517
Conversation
homeassistant/scripts/__init__.py
Outdated
@@ -48,6 +50,14 @@ def run(args: List) -> int: | |||
logging.basicConfig(stream=sys.stdout, level=logging.INFO) | |||
|
|||
for req in getattr(script, 'REQUIREMENTS', []): | |||
try: | |||
# Only use the requirement's project_name to verify it exists | |||
project_name = Requirement.parse(req).project_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not reinvent the wheel. Import PackageLoadable
from homeassistant.requirements
@@ -22,8 +22,6 @@ | |||
from homeassistant.exceptions import HomeAssistantError | |||
|
|||
REQUIREMENTS = ('colorlog==4.0.2',) | |||
if system() == 'Windows': # Ensure colorama installed for colorlog on Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this no longer necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s automatic these days. In the past you needed colorlog[windows]
See https://pypi.org/project/colorlog/ search windows/colorama
Description:
Retry of #20272
Current behaviour always installs a script's requirement
This checks if a requirement's project name is available (by import) before it forces installThere is full (including version) requirement handling available inrequirements.py
, but this requires a full hass instance and seems like an overkill for scriptsRelated issue (if applicable): fixes #18651
Checklist:
tox
. Your PR cannot be merged unless tests pass