-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py.in
243 lines (212 loc) · 7.4 KB
/
setup.py.in
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# ##### BEGIN LICENSE BLOCK #####
#
# Copyright (C) 2014-2015, Peter Hatina <[email protected]>
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 2.1 of the
# License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
#
# ##### END LICENSE BLOCK #####
# TODO:
# - default namespace
# - default trust store
# - pass configured values from configure script
'''
LMIWBEM setup script.
Python version for compilation is set at runtime:
python2 setup.py [command] or
python3 setup.py [command]
'''
import os
import os.path
import subprocess
import sys
from collections import namedtuple
from distutils.core import setup
from distutils.core import Extension
from distutils.command.build import build
lmiwbem_docgen = '@top_srcdir@/util/docgen'
# prefix == @top_srcdir@
lmiwbem_pydocs = [
'src/obj/cim/lmiwbem_parameter.pydoc',
'src/obj/cim/lmiwbem_instance.pydoc',
'src/obj/cim/lmiwbem_instance_name.pydoc',
'src/obj/cim/lmiwbem_class.pydoc',
'src/obj/cim/lmiwbem_method.pydoc',
'src/obj/cim/lmiwbem_class_name.pydoc',
'src/obj/cim/lmiwbem_qualifier.pydoc',
'src/obj/cim/lmiwbem_property.pydoc',
'src/obj/lmiwbem_listener.pydoc',
'src/obj/lmiwbem_slp.pydoc',
'src/obj/lmiwbem_connection.pydoc',
'src/obj/lmiwbem_nocasedict.pydoc'
]
class lmiwbem_build(build):
'''
Helper class for build command. It creates a temporary Python module named
lmiwbem.
'''
def setup(self):
try:
os.symlink('src/lmiwbem', 'lmiwbem')
except OSError as e:
raise OSError(e.args[0], 'Can\'t create \'lmiwbem\' module directory')
def generate_docs(self):
pydocs = [
os.path.join('@top_srcdir@', pydoc)
for pydoc in lmiwbem_pydocs
]
headers = [
os.path.join(
'@top_builddir@',
os.path.splitext(header)[0] + '_pydoc.h')
for header in lmiwbem_pydocs
]
# Generate pydoc headers
for pydoc, header in zip(pydocs, headers):
print('docgen %s %s' % (pydoc, header))
subprocess.check_call([lmiwbem_docgen, pydoc, header])
def teardown(self):
os.unlink('lmiwbem')
def run(self):
self.setup()
self.generate_docs()
build.run(self)
self.teardown()
# User defined values from configure script.
with_listener = '@WITH_LISTENER@' == 'yes'
with_slp = '@WITH_SLP@' == 'yes'
with_enum_ctx = '@WITH_ENUM_CTX@' == 'yes'
with_wsman = '@WITH_WSMAN@' == 'yes'
# LMIWBEM extra compile args.
lmiwbem_extra_compile_args = '@CXXFLAGS@'.split(' ')
# LMIWBEM include directories.
lmiwbem_include_dirs = [
'@top_builddir@',
'@top_srcdir@/src',
'@top_srcdir@/src/obj',
'@top_srcdir@/src/obj/cim',
'@top_srcdir@/src/util',
'@top_builddir@/src',
'@top_builddir@/src/obj',
'@top_builddir@/src/obj/cim']
# LMIWBEM defines.
lmiwbem_defines = [('@PEGASUS_PLATFORM@', None)]
# LMIWBEM source files.
lmiwbem_sources = [
'util/lmiwbem_convert.cpp',
'util/lmiwbem_string.cpp',
'util/lmiwbem_util.cpp',
'lmiwbem_gil.cpp',
'obj/lmiwbem_connection.cpp',
'obj/cim/lmiwbem_class.cpp',
'obj/cim/lmiwbem_instance.cpp',
'obj/cim/lmiwbem_instance_name.cpp',
'obj/cim/lmiwbem_method.cpp',
'obj/cim/lmiwbem_property.cpp',
'obj/cim/lmiwbem_qualifier.cpp',
'obj/cim/lmiwbem_class_name.cpp',
'obj/cim/lmiwbem_types.cpp',
'obj/cim/lmiwbem_parameter.cpp',
'obj/cim/lmiwbem_constants.cpp',
'obj/cim/lmiwbem_value.cpp',
'obj/lmiwbem_config.cpp',
'obj/lmiwbem_nocasedict.cpp',
'lmiwbem_client_cimxml.cpp',
'lmiwbem_urlinfo.cpp',
'lmiwbem_mutex.cpp',
'lmiwbem.cpp',
'lmiwbem_client.cpp',
'lmiwbem_exception.cpp']
# LMIWBEM default libraries.
lmiwbem_libraries = ['pegclient', 'pegcommon']
# We do not provide --with-python3 CLI option. Proper boost::python library is
# chosen at runtime.
if sys.version_info.major == 2:
lmiwbem_libraries.append('boost_python')
elif sys.version_info.major == 3:
lmiwbem_libraries.append('boost_python3')
else:
raise RuntimeError('Unsupported Python version')
# Build with indication listener.
if with_listener:
lmiwbem_defines.append(('HAVE_PEGASUS_LISTENER', None))
lmiwbem_sources.append('obj/lmiwbem_listener.cpp')
lmiwbem_libraries.append('peglistener')
# Build with SLP support.
if with_slp:
lmiwbem_defines.append(('HAVE_SLP', None))
lmiwbem_sources.append('obj/lmiwbem_slp.cpp')
lmiwbem_libraries.append('slp')
# Build with Enumeration Context.
if with_enum_ctx:
lmiwbem_defines.append(('HAVE_PEGASUS_ENUMERATION_CONTEXT', None))
lmiwbem_sources.extend([
'obj/cim/lmiwbem_enum_ctx.cpp',
'obj/lmiwbem_connection_pull.cpp'])
# Build with OpenWSMAN support.
if with_wsman:
lmiwbem_include_dirs.extend([
'/usr/include/openwsman',
'/usr/include/openwsman/cpp'])
lmiwbem_defines.append(('HAVE_OPENWSMAN', None))
lmiwbem_sources.extend([
'lmiwbem_client_wsman_request.cpp',
'lmiwbem_client_wsman.cpp',
'lmiwbem_client_wsman_builder.cpp'])
lmiwbem_libraries.extend(['wsman', 'wsman_clientpp'])
srcdir = os.path.normpath('@abs_srcdir@/src')
# C++ extension
lmiwbem_core = Extension(
'lmiwbem.lmiwbem_core',
define_macros=lmiwbem_defines,
extra_compile_args=lmiwbem_extra_compile_args,
include_dirs=lmiwbem_include_dirs,
sources=[os.path.join(srcdir, source) for source in lmiwbem_sources],
libraries=lmiwbem_libraries)
setup(
name='lmiwbem',
version='@VERSION@',
license='LGPLv2+',
author='Peter Hatina',
author_email='[email protected]',
url='https://github.com/phatina/lmiwbem',
description='LMIWBEM is a Python library, which performs CIM operations'
'using CIM-XML protocol.',
ext_modules=[lmiwbem_core],
packages=['lmiwbem'],
cmdclass={'build': lmiwbem_build},
classifiers=[
'License :: OSI Approved :: GNU Lesser General Public License v2 or'
'later (LGPLv2+)',
'Operating System :: POSIX :: Linux',
'Topic :: System :: Systems Administration',
'Programming Language :: C++',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Intended Audience :: Developers',
'Environment :: Console',
],
long_description=\
'''
LMIWBEM is a Python library, which performs CIM operations using
CIM-XML protocol. The library tries to mimic PyWBEM, but does things in
different way:
- TOG-Pegasus client's library is used for communication
- lazy evaluation of CIM objects is used
- some minor API was added for performance reasons
''')