1 from __future__
import absolute_import, print_function
2 from setuptools.command.build_py
import build_py
9 ascii = codecs.lookup(
'ascii')
10 func =
lambda name, enc=ascii: {
True: enc}.get(name==
'mbcs')
13 from setuptools
import setup, Extension
14 import glob, os, shutil, fnmatch, platform, sys
21 from generator
import mavgen, mavparse
24 if os.getenv(
"MDEF",
None)
is not None:
25 mdef_paths = [os.getenv(
"MDEF")]
27 mdef_paths = [os.path.join(
'..',
'message_definitions'),
28 os.path.join(
'mavlink',
'message_definitions'),
29 os.path.join(
'..',
'mavlink',
'message_definitions'),
30 os.path.join(
'message_definitions'),
33 for path
in mdef_paths:
34 mdef_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), path)
35 if os.path.exists(mdef_path):
36 print(
"Using message definitions from %s" % mdef_path)
39 dialects_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'dialects')
41 v10_dialects = glob.glob(os.path.join(mdef_path,
'v1.0',
'*.xml'))
44 v20_dialects = glob.glob(os.path.join(mdef_path,
'v1.0',
'*.xml'))
46 should_generate =
not "NOGEN" in os.environ
48 if len(v10_dialects) == 0:
49 print(
"No XML message definitions found")
52 for xml
in v10_dialects:
53 shutil.copy(xml, os.path.join(dialects_path,
'v10'))
54 for xml
in v20_dialects:
55 shutil.copy(xml, os.path.join(dialects_path,
'v20'))
57 for xml
in v10_dialects:
58 dialect = os.path.basename(xml)[:-4]
59 wildcard = os.getenv(
"MAVLINK_DIALECT",
'*')
60 if not fnmatch.fnmatch(dialect, wildcard):
62 print(
"Building %s for protocol 1.0" % xml)
63 if not mavgen.mavgen_python_dialect(dialect, mavparse.PROTOCOL_1_0):
64 print(
"Building failed %s for protocol 1.0" % xml)
67 for xml
in v20_dialects:
68 dialect = os.path.basename(xml)[:-4]
69 wildcard = os.getenv(
"MAVLINK_DIALECT",
'*')
70 if not fnmatch.fnmatch(dialect, wildcard):
72 print(
"Building %s for protocol 2.0" % xml)
73 if not mavgen.mavgen_python_dialect(dialect, mavparse.PROTOCOL_2_0):
74 print(
"Building failed %s for protocol 2.0" % xml)
78 if platform.system() !=
'Windows':
79 extensions = [ Extension(
'mavnative',
80 sources=[
'mavnative/mavnative.c'],
82 'generator/C/include_v1.0',
83 'generator/C/include_v2.0',
88 print(
"Skipping mavnative due to Windows possibly missing a compiler...")
99 setup (name =
'pymavlink',
101 description =
'Python MAVLink code',
102 long_description = (
'A Python library for handling MAVLink protocol streams and log files. This allows for the ' 103 'creation of simple scripts to analyse telemetry logs from autopilots such as ArduPilot which use ' 104 'the MAVLink protocol. See the scripts that come with the package for examples of small, useful ' 105 'scripts that use pymavlink. For more information about the MAVLink protocol see ' 106 'https://mavlink.io/en/'),
107 url =
'https://github.com/ArduPilot/pymavlink/',
108 classifiers=[
'Development Status :: 4 - Beta',
109 'Environment :: Console',
110 'Intended Audience :: Science/Research',
111 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
112 'Operating System :: OS Independent',
113 'Programming Language :: Python :: 2.7',
114 'Programming Language :: Python :: 3.5',
115 'Topic :: Scientific/Engineering' 118 package_dir = {
'pymavlink' :
'.' },
119 package_data = {
'pymavlink.dialects.v10' : [
'*.xml'],
120 'pymavlink.dialects.v20' : [
'*.xml'],
121 'pymavlink.generator' : [
'*.xsd',
123 'java/lib/Messages/*.*',
124 'C/include_v1.0/*.h',
125 'C/include_v1.0/*.hpp',
126 'C/include_v2.0/*.h',
127 'C/include_v2.0/*.hpp',
128 'CPP11/include_v2.0/*.hpp',
131 'pymavlink' : [
'mavnative/*.h',
132 'message_definitions/v*/*.xml']
134 packages = [
'pymavlink',
135 'pymavlink.generator',
136 'pymavlink.dialects',
137 'pymavlink.dialects.v10',
138 'pymavlink.dialects.v20'],
139 scripts = [
'tools/magfit_delta.py',
'tools/mavextract.py',
140 'tools/mavgraph.py',
'tools/mavparmdiff.py',
141 'tools/mavtogpx.py',
'tools/magfit_gps.py',
142 'tools/mavflightmodes.py',
'tools/mavlogdump.py',
143 'tools/mavparms.py',
'tools/magfit_motors.py',
144 'tools/mavflighttime.py',
'tools/mavloss.py',
145 'tools/mavplayback.py',
'tools/magfit.py',
146 'tools/mavgpslock.py',
147 'tools/mavmission.py',
148 'tools/mavsigloss.py',
149 'tools/mavsearch.py',
150 'tools/mavtomfile.py',
154 'tools/mavfft_isb.py',
155 'tools/mavsummarize.py',
156 'tools/MPU6KSearch.py'],
164 cmdclass={
'build_py': custom_build_py},
165 ext_modules = extensions