Missing section 'services' in kdu, not included during SOL006 migration
[osm/IM.git] / setup.py
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
19 from setuptools import setup, find_packages
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):
33 self.pipinstall('pyang')
34 self.pipinstall('pyangbind')
35 import pyangbind
36 print("Using dir {}/{} for python artifacts".format(os.getcwd(), self.im_dir))
37 path = "{}/{}".format(os.getcwd(), self.im_dir)
38 protoc_command = ["make", "models"]
39 if subprocess.call(protoc_command) != 0:
40 sys.exit(-1)
41 # To ensure generated files are copied to the python installation folder
42 self.copy_tree(self.im_dir, "{}{}".format(self.install_lib, self.im_dir))
43 install.run(self)
44
45
46 setup(
47 name='osm_im',
48 description='OSM Information Model',
49 long_description=open('README.rst').read(),
50 version_command=('git describe --tags --long --dirty --match v*', 'pep440-git-full'),
51 author='Mike Marchetti',
52 author_email='mmarchetti@sandvine.com',
53 packages=find_packages(),
54 include_package_data=True,
55 setup_requires=['setuptools-version-command'],
56 install_requires=['pyang', 'pyangbind'],
57 test_suite='nose.collector',
58 url='https://osm.etsi.org/gitweb/?p=osm/IM.git;a=summary',
59 license='Apache 2.0',
60 cmdclass={'install': Install_osm_im},
61 )