1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at:
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
13 from __future__ import print_function
16 from distutils.command.build_ext import build_ext
17 from distutils.errors import CCompilerError, DistutilsExecError, \
18 DistutilsPlatformError
25 # Try to set the version from the generated ovs/version.py
26 exec(open("ovs/version.py").read())
28 print("Ensure version.py is created by running make python/ovs/version.py",
32 ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
33 if sys.platform == 'win32':
34 ext_errors += (IOError, ValueError)
37 class BuildFailed(Exception):
41 class try_build_ext(build_ext):
42 # This class allows C extension building to fail
43 # NOTE: build_ext is not a new-style class
48 except DistutilsPlatformError:
51 def build_extension(self, ext):
53 build_ext.build_extension(self, ext)
60 description='Open vSwitch library',
62 url='http://www.openvswitch.org/',
63 author='Open vSwitch',
64 author_email='dev@openvswitch.org',
65 packages=['ovs', 'ovs.db', 'ovs.unixctl'],
66 keywords=['openvswitch', 'ovs', 'OVSDB'],
69 'Development Status :: 5 - Production/Stable',
70 'Topic :: Database :: Front-Ends',
71 'Topic :: Software Development :: Libraries :: Python Modules',
72 'Topic :: System :: Networking',
73 'License :: OSI Approved :: Apache Software License',
74 'Programming Language :: Python :: 2',
75 'Programming Language :: Python :: 2.7',
76 'Programming Language :: Python :: 3',
77 'Programming Language :: Python :: 3.4',
79 ext_modules=[setuptools.Extension("ovs._json", sources=["ovs/_json.c"],
80 libraries=['openvswitch'])],
81 cmdclass={'build_ext': try_build_ext},
85 setuptools.setup(**setup_args)
87 BUILD_EXT_WARNING = ("WARNING: The C extension could not be compiled, "
88 "speedups are not enabled.")
90 print(BUILD_EXT_WARNING)
91 print("Failure information, if any, is above.")
92 print("Retrying the build without the C extension.")
95 del(setup_args['cmdclass'])
96 del(setup_args['ext_modules'])
97 setuptools.setup(**setup_args)