blob: d10b5c625968b7fb94ee68fa163d77db650197ae [file] [log] [blame]
Scott Bakerbcbd4cc2018-03-07 13:50:21 -08001#!/usr/bin/env python
Matteo Scandolod2044a42017-08-07 16:08:28 -07002
3# Copyright 2017-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Scott Baker96b995a2017-02-15 16:21:12 -080017import os
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080018from setuptools.command.install import install
19
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080020try:
21 from xosutil.autoversion_setup import setup_with_auto_version as setup
22except ImportError:
23 # xosutil is not installed. Expect this to happen when we build an egg, in which case xosgenx.version will
24 # automatically have the right version.
25 from setuptools import setup
26
27from xosapi.version import __version__
Scott Baker96b995a2017-02-15 16:21:12 -080028
Zack Williams045b63d2019-01-22 16:30:57 -070029CHAMELEON_DIR = "xosapi/chameleon"
Scott Baker96b995a2017-02-15 16:21:12 -080030
31if not os.path.exists(CHAMELEON_DIR):
32 raise Exception("%s does not exist!" % CHAMELEON_DIR)
33
34if not os.path.exists(os.path.join(CHAMELEON_DIR, "protos/schema_pb2.py")):
35 raise Exception("Please make the chameleon protos")
36
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080037# Chameleon requires these files have executable permission set.
Zack Williams045b63d2019-01-22 16:30:57 -070038
39
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080040class InstallFixChameleonPermissions(install):
41 def run(self):
42 install.run(self)
43 for filepath in self.get_outputs():
Zack Williams045b63d2019-01-22 16:30:57 -070044 if filepath.endswith(
45 "chameleon/protoc_plugins/gw_gen.py"
46 ) or filepath.endswith("chameleon/protoc_plugins/swagger_gen.py"):
47 os.chmod(filepath, 0o777)
Scott Baker96b995a2017-02-15 16:21:12 -080048
Scott Baker96b995a2017-02-15 16:21:12 -080049
Zack Williams045b63d2019-01-22 16:30:57 -070050setup_result = setup(
51 name="xosapi",
52 version=__version__,
53 cmdclass={"install": InstallFixChameleonPermissions},
54 description="XOS api client",
55 package_dir={"xosapi.chameleon": CHAMELEON_DIR},
56 packages=[
57 "xosapi.chameleon.grpc_client",
58 "xosapi.chameleon.protos",
59 "xosapi.chameleon.utils",
60 "xosapi.chameleon.protoc_plugins",
61 "xosapi",
62 "xosapi.convenience",
63 ],
64 py_modules=["xosapi.chameleon.__init__"],
65 include_package_data=True,
66 package_data={
67 "xosapi.chameleon.protos": ["*.proto"],
68 "xosapi.chameleon.protoc_plugins": ["*.desc"],
69 },
70 scripts=["xossh"],
71)