Skip to content

Commit

Permalink
Update to MAVSDK v2.11.0
Browse files Browse the repository at this point in the history
This should bring native support for macOS on ARM (M1).
  • Loading branch information
julianoes committed Jun 2, 2024
1 parent 789eaf1 commit 44889ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MAVSDK_SERVER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.10.2
v2.11.0
37 changes: 25 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import urllib.request
import os
import stat
import sys
import platform
import subprocess


Expand Down Expand Up @@ -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":
Expand All @@ -61,24 +62,34 @@ 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.platform() == '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() == '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.")
f"Error: mavsdk_server is not distributed for platform "
"{platform.system()} (yet)!\n\nYou should set the "
"'MAVSDK_BUILD_PURE=ON' environment variable and get "
"mavsdk_server manually.")

@property
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'
Expand All @@ -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 f"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:
Expand All @@ -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)
Expand Down

0 comments on commit 44889ba

Please sign in to comment.