fix: Adapt versioning scheme to Home Assistant and switch to uv (#896)
Some checks are pending
Bump Version / Bump Version Workflow (push) Waiting to run
docker-build / platform-excludes (push) Waiting to run
docker-build / build (push) Blocked by required conditions
docker-build / merge (push) Blocked by required conditions
pre-commit / pre-commit (push) Waiting to run
Run Pytest on Pull Request / test (push) Waiting to run

Home Assistant expects versioning always increases numbers. Add
a date component to the development version to comply with this
expectation. The scheme is now 0.0.0.dev<date><hash>.

Use uv for creating and managing the virtual environment for developement.
This enourmously speeds up dependency updates. For this change
dependency requirements are now solely handled in pyproject.toml.
requirements.tx and requirements-dev.txt are deleted.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2026-02-23 20:59:03 +01:00
committed by GitHub
parent c578a56af2
commit d446274129
30 changed files with 3974 additions and 319 deletions

123
Makefile
View File

@@ -1,8 +1,18 @@
# Define the targets
.PHONY: help venv pip install dist test test-full test-system test-ci test-profile docker-run docker-build docs read-docs clean format gitlint mypy run run-dev run-dash run-dash-dev prepare-version test-version
.PHONY: help install dist test test-system test-ci test-profile \
docker-run docker-build docs read-docs clean format gitlint mypy \
run run-dev run-dash run-dash-dev prepare-version test-version uv-update
# Use uv for all program actions
UV := uv
PYTHON := $(UV) run python
PYTEST := $(UV) run pytest
MYPY := $(UV) run mypy
PRECOMMIT := $(UV) run pre-commit
COMMITIZEN := $(UV) run cz
# - Take VERSION from version.py
VERSION := $(shell python3 scripts/get_version.py)
VERSION := $(shell $(PYTHON) scripts/get_version.py)
# Default target
all: help
@@ -10,13 +20,11 @@ all: help
# Target to display help information
help:
@echo "Available targets:"
@echo " venv - Set up a Python 3 virtual environment."
@echo " pip - Install dependencies from requirements.txt."
@echo " pip-dev - Install dependencies from requirements-dev.txt."
@echo " format - Format source code."
@echo " gitlint - Lint last commit message."
@echo " mypy - Run mypy."
@echo " install - Install EOS in editable form (development mode) into virtual environment."
@echo " update-env - Update virtual environmenr to match pyproject.toml."
@echo " docker-run - Run entire setup on docker"
@echo " docker-build - Rebuild docker image"
@echo " docs - Generate HTML documentation (in build/docs/html/)."
@@ -36,57 +44,48 @@ help:
@echo " clean - Remove generated documentation, distribution and virtual environment."
@echo " prepare-version - Prepare a version defined in setup.py."
# Target to set up a Python 3 virtual environment
venv:
python3 -m venv .venv
@PYVER=$$(./.venv/bin/python --version) && \
echo "Virtual environment created in '.venv' with $$PYVER. Activate it using 'source .venv/bin/activate'."
# Target to install dependencies from requirements.txt
pip: venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
@echo "Dependencies installed from requirements.txt."
# Target to install dependencies from requirements.txt
pip-dev: pip
.venv/bin/pip install -r requirements-dev.txt
@echo "Dependencies installed from requirements-dev.txt."
# Target to create a version.txt
version-txt:
echo "$(VERSION)" > version.txt
# Get the version from the package for setuptools (and pip)
VERSION=$$(${PYTHON} scripts/get_version.py)
@echo "$(VERSION)" > version.txt
@echo "version.txt set to '$(VERSION)'."
# Target to install EOS in editable form (development mode) into virtual environment.
install: pip-dev version-txt
.venv/bin/pip install build
.venv/bin/pip install -e .
@echo "EOS installed in editable form (development mode)."
install: version-txt
# Upgrade installation and dependencies
$(UV) sync --extra dev
@echo "EOS version $(VERSION) installed in editable form (development mode)."
# Target to rebuild the virtual environment.
update-env:
@echo "Rebuilding virtual environment to match pyproject.toml..."
uv rebuild
@echo "Environment rebuilt."
# Target to create a distribution.
dist: pip
.venv/bin/pip install build
.venv/bin/python -m build --wheel
dist: version-txt
$(PIP) install build
$(PYTHON) -m build --wheel
@echo "Distribution created (see dist/)."
# Target to generate documentation
gen-docs: pip-dev version-txt
.venv/bin/pip install -e .
.venv/bin/python ./scripts/generate_config_md.py --output-file docs/_generated/config.md
.venv/bin/python ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
.venv/bin/python ./scripts/generate_openapi.py --output-file openapi.json
gen-docs: version-txt
$(PYTHON) ./scripts/generate_config_md.py --output-file docs/_generated/config.md
$(PYTHON) ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
$(PYTHON) ./scripts/generate_openapi.py --output-file openapi.json
@echo "Documentation generated to openapi.json and docs/_generated."
# Target to build HTML documentation
docs: pip-dev
.venv/bin/pytest --finalize tests/test_docsphinx.py
docs: install
$(PYTEST) --finalize tests/test_docsphinx.py
@echo "Documentation build to build/docs/html/."
# Target to read the HTML documentation
read-docs:
@echo "Read the documentation in your browser"
.venv/bin/pytest --finalize tests/test_docsphinx.py
.venv/bin/python -m webbrowser build/docs/html/index.html
$(PYTEST) --finalize tests/test_docsphinx.py
$(PYTHON) -m webbrowser build/docs/html/index.html
# Clean Python bytecode
clean-bytecode:
@@ -104,64 +103,66 @@ clean-docs:
clean: clean-docs
@echo "Cleaning virtual env, distribution and build directories"
rm -rf build .venv
@echo "Cleaning uv environment"
$(UV) clean
@echo "Deletion complete."
run:
@echo "Starting EOS production server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eos --startup_eosdash true
$(PYTHON) -m akkudoktoreos.server.eos --startup_eosdash true
run-dev:
@echo "Starting EOS development server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eos --host localhost --port 8503 --log_level DEBUG --startup_eosdash false --reload true
$(PYTHON) -m akkudoktoreos.server.eos --host localhost --port 8503 --log_level DEBUG --startup_eosdash false --reload true
run-dash:
@echo "Starting EOSdash production server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eosdash
$(PYTHON) -m akkudoktoreos.server.eosdash
run-dash-dev:
@echo "Starting EOSdash development server, please wait..."
.venv/bin/python -m akkudoktoreos.server.eosdash --host localhost --port 8504 --log_level DEBUG --reload true
$(PYTHON) -m akkudoktoreos.server.eosdash --host localhost --port 8504 --log_level DEBUG --reload true
# Target to setup tests.
test-setup: pip-dev
test-setup: install
@echo "Setup tests"
# Target to run tests.
test:
@echo "Running tests..."
.venv/bin/pytest -vs --cov src --cov-report term-missing
$(PYTEST) -vs --cov src --cov-report term-missing
# Target to run tests as done by CI on Github.
test-ci:
@echo "Running tests as CI..."
.venv/bin/pytest --finalize --check-config-side-effect -vs --cov src --cov-report term-missing
$(PYTEST) --finalize --check-config-side-effect -vs --cov src --cov-report term-missing
# Target to run tests including the system tests.
test-system:
@echo "Running tests incl. system tests..."
.venv/bin/pytest --system-test -vs --cov src --cov-report term-missing
$(PYTEST) --system-test -vs --cov src --cov-report term-missing
# Target to run all tests.
test-finalize:
@echo "Running all tests..."
.venv/bin/pytest --finalize
$(PYTEST) --finalize
# Target to run tests including the single test optimization with profiling.
test-profile:
@echo "Running single test optimization with profiling..."
.venv/bin/python tests/single_test_optimization.py --profile
$(PYTHON) tests/single_test_optimization.py --profile
# Target to format code.
format:
.venv/bin/pre-commit run --all-files
$(PRECOMMIT) run --all-files
# Target to trigger gitlint using pre-commit for the latest commit messages
# Target to trigger git linting using commitizen for the latest commit messages
gitlint:
.venv/bin/cz check --rev-range main..HEAD
$(COMMITIZEN) check --rev-range main..HEAD
# Target to format code.
mypy:
.venv/bin/mypy
$(MYPY)
# Run entire setup on docker
docker-run:
@@ -180,15 +181,15 @@ docker-build:
# Take UPDATE_FILES from GitHub action bump-version.yml
UPDATE_FILES := $(shell sed -n 's/^[[:space:]]*UPDATE_FILES[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' \
.github/workflows/bump-version.yml)
prepare-version: #pip-dev
prepare-version: install
@echo "Update version to $(VERSION) from version.py in files $(UPDATE_FILES) and doc"
.venv/bin/python ./scripts/update_version.py $(VERSION) $(UPDATE_FILES)
.venv/bin/python ./scripts/convert_lightweight_tags.py
.venv/bin/python ./scripts/generate_config_md.py --output-file docs/_generated/config.md
.venv/bin/python ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
.venv/bin/python ./scripts/generate_openapi.py --output-file openapi.json
.venv/bin/pytest -vv --finalize tests/test_version.py
$(PYTHON) ./scripts/update_version.py $(VERSION) $(UPDATE_FILES)
$(PYTHON) ./scripts/convert_lightweight_tags.py
$(PYTHON) ./scripts/generate_config_md.py --output-file docs/_generated/config.md
$(PYTHON) ./scripts/generate_openapi_md.py --output-file docs/_generated/openapi.md
$(PYTHON) ./scripts/generate_openapi.py --output-file openapi.json
$(PYTEST) -vv --finalize tests/test_version.py
test-version:
echo "Test version information to be correctly set in all version files"
.venv/bin/pytest -vv tests/test_version.py
$(PYTEST) -vv tests/test_version.py