| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | # implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import subprocess |
| 17 | import sys |
| 18 | import os |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 19 | from setuptools import setup, find_packages |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 20 | from setuptools.command.install import install |
| 21 | |
| 22 | |
| 23 | class Install_osm_im(install): |
| 24 | """Generation of .py files from yang models""" |
| 25 | model_dir = "models/yang" |
| 26 | im_dir = "osm_im" |
| 27 | |
| 28 | def pipinstall(self, package): |
| 29 | """pip install for executable dependencies""" |
| 30 | subprocess.call([sys.executable, "-m", "pip", "install", package]) |
| 31 | |
| 32 | def run(self): |
| garciadeblas | 8aef22e | 2024-01-25 14:38:06 +0100 | [diff] [blame] | 33 | self.pipinstall('pyang==2.5.2') |
| 34 | self.pipinstall('pyangbind==0.8.1') |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 35 | import pyangbind |
| garciadeblas | 361145b | 2019-10-28 11:11:48 +0100 | [diff] [blame] | 36 | print("Using dir {}/{} for python artifacts".format(os.getcwd(), self.im_dir)) |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 37 | path = "{}/{}".format(os.getcwd(), self.im_dir) |
| sousaedu | 439ba4a | 2021-07-29 14:55:35 +0200 | [diff] [blame] | 38 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 39 | protoc_command = ["make", "models"] |
| 40 | if subprocess.call(protoc_command) != 0: |
| 41 | sys.exit(-1) |
| sousaedu | 439ba4a | 2021-07-29 14:55:35 +0200 | [diff] [blame] | 42 | |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 43 | # To ensure generated files are copied to the python installation folder |
| sousaedu | 439ba4a | 2021-07-29 14:55:35 +0200 | [diff] [blame] | 44 | install_path = "{}{}".format(self.install_lib, self.im_dir) |
| 45 | self.copy_tree(self.im_dir, install_path) |
| 46 | if os.path.isfile("{}/etsi-nfv-nsd.py".format(install_path)): |
| 47 | self.move_file( |
| 48 | "{}/etsi-nfv-nsd.py".format(install_path), "{}/etsi_nfv_nsd.py".format(install_path) |
| 49 | ) |
| 50 | if os.path.isfile("{}/etsi-nfv-vnfd.py".format(install_path)): |
| 51 | self.move_file( |
| 52 | "{}/etsi-nfv-vnfd.py".format(install_path), "{}/etsi_nfv_vnfd.py".format(install_path) |
| 53 | ) |
| 54 | |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 55 | install.run(self) |
| 56 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 57 | |
| 58 | setup( |
| 59 | name='osm_im', |
| garciadeblas | 825b76d | 2017-08-30 15:03:32 +0200 | [diff] [blame] | 60 | description='OSM Information Model', |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 61 | long_description=open('README.rst').read(), |
| Mike Marchetti | 09a2710 | 2018-09-24 15:05:51 -0400 | [diff] [blame] | 62 | version_command=('git describe --tags --long --dirty --match v*', 'pep440-git-full'), |
| beierlm | 5b3f4b6 | 2021-02-17 07:22:20 -0500 | [diff] [blame] | 63 | author='OSM Support', |
| 64 | author_email='osmsupport@etsi.org', |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 65 | packages=find_packages(), |
| 66 | include_package_data=True, |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 67 | setup_requires=['setuptools-version-command'], |
| 68 | test_suite='nose.collector', |
| Felipe Vicens | 65a6982 | 2019-09-25 14:19:33 +0200 | [diff] [blame] | 69 | url='https://osm.etsi.org/gitweb/?p=osm/IM.git;a=summary', |
| 70 | license='Apache 2.0', |
| 71 | cmdclass={'install': Install_osm_im}, |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 72 | ) |