From 4b1c1ec5db4fc5eb38c632245117c7c1162eb1f3 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Tue, 11 Jul 2023 00:10:11 +0200 Subject: [PATCH] make uvloop optional for armv7 --- .github/workflows/release.yml | 26 +++++++++++--------------- Dockerfile | 4 ++++ music_assistant/__main__.py | 9 ++++++++- pyproject.toml | 3 +-- requirements_all.txt | 1 - 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 778da2cb..028457f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,23 +73,16 @@ jobs: else echo "channel=stable" >> $GITHUB_OUTPUT fi - - name: Install tomli - run: >- - pip install tomli tomli-w - - name: Set Python project version from tag - shell: python - run: |- - import tomli - import tomli_w - with open("pyproject.toml", "rb") as f: - pyproject = tomli.load(f) - - pyproject["project"]["version"] = "${{ needs.build-and-publish-pypi.outputs.version }}" + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/music-assistant/server - with open("pyproject.toml", "wb") as f: - tomli_w.dump(pyproject, f) - # we use 3 different jobs here due to the fact that the architecture is named differently in buildx + # we use 3 different jobs here due so we can pass the correct BUILD_ARCH - name: Build and Push amd64 uses: docker/build-push-action@v4.1.1 with: @@ -103,6 +96,7 @@ jobs: ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.channel }}, ghcr.io/${{ github.repository_owner }}/server:latest push: true + labels: ${{ steps.meta.outputs.labels }} build-args: | "MASS_VERSION=${{ needs.build-and-publish-pypi.outputs.version }}" "BUILD_ARCH=amd64" @@ -119,6 +113,7 @@ jobs: ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.channel }}, ghcr.io/${{ github.repository_owner }}/server:latest push: true + labels: ${{ steps.meta.outputs.labels }} build-args: | "MASS_VERSION=${{ needs.build-and-publish-pypi.outputs.version }}" "BUILD_ARCH=aarch64" @@ -135,6 +130,7 @@ jobs: ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.channel }}, ghcr.io/${{ github.repository_owner }}/server:latest push: true + labels: ${{ steps.meta.outputs.labels }} build-args: | "MASS_VERSION=${{ needs.build-and-publish-pypi.outputs.version }}" "BUILD_ARCH=armv7" diff --git a/Dockerfile b/Dockerfile index 9989a405..2c112ba4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ FROM ghcr.io/home-assistant/$BUILD_ARCH-base-python:${BASE_IMAGE_VERSION} ARG MASS_VERSION ENV S6_SERVICES_GRACETIME=220000 ENV WHEELS_LINKS="https://wheels.home-assistant.io/musllinux/" +ARG UVLOOP_VERSION="0.17.0" WORKDIR /usr/src @@ -34,6 +35,9 @@ RUN pip3 install \ music-assistant[server]==${MASS_VERSION} \ && python3 -m compileall music-assistant +# Install optional uvloop if possible (will fail on armv7) +RUN pip3 install --no-cache-dir uvloop==${UVLOOP_VERSION}; exit 0 + # Set some labels LABEL \ org.opencontainers.image.title="Music Assistant" \ diff --git a/music_assistant/__main__.py b/music_assistant/__main__.py index 41dd76fa..1097508d 100644 --- a/music_assistant/__main__.py +++ b/music_assistant/__main__.py @@ -20,6 +20,13 @@ from music_assistant.constants import ROOT_LOGGER_NAME from music_assistant.server import MusicAssistant from music_assistant.server.helpers.logging import activate_log_queue_handler +try: + import uvloop # noqa: F401 + + USE_UVLOOP = True +except ImportError: + USE_UVLOOP = False + FORMAT_DATE: Final = "%Y-%m-%d" FORMAT_TIME: Final = "%H:%M:%S" FORMAT_DATETIME: Final = f"{FORMAT_DATE} {FORMAT_TIME}" @@ -177,7 +184,7 @@ def main(): run( start_mass(), - use_uvloop=True, + use_uvloop=USE_UVLOOP, shutdown_callback=on_shutdown, executor_workers=64, ) diff --git a/pyproject.toml b/pyproject.toml index d7c57847..ff2461fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,8 +45,7 @@ server = [ "shortuuid==1.0.11", "zeroconf==0.70.0", "cryptography==41.0.1", - "ifaddr==0.2.0", - "uvloop==0.17.0" + "ifaddr==0.2.0" ] test = [ "black==23.3.0", diff --git a/requirements_all.txt b/requirements_all.txt index ef28df0f..0efc27d2 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -29,7 +29,6 @@ python-slugify==8.0.1 shortuuid==1.0.11 soco==0.29.1 unidecode==1.3.6 -uvloop==0.17.0 xmltodict==0.13.0 ytmusicapi==1.0.0 zeroconf==0.70.0 -- 2.34.1