mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-04-01 15:57:12 +01:00
Fix version/requirements parsing in setup.py, set version in Dockerfile (#6692)
* Fix version/requirements parsing in setup.py, set version in Dockerfile Remove the step patching const.py with detected version in CI and do this during Dockerfile version from BUILD_VERSION argument instead. Also, fix parsing of the version in `setup.py` - it wasn't working because it was splitting the files on "/n" instead of newlines, resulting in all Python packages installed having version string set to `9999.9.9.dev9999` instead of the expected version. (Note: setuptools are doing a version string normalization, so the installed package has stripped leading zeroes and the second component is `9` instead of the literal `09` used in default string in all places. Fixing this is out of scope of this change as the ideal solution would be to change the versioning schema but it should be noted.) Lastly, clean up builder.yaml environment variables (crane is not used anymore after #6679). * Generate setuptools-compatible version for PR builds For PR builds, we're using plain commit SHA as the version. This is perfectly fine for Docker tags but it's not acceptable for Python package version. By fixing the setup.py bug this error surfaced. Work it around by setting the Package version to the string we used previously suffixed by the commit SHA as build metadata (delimited by `+`).
This commit is contained in:
10
.github/workflows/builder.yml
vendored
10
.github/workflows/builder.yml
vendored
@@ -35,8 +35,6 @@ on:
|
||||
env:
|
||||
DEFAULT_PYTHON: "3.14.3"
|
||||
COSIGN_VERSION: "v2.5.3"
|
||||
CRANE_VERSION: "v0.20.7"
|
||||
CRANE_SHA256: "8ef3564d264e6b5ca93f7b7f5652704c4dd29d33935aff6947dd5adefd05953e"
|
||||
BUILD_NAME: supervisor
|
||||
BUILD_TYPE: supervisor
|
||||
IMAGE_NAME: hassio-supervisor
|
||||
@@ -161,12 +159,6 @@ jobs:
|
||||
path: wheels
|
||||
retention-days: 1
|
||||
|
||||
- name: Set version
|
||||
if: needs.init.outputs.publish == 'true'
|
||||
uses: home-assistant/actions/helpers/version@master
|
||||
with:
|
||||
type: ${{ env.BUILD_TYPE }}
|
||||
|
||||
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||
if: needs.init.outputs.publish == 'true'
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
@@ -276,7 +268,7 @@ jobs:
|
||||
image: ghcr.io/home-assistant/amd64-hassio-supervisor
|
||||
image-tags: runner
|
||||
load: true
|
||||
version: runner
|
||||
version: ${{ needs.init.outputs.version }}
|
||||
|
||||
# Pull the Supervisor for publish runs to test the published image
|
||||
- name: Pull Supervisor
|
||||
|
||||
@@ -40,9 +40,11 @@ RUN \
|
||||
${LOCAL_WHEELS:+--find-links $LOCAL_WHEELS}
|
||||
|
||||
# Install Home Assistant Supervisor
|
||||
ARG BUILD_VERSION="9999.09.9.dev9999"
|
||||
COPY . supervisor
|
||||
RUN \
|
||||
uv pip install --no-cache -e ./supervisor \
|
||||
sed -i "s/^SUPERVISOR_VERSION =.*/SUPERVISOR_VERSION = \"${BUILD_VERSION}\"/g" /usr/src/supervisor/supervisor/const.py \
|
||||
&& uv pip install --no-cache -e ./supervisor \
|
||||
&& python3 -m compileall ./supervisor/supervisor
|
||||
|
||||
|
||||
|
||||
10
setup.py
10
setup.py
@@ -5,7 +5,9 @@ import re
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
RE_SUPERVISOR_VERSION = re.compile(r"^SUPERVISOR_VERSION =\s*(.+)$")
|
||||
RE_SUPERVISOR_VERSION = re.compile(
|
||||
r'^SUPERVISOR_VERSION =\s*"?((?P<git_sha>[0-9a-f]{40})|[^"]+)"?$'
|
||||
)
|
||||
|
||||
SUPERVISOR_DIR = Path(__file__).parent
|
||||
REQUIREMENTS_FILE = SUPERVISOR_DIR / "requirements.txt"
|
||||
@@ -16,13 +18,15 @@ CONSTANTS = CONST_FILE.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _get_supervisor_version():
|
||||
for line in CONSTANTS.split("/n"):
|
||||
for line in CONSTANTS.split("\n"):
|
||||
if match := RE_SUPERVISOR_VERSION.match(line):
|
||||
if git_sha := match.group("git_sha"):
|
||||
return f"9999.09.9.dev9999+{git_sha}"
|
||||
return match.group(1)
|
||||
return "9999.09.9.dev9999"
|
||||
|
||||
|
||||
setup(
|
||||
version=_get_supervisor_version(),
|
||||
dependencies=REQUIREMENTS.split("/n"),
|
||||
dependencies=REQUIREMENTS.split("\n"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user