1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import os
import sys
import subprocess
from setuptools import setup
from setuptools.command.build_py import build_py
sys.path.append('./vyos')
from defaults import directories
def packages(directory):
return [
_[0].replace('/','.')
for _ in os.walk(directory)
if os.path.isfile(os.path.join(_[0], '__init__.py'))
]
class GenerateProto(build_py):
ver = os.environ.get('OCAML_VERSION')
if ver:
proto_path = f'/opt/opam/{ver}/share/vyconf'
else:
proto_path = directories['proto_path']
def run(self):
# find all .proto files in vyconf proto_path
proto_files = []
for _, _, files in os.walk(self.proto_path):
for file in files:
if file.endswith('.proto'):
proto_files.append(file)
# compile each .proto file to Python
for proto_file in proto_files:
subprocess.check_call(
[
'protoc',
'--python_out=vyos/proto',
f'--proto_path={self.proto_path}/',
proto_file,
]
)
build_py.run(self)
setup(
name = "vyos",
version = "1.3.0",
author = "VyOS maintainers and contributors",
author_email = "maintainers@vyos.net",
description = ("VyOS configuration libraries."),
license = "LGPLv2+",
keywords = "vyos",
url = "http://www.vyos.io",
packages = packages('vyos'),
long_description="VyOS configuration libraries",
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Utilities",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
],
entry_points={
"console_scripts": [
"config-mgmt = vyos.config_mgmt:run",
],
},
cmdclass={
'build_py': GenerateProto,
},
)
|