From e3ea8414d539d69a9c79295d5516a85502f17ed1 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 2 Jun 2024 21:20:14 +1200 Subject: [PATCH] Update to MAVSDK v2.11.0 This should bring native support for macOS on ARM (M1). --- .github/workflows/main.yml | 16 ++++++++++++---- MAVSDK_SERVER_VERSION | 2 +- setup.py | 37 +++++++++++++++++++++++++------------ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf77504e..d51bcac2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -130,8 +130,17 @@ jobs: twine upload dist/*.whl macOS: - name: macOS - runs-on: macos-12 + name: macOS ${{ matrix.arch }} + runs-on: ${{ matrix.runs_on }} + strategy: + matrix: + include: + - arch: x64 + wheel_arch: 10_9_x86_64 + runs_on: macos-13 + - arch: arm64 + wheel_arch: 11_0_arm64 + runs_on: macos-14 steps: - uses: actions/checkout@v1 with: @@ -158,9 +167,8 @@ jobs: run: | python setup.py bdist_wheel export PATH="$(python -m site --user-base)/bin:$PATH" - echo "PATH: $PATH" delocate-wheel -w wheelhouse -v dist/*.whl - ls wheelhouse/*any.whl | sed -e 'p;s/any/macosx_10_9_x86_64/' | xargs -n2 mv + ls wheelhouse/*any.whl | sed -e 'p;s/any/macosx_${{ matrix.wheel_arch }}/' | xargs -n2 mv - name: Check the artifacts run: | diff --git a/MAVSDK_SERVER_VERSION b/MAVSDK_SERVER_VERSION index 1e8349cd..b0c3c5ce 100644 --- a/MAVSDK_SERVER_VERSION +++ b/MAVSDK_SERVER_VERSION @@ -1 +1 @@ -v2.10.2 +v2.11.0 diff --git a/setup.py b/setup.py index ff704d3f..6aea6d4f 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ import urllib.request import os import stat -import sys +import platform import subprocess @@ -50,9 +50,10 @@ class custom_build(build): @property def platform_suffix(self): """ - Trying to detect the platform to know which `mavsdk_server` executable to download + Trying to detect the platform to know which `mavsdk_server` executable + to download """ - if sys.platform.startswith('linux') and 'MAVSDK_SERVER_ARCH' in os.environ: + if platform.system() == 'Linux' and 'MAVSDK_SERVER_ARCH' in os.environ: if os.environ['MAVSDK_SERVER_ARCH'] == "armv6l": return 'linux-armv6-musl' elif os.environ['MAVSDK_SERVER_ARCH'] == "armv7l": @@ -61,16 +62,26 @@ def platform_suffix(self): return 'linux-arm64-musl' else: raise NotImplementedError( - f"Error: unknown MAVSDK_SERVER_ARCH: {os.environ['MAVSDK_SERVER_ARCH']}") - elif sys.platform.startswith('linux'): + "Error: unknown MAVSDK_SERVER_ARCH: " + f"{os.environ['MAVSDK_SERVER_ARCH']}") + elif platform.system() == 'Linux': return 'musl_x86_64' - elif sys.platform.startswith('darwin'): - return 'macos' - elif sys.platform.startswith('win'): + elif platform.system() == 'Darwin': + if platform.processor() == 'i386': + return 'macos_x64' + elif platform.processor() == 'arm': + return 'macos_arm64' + raise NotImplementedError( + f"Error: unknown macOS processor: {platform.processor()}") + elif platform.system() == 'Windows' \ + and platform.processor().startswith('AMD64'): return 'win32.exe' else: raise NotImplementedError( - f"Error: mavsdk_server is not distributed for platform {sys.platform} (yet)! You should set the 'MAVSDK_BUILD_PURE=ON' environment variable and get mavsdk_server manually.") + "Error: mavsdk_server is not distributed for platform " + f"{platform.system()} ({platform.processor()}) (yet)!\n\n" + "You should set the 'MAVSDK_BUILD_PURE=ON' environment " + "variable and get mavsdk_server manually.") @property def mavsdk_server_filepath(self): @@ -78,7 +89,7 @@ def mavsdk_server_filepath(self): The location of the downloaded `mavsdk_server` binary For Windows this needs to be a .exe file """ - if sys.platform.startswith('win'): + if platform.system() == 'Windows': return 'mavsdk/bin/mavsdk_server.exe' else: return 'mavsdk/bin/mavsdk_server' @@ -97,7 +108,8 @@ def mavsdk_server_url(self): """ Build the url of the `mavsdk_server` binary """ - return f"https://github.com/mavlink/MAVSDK/releases/download/{self.mavsdk_server_tag}/mavsdk_server_{self.platform_suffix}" + return "https://github.com/mavlink/MAVSDK/releases/download/" \ + f"{self.mavsdk_server_tag}/mavsdk_server_{self.platform_suffix}" def run(self): if 'MAVSDK_BUILD_PURE' not in os.environ: @@ -107,7 +119,8 @@ def run(self): def download_mavsdk_server(self): print( - f"downloading {self.mavsdk_server_url} into {self.mavsdk_server_filepath}") + f"downloading {self.mavsdk_server_url} into " + f"{self.mavsdk_server_filepath}") urllib.request.urlretrieve( self.mavsdk_server_url, filename=self.mavsdk_server_filepath)