forked from bitcraze/crazyflie-clients-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
122 lines (107 loc) · 4.6 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python3
from distutils.core import setup
import glob
import os
import sys
from subprocess import Popen, PIPE
# Recover version from Git
try:
process = Popen(["git", "describe", "--tags"], stdout=PIPE)
(output, err) = process.communicate()
exit_code = process.wait()
except OSError:
raise Exception("Cannot run git: Git is required to generate packages!")
VERSION = output.strip().decode("UTF-8")
toplevel_data_files = ['README.md', 'LICENSE.txt']
# Platform specific settings
if sys.platform.startswith('win32'):
try:
import py2exe
except ImportError:
print("Warning: py2exe not usable")
setup_args = dict(
console=[{
"script": 'bin/cfclient',
"icon_resources": [(1, "bitcraze.ico")]
}],
options={"py2exe": {
"includes": [
"sip", "PyQt4",
"cfclient.ui.widgets",
"cflib.bootloader.cloader",
"cfclient.ui.toolboxes.*",
"cfclient.ui.*",
"cfclient.ui.tabs.*",
"cfclient.ui.widgets.*",
"cfclient.ui.dialogs.*",
"cfclient.utils.input.inputreaders.*",
"cfclient.utils.input.inputinterfaces.*",
'zmq.backend.cython'],
"excludes": [
"AppKit",
'zmq.libzmq'],
'dll_excludes': [
'libzmq.pyd'],
"skip_archive": True}})
toplevel_data_files.append('SDL2.dll')
else:
setup_args = dict(
scripts=['bin/cfclient', 'bin/cfheadless'])
# Initial parameters
setup_args = dict(name='cfclient',
description='Bitcraze Cazyflie nano quadcopter client',
version=VERSION,
author='Bitcraze team',
author_email='contact@bitcraze.se',
url='http://www.bitcraze.se',
package_dir={'': 'lib'},
packages=['cfclient', 'cfclient.ui', 'cfclient.ui.tabs',
'cfclient.ui.toolboxes', 'cfclient.ui.widgets',
'cfclient.utils', 'cfclient.ui.dialogs', 'cflib',
'cflib.bootloader', 'cflib.crazyflie',
'cflib.drivers',
'cflib.utils', 'cflib.crtp',
'cfclient.utils.input',
'cfclient.utils.input.inputinterfaces',
'cfclient.utils.input.mux',
'cfclient.utils.input.inputreaders'],
data_files=[('', toplevel_data_files),
('cfclient/ui',
glob.glob('src/cfclient/ui/*.ui')),
('cfclient/ui/tabs',
glob.glob('src/cfclient/ui/tabs/*.ui')),
('cfclient/ui/widgets',
glob.glob('src/cfclient/ui/widgets/*.ui')),
('cfclient/ui/toolboxes',
glob.glob('src/cfclient/ui/toolboxes/*.ui')),
('cfclient/ui/dialogs',
glob.glob('src/cfclient/ui/dialogs/*.ui')),
('cfclient/configs',
glob.glob('src/cfclient/configs/*.json')),
('cflib/cache',
glob.glob('src/cflib/cache/*.json')),
('cfclient/configs/input',
glob.glob('src/cfclient/configs/input/*.json')),
('cfclient/configs/log',
glob.glob('src/cfclient/configs/log/*.json')),
('cfclient',
glob.glob('src/cfclient/*.png'))],
**setup_args)
# Fetch values from package.xml when using catkin
if os.getenv('CATKIN_TEST_RESULTS_DIR'):
from catkin_pkg.python_setup import generate_distutils_setup
# Delete keys which should not match catkin packaged variant
for k in ('version', 'url'):
setup_args.pop(k, None)
setup_args = generate_distutils_setup(**setup_args)
# Write a temp file to pass verision into script
version_file = os.path.join(os.path.dirname(__file__),
"lib", "cfclient", "version.py")
try:
with open(version_file, "w") as versionpy:
versionpy.write("VERSION='{}'".format(VERSION))
except:
print("Warning: Version file cannot be written.")
setup(**setup_args)
if (os.path.isfile(version_file)):
os.remove(version_file)