forked from ANISH-GOTTAPU/snappi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
98 lines (89 loc) · 2.96 KB
/
setup.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
To build distribution: python setup.py sdist bdist_wheel --universal
"""
import os
import setuptools
import openapiart
import requests
import shutil
pkg_name = "snappi"
go_pkg_name = "gosnappi"
model_protobuf_name = "otg"
version = "0.6.16"
models_version = "0.6.10"
# read long description from readme.md
base_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(base_dir, "readme.md")) as fd:
long_description = fd.read()
# download openapi.yaml
openapi_url = "https://github.com/open-traffic-generator/models/releases/download/v{version}/openapi.yaml".format(
version=models_version
)
response = requests.request("GET", openapi_url, allow_redirects=True)
assert response.status_code == 200
with open(os.path.join("openapi.yaml"), "wb") as fp:
fp.write(response.content)
openapiart.OpenApiArt(
api_files=["openapi.yaml"],
protobuf_name=model_protobuf_name,
artifact_dir="artifacts",
extension_prefix=pkg_name,
).GeneratePythonSdk(package_name=pkg_name).GenerateGoSdk(
package_dir="github.com/open-traffic-generator/snappi/%s" % go_pkg_name, package_name=go_pkg_name
)
if os.path.exists(pkg_name):
shutil.rmtree(pkg_name, ignore_errors=True)
# remove unwanted files
shutil.copytree(os.path.join("artifacts", pkg_name), pkg_name)
shutil.copyfile(
os.path.join(base_dir, "artifacts", model_protobuf_name + ".proto"),
os.path.join(base_dir, model_protobuf_name + ".proto")
)
shutil.rmtree("artifacts", ignore_errors=True)
for name in os.listdir(pkg_name):
path = os.path.join(pkg_name, name)
if "pb2" in path:
os.remove(path)
else:
print(path + " will be published")
doc_dir = os.path.join(pkg_name, "docs")
os.mkdir(doc_dir)
shutil.move("openapi.yaml", doc_dir)
with open("models-release", "w") as out:
out.write("v" + models_version)
setuptools.setup(
name=pkg_name,
version=version,
description="The Snappi Open Traffic Generator Python Package",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/open-traffic-generator/snappi",
author="ajbalogh",
author_email="[email protected]",
license="MIT",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing :: Traffic Generation",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
],
keywords="snappi testing open traffic generator automation",
include_package_data=True,
packages=[pkg_name],
python_requires=">=2.7, <4",
install_requires=[
"requests",
"pyyaml",
"jsonpath-ng",
"typing",
"typing-extensions",
],
extras_require={
"ixnetwork": ["snappi_ixnetwork==0.5.4"],
"trex": ["snappi_trex"],
"convergence": ["snappi_convergence==0.2.1"],
"testing": ["pytest", "flask"],
},
)