forked from catkin/catkin_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
164 lines (147 loc) · 5.68 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import argparse
from distutils import log
import os
import site
from stat import ST_MODE
import sys
from setuptools import find_packages
from setuptools import setup
from setuptools.command.install import install
# Setup installation dependencies
install_requires = [
'catkin-pkg > 0.2.9',
'setuptools',
'PyYAML',
'osrf-pycommon > 0.1.1',
]
# Figure out the resources that need to be installed
this_dir = os.path.abspath(os.path.dirname(__file__))
osx_resources_path = os.path.join(
this_dir,
'catkin_tools',
'notifications',
'resources',
'osx',
'catkin build.app')
osx_notification_resources = [os.path.join(dp, f)
for dp, dn, fn in os.walk(osx_resources_path)
for f in fn]
src_path = os.path.join(this_dir, 'catkin_tools')
osx_notification_resources = [os.path.relpath(x, src_path)
for x in osx_notification_resources]
def _resolve_prefix(prefix, type):
osx_system_prefix = '/System/Library/Frameworks/Python.framework/Versions'
if type == 'man':
if prefix == '/usr':
return '/usr/share'
if sys.prefix.startswith(osx_system_prefix):
return '/usr/share'
elif type == 'bash_comp':
if prefix == '/usr':
return '/'
if sys.prefix.startswith(osx_system_prefix):
return '/'
elif type == 'zsh_comp':
if sys.prefix.startswith(osx_system_prefix):
return '/usr/local'
else:
raise ValueError('not supported type')
return prefix
def get_data_files(prefix):
data_files = []
# Bash completion
bash_comp_dest = os.path.join(_resolve_prefix(prefix, 'bash_comp'),
'etc/bash_completion.d')
data_files.append((bash_comp_dest,
['completion/catkin_tools-completion.bash']))
# Zsh completion
zsh_comp_dest = os.path.join(_resolve_prefix(prefix, 'zsh_comp'),
'share/zsh/site-functions')
data_files.append((zsh_comp_dest, ['completion/_catkin']))
return data_files
class PermissiveInstall(install):
def run(self):
install.run(self)
if os.name == 'posix':
for file in self.get_outputs():
# all installed files should be readable for anybody
mode = ((os.stat(file)[ST_MODE]) | 0o444) & 0o7777
log.info("changing permissions of %s to %o" % (file, mode))
os.chmod(file, mode)
# Provide information about bash completion after default install.
if (sys.platform.startswith("linux") and
self.install_data == "/usr/local"):
log.info("""
----------------------------------------------------------------
To enable tab completion, add the following to your '~/.bashrc':
source {0}
----------------------------------------------------------------
""".format(os.path.join(self.install_data,
'etc/bash_completion.d',
'catkin_tools-completion.bash')))
from distutils.core import setup
from distutils.dist import Distribution
dist = Distribution()
dist.parse_config_files()
dist.parse_command_line()
prefix = dist.get_option_dict('install').get('prefix',("default", sys.prefix))[1]
setup(
name='catkin_tools',
version='0.4.5',
python_requires='>=3.5',
packages=find_packages(exclude=['tests*', 'docs']),
package_data={
'catkin_tools': [
'notifications/resources/linux/catkin_icon.png',
'notifications/resources/linux/catkin_icon_red.png',
'verbs/catkin_shell_verbs.bash',
'docs/examples',
] + osx_notification_resources
},
data_files=get_data_files(prefix),
install_requires=install_requires,
author='William Woodall',
author_email='[email protected]',
maintainer='William Woodall',
maintainer_email='[email protected]',
url='http://catkin-tools.readthedocs.org/',
keywords=['catkin'],
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
],
description="Command line tools for working with catkin.",
long_description="Provides command line tools for working with catkin.",
license='Apache 2.0',
test_suite='tests',
entry_points={
'console_scripts': [
'catkin = catkin_tools.commands.catkin:main',
],
'catkin_tools.commands.catkin.verbs': [
'build = catkin_tools.verbs.catkin_build:description',
'clean = catkin_tools.verbs.catkin_clean:description',
'config = catkin_tools.verbs.catkin_config:description',
'create = catkin_tools.verbs.catkin_create:description',
'env = catkin_tools.verbs.catkin_env:description',
'init = catkin_tools.verbs.catkin_init:description',
'list = catkin_tools.verbs.catkin_list:description',
'locate = catkin_tools.verbs.catkin_locate:description',
'profile = catkin_tools.verbs.catkin_profile:description',
],
'catkin_tools.jobs': [
'catkin = catkin_tools.jobs.catkin:description',
'cmake = catkin_tools.jobs.cmake:description',
],
'catkin_tools.spaces': [
'build = catkin_tools.spaces.build:description',
'devel = catkin_tools.spaces.devel:description',
'install = catkin_tools.spaces.install:description',
'log = catkin_tools.spaces.log:description',
'source = catkin_tools.spaces.source:description',
],
},
cmdclass={'install': PermissiveInstall},
)