Skip to content

Commit d078bd6

Browse files
Add a way to build pure package and publish it to PyPi
1 parent adeb33a commit d078bd6

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ branches:
66
matrix:
77
fast_finish: true
88
include:
9+
- os: linux
10+
name: linux (pure wheel)
11+
dist: bionic
12+
python:
13+
- 3.6
14+
- 3.7
15+
before_install:
16+
python3 --version;
17+
pip3 --version;
18+
env:
19+
- BUILD_TARGET=linux_pure_wheel
20+
- PYTHON_BIN=python3
21+
- MAVSDK_BUILD_PURE=ON
22+
addons:
23+
apt:
24+
packages:
25+
- patchelf
926
- os: linux
1027
name: Linux
1128
dist: bionic
@@ -66,6 +83,10 @@ install:
6683
script:
6784
- set -e
6885
- $PYTHON_BIN setup.py bdist_wheel
86+
- if [[ "${BUILD_TARGET}" = "linux_pure_wheel" ]]; then
87+
mkdir wheelhouse;
88+
mv dist/*.whl wheelhouse;
89+
fi
6990
- if [[ "${BUILD_TARGET}" = "linux" ]]; then
7091
auditwheel repair --plat manylinux2010_x86_64 dist/*.whl;
7192
fi

mavsdk/system.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,18 @@ def _start_mavsdk_server(system_address=None):
162162
else:
163163
from importlib_resources import path
164164

165-
with path(bin, 'mavsdk_server') as backend:
166-
bin_path_and_args = [os.fspath(backend), "-p", "50051"]
167-
if system_address:
168-
bin_path_and_args.append(system_address)
169-
p = subprocess.Popen(bin_path_and_args,
170-
shell=False,
171-
stdout=subprocess.DEVNULL,
172-
stderr=subprocess.DEVNULL)
165+
try:
166+
with path(bin, 'mavsdk_server') as backend:
167+
bin_path_and_args = [os.fspath(backend), "-p", "50051"]
168+
if system_address:
169+
bin_path_and_args.append(system_address)
170+
p = subprocess.Popen(bin_path_and_args,
171+
shell=False,
172+
stdout=subprocess.DEVNULL,
173+
stderr=subprocess.DEVNULL)
174+
except FileNotFoundError:
175+
raise Exception("\nIt seems like this installation does not provide an embedded 'mavsdk_server' binary. If you installed from pip, it means that 'mavsdk_server' is not distributed for your platform (yet). You will need to get and run it manually:\n\n\t1. Build 'mavsdk_server': https://github.com/mavlink/mavsdk.\n\t2. Run it, e.g. on port 50051: './mavsdk_server -p 50051'.\n\t3. Set the 'mavsdk_server_address' and port when creating the System: 'drone = System(mavsdk_server_address='localhost', port=50051)\n")
176+
173177

174178
def cleanup():
175179
p.kill()

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import urllib.request
88
import os
9+
import platform
910
import stat
1011
import sys
1112
import subprocess
@@ -52,15 +53,15 @@ def platform_suffix(self):
5253
"""
5354
Trying to detect the platform to know which `mavsdk_server` executable to download
5455
"""
55-
if sys.platform.startswith('linux'):
56+
if sys.platform.startswith('linux') and platform.machine() == "x86_64":
5657
return 'manylinux2010-x64'
5758
elif sys.platform.startswith('darwin'):
5859
return 'macos'
5960
elif sys.platform.startswith('win'):
6061
return 'win32.exe'
6162
else:
6263
raise NotImplementedError(
63-
f"Platform {sys.platform} is not (yet) supported by this setup.py!")
64+
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.")
6465

6566
@property
6667
def mavsdk_server_filepath(self):
@@ -86,7 +87,9 @@ def mavsdk_server_url(self):
8687
return f"https://github.com/mavlink/MAVSDK/releases/download/{self.mavsdk_server_tag}/mavsdk_server_{self.platform_suffix}"
8788

8889
def run(self):
89-
self.download_mavsdk_server()
90+
if 'MAVSDK_BUILD_PURE' not in os.environ:
91+
self.download_mavsdk_server()
92+
9093
build.run(self)
9194

9295
def download_mavsdk_server(self):

0 commit comments

Comments
 (0)