forked from bitcraze/crazyflie-clients-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
111 lines (93 loc) · 3.88 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
#!/usr/bin/env python
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()
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.*"],
"excludes": ["AppKit"],
"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='[email protected]',
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.inputdevices'],
data_files=[('', toplevel_data_files),
('cfclient/ui',
glob.glob('lib/cfclient/ui/*.ui')),
('cfclient/ui/tabs',
glob.glob('lib/cfclient/ui/tabs/*.ui')),
('cfclient/ui/widgets',
glob.glob('lib/cfclient/ui/widgets/*.ui')),
('cfclient/ui/toolboxes',
glob.glob('lib/cfclient/ui/toolboxes/*.ui')),
('cfclient/ui/dialogs',
glob.glob('lib/cfclient/ui/dialogs/*.ui')),
('cfclient/configs',
glob.glob('lib/cfclient/configs/*.json')),
('cflib/cache',
glob.glob('lib/cflib/cache/*.json')),
('cfclient/configs/input',
glob.glob('lib/cfclient/configs/input/*.json')),
('cfclient/configs/log',
glob.glob('lib/cfclient/configs/log/*.json')),
('cfclient',
glob.glob('lib/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)