make uvloop optional for armv7
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 10 Jul 2023 22:10:11 +0000 (00:10 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 10 Jul 2023 22:10:11 +0000 (00:10 +0200)
.github/workflows/release.yml
Dockerfile
music_assistant/__main__.py
pyproject.toml
requirements_all.txt

index 778da2cb81fd040ae116c7eff9e0b9da003b547e..028457f9a27922d8803e0d8dec3282eabee992f2 100644 (file)
@@ -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"
index 9989a4057975d301824bbfefbe922e61ba7fe3a2..2c112ba4081097f616bcfcc7d62b9fe7b1c4f10e 100644 (file)
@@ -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" \
index 41dd76fa421d9467a1556cac7814b89a88fee5e0..1097508da3d0812caace1da640efa6bac03a85db 100644 (file)
@@ -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,
     )
index d7c578470d04a8267ab606e177426c432e92696a..ff2461fad1158c3fad5a93590427a8c5c5749437 100644 (file)
@@ -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",
index ef28df0fb8f9a3033e3654e9a4e4ddf02468ca60..0efc27d2975b6e9cbcbe247dca3c125d56ae361a 100644 (file)
@@ -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