Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 2 | |
| 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 Baker | 96b995a | 2017-02-15 16:21:12 -0800 | [diff] [blame] | 17 | import os |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 18 | from setuptools.command.install import install |
| 19 | |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 20 | try: |
| 21 | from xosutil.autoversion_setup import setup_with_auto_version as setup |
| 22 | except 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 | |
| 27 | from xosapi.version import __version__ |
Scott Baker | 96b995a | 2017-02-15 16:21:12 -0800 | [diff] [blame] | 28 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 29 | |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 30 | class InstallFixChameleonPermissions(install): |
Scott Baker | bef5fd9 | 2019-02-21 10:24:02 -0800 | [diff] [blame^] | 31 | # Chameleon requires these files have executable permission set, |
| 32 | # but setup.py installs them without the execute bit. |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 33 | def run(self): |
| 34 | install.run(self) |
| 35 | for filepath in self.get_outputs(): |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 36 | if filepath.endswith( |
Scott Baker | bef5fd9 | 2019-02-21 10:24:02 -0800 | [diff] [blame^] | 37 | "chameleon_client/protoc_plugins/gw_gen.py" |
| 38 | ): |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 39 | os.chmod(filepath, 0o777) |
Scott Baker | 96b995a | 2017-02-15 16:21:12 -0800 | [diff] [blame] | 40 | |
Scott Baker | 96b995a | 2017-02-15 16:21:12 -0800 | [diff] [blame] | 41 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 42 | setup_result = setup( |
| 43 | name="xosapi", |
| 44 | version=__version__, |
| 45 | cmdclass={"install": InstallFixChameleonPermissions}, |
| 46 | description="XOS api client", |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 47 | packages=[ |
Scott Baker | bef5fd9 | 2019-02-21 10:24:02 -0800 | [diff] [blame^] | 48 | "xosapi.chameleon_client", |
| 49 | "xosapi.chameleon_client.protos", |
| 50 | "xosapi.chameleon_client.protoc_plugins", |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 51 | "xosapi", |
| 52 | "xosapi.convenience", |
| 53 | ], |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 54 | scripts=["xossh"], |
| 55 | ) |