forked from phatina/python-lmiwbem
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py.in
158 lines (138 loc) · 4.77 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
# ##### BEGIN LICENSE BLOCK #####
#
# Copyright (C) 2014, Peter Hatina <phatina@redhat.com>
#
# 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 sys
from collections import namedtuple
from distutils.core import setup
from distutils.core import Extension
from distutils.command.build import build
class lmiwbem_build(build):
"""
Helper class for build command. It creates a temporary Python module named
lmiwbem.
"""
def run(self):
try:
os.symlink("src/lmiwbem", "lmiwbem")
except OSError as e:
raise OSError(e.args[0], "Can't create 'lmiwbem' module directory")
build.run(self)
os.unlink("lmiwbem")
# User defined values from configure script.
with_listener = "@WITH_LISTENER@" == "yes"
with_slp = "@WITH_SLP@" == "yes"
# LMIWBEM defines.
lmiwbem_defines = [("@PEGASUS_PLATFORM@", None)]
# LMIWBEM source files.
lmiwbem_sources = [
"lmiwbem_addr.cpp",
"lmiwbem_class.cpp",
"lmiwbem_class_name.cpp",
"lmiwbem_client.cpp",
"lmiwbem_connection.cpp",
"lmiwbem_constants.cpp",
"lmiwbem.cpp",
"lmiwbem_exception.cpp",
"lmiwbem_extract.cpp",
"lmiwbem_instance.cpp",
"lmiwbem_instance_name.cpp",
"lmiwbem_method.cpp",
"lmiwbem_nocasedict.cpp",
"lmiwbem_parameter.cpp",
"lmiwbem_property.cpp",
"lmiwbem_qualifier.cpp",
"lmiwbem_types.cpp",
"lmiwbem_util.cpp",
"lmiwbem_value.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("lmiwbem_listener.cpp")
lmiwbem_libraries.append("peglistener")
# Build with SLP support.
if with_slp:
lmiwbem_defines.append(("HAVE_SLP", None))
lmiwbem_sources.append("lmiwbem_slp.cpp")
lmiwbem_libraries.append("slp")
srcdir = os.path.normpath("@abs_srcdir@/src")
# C++ extension
lmiwbem_core = Extension(
"lmiwbem.lmiwbem_core",
define_macros=lmiwbem_defines,
include_dirs=["@top_builddir@"],
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="phatina@redhat.com",
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
""")