From 8e4fd130db2e4bd365e954bd2b89eac44b64358f Mon Sep 17 00:00:00 2001 From: dotKrad Date: Mon, 7 Aug 2023 02:24:52 -0400 Subject: [PATCH] container updates --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 44 ++++++++++++++++----------------- .vscode/settings.json | 6 ++++- .vscode/tasks.json | 22 ++--------------- requirements.txt | 3 +++ scripts/develop | 20 +++++++++++++++ scripts/setup | 8 ++++++ 7 files changed, 61 insertions(+), 44 deletions(-) create mode 100644 scripts/develop create mode 100644 scripts/setup diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a7e7945..b7e4873 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10 +FROM python:3.11 RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1097eb5..19e8413 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,30 +1,30 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ghcr.io/ludeeus/devcontainer/integration:latest", "name": "FPL integration development", - "context": "..", + "image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye", "appPort": [ "9123:8123" ], - "postCreateCommand": "container install", - "extensions": [ - "ms-python.python", - "github.vscode-pull-request-github", - "ryanluker.vscode-coverage-gutters", - "ms-python.vscode-pylance" - ], - "settings": { - "files.eol": "\n", - "editor.tabSize": 4, - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/bin/python3", - "python.analysis.autoSearchPaths": false, - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.formatting.provider": "black", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true + "postCreateCommand": "scripts/setup", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "github.vscode-pull-request-github", + "ryanluker.vscode-coverage-gutters", + "ms-python.vscode-pylance" + ], + "settings": { + "files.eol": "\n", + "editor.tabSize": 4, + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/bin/python3", + "python.analysis.autoSearchPaths": false, + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } + } } } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 4224bfc..51b0c06 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,9 @@ ], "files.associations": { "*.yaml": "home-assistant" - } + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.formatting.provider": "none" } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d1a0ae7..54ba9c4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,27 +2,9 @@ "version": "2.0.0", "tasks": [ { - "label": "Run Home Assistant on port 9123", + "label": "Run Home Assistant on port 8123", "type": "shell", - "command": "container start", - "problemMatcher": [] - }, - { - "label": "Run Home Assistant configuration against /config", - "type": "shell", - "command": "container check", - "problemMatcher": [] - }, - { - "label": "Upgrade Home Assistant to latest dev", - "type": "shell", - "command": "container install", - "problemMatcher": [] - }, - { - "label": "Install a specific version of Home Assistant", - "type": "shell", - "command": "container set-version", + "command": "scripts/develop", "problemMatcher": [] } ] diff --git a/requirements.txt b/requirements.txt index e69de29..216035f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,3 @@ +colorlog==6.7.0 +pip>=21.0 +ruff>=0.0.267 \ No newline at end of file diff --git a/scripts/develop b/scripts/develop new file mode 100644 index 0000000..4bf0c9e --- /dev/null +++ b/scripts/develop @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +# Create config dir if not present +if [[ ! -d "/home/config" ]]; then + mkdir -p "/home/config" + hass --config "/home/config" --script ensure_config +fi + +# Set the path to custom_components +## This let's us have the structure we want /custom_components/integration_blueprint +## while at the same time have Home Assistant configuration inside /config +## without resulting to symlinks. +export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components" + +# Start Home Assistant +hass --config "/home/config" --debug \ No newline at end of file diff --git a/scripts/setup b/scripts/setup new file mode 100644 index 0000000..668a623 --- /dev/null +++ b/scripts/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +python -m pip install --requirement requirements.txt +python -m pip install --upgrade git+https://github.com/home-assistant/home-assistant@dev \ No newline at end of file