Skip to content

Commit

Permalink
[sonic-yang-mgmt/setup.py]: Removing the part where build dependencie…
Browse files Browse the repository at this point in the history
…s are installed in setup.py. (#4657)

Changes:
-- Removing the part where build dependencies are installed in setup.py.
-- Adding build dependencies in corresponsing rules\..*.mk file.

Signed-off-by: Praveen Chaudhary pchaudhary@linkedin.com
  • Loading branch information
Praveen Chaudhary authored May 28, 2020
1 parent 6d0f8dc commit 8720192
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 60 deletions.
7 changes: 5 additions & 2 deletions rules/sonic-yang-mgmt-py2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
SONIC_YANG_MGMT_PY = sonic_yang_mgmt-1.0-py2-none-any.whl
$(SONIC_YANG_MGMT_PY)_SRC_PATH = $(SRC_PATH)/sonic-yang-mgmt
$(SONIC_YANG_MGMT_PY)_PYTHON_VERSION = 2
$(SONIC_YANG_MGMT_PY)_DEBS_DEPENDS = $(LIBYANG)
$(SONIC_YANG_MGMT_PY)_DEPENDS = $(SONIC_YANG_MODELS_PY3)
$(SONIC_YANG_MGMT_PY)_DEBS_DEPENDS = $(LIBYANG) $(LIBYANG_CPP) $(LIBYANG_PY2) \
$(LIBYANG_PY3)
$(SONIC_YANG_MGMT_PY)_DEPENDS = $(SONIC_YANG_MODELS_PY3)
$(SONIC_YANG_MGMT_PY)_RDEPENDS = $(SONIC_YANG_MODELS_PY3) $(LIBYANG) \
$(LIBYANG_CPP) $(LIBYANG_PY2)

SONIC_PYTHON_WHEELS += $(SONIC_YANG_MGMT_PY)
3 changes: 2 additions & 1 deletion rules/sonic-yang-models-py3.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SONIC_YANG_MODELS_PY3 = sonic_yang_models-1.0-py3-none-any.whl
$(SONIC_YANG_MODELS_PY3)_SRC_PATH = $(SRC_PATH)/sonic-yang-models
$(SONIC_YANG_MODELS_PY3)_PYTHON_VERSION = 3
$(SONIC_YANG_MODELS_PY3)_DEBS_DEPENDS = $(LIBYANG)
$(SONIC_YANG_MODELS_PY3)_DEBS_DEPENDS = $(LIBYANG) $(LIBYANG_CPP) \
$(LIBYANG_PY2) $(LIBYANG_PY3)

SONIC_PYTHON_WHEELS += $(SONIC_YANG_MODELS_PY3)
export SONIC_YANG_MODELS_PY3
34 changes: 1 addition & 33 deletions src/sonic-yang-mgmt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,10 @@

from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from os import system, environ
from os import system
from sys import exit
import pytest

# find path of pkgs from os environment vars
prefix = '../../'; debs = environ["IMAGE_DISTRO_DEBS_PATH"]
wheels = environ["PYTHON_WHEELS_PATH"]
wheels_path = '{}/{}'.format(prefix, wheels)
deps_path = '{}/{}'.format(prefix, debs)
# dependencies
libyang = '{}/{}'.format(deps_path, environ["LIBYANG"])
libyangCpp = '{}/{}'.format(deps_path, environ["LIBYANG_CPP"])
libyangPy2 = '{}/{}'.format(deps_path, environ["LIBYANG_PY2"])
libyangPy3 = '{}/{}'.format(deps_path, environ["LIBYANG_PY3"])
sonicYangModels = '{}/{}'.format(wheels_path, environ["SONIC_YANG_MODELS_PY3"])

# important reuirements parameters
build_requirements = [libyang, libyangCpp, libyangPy2, libyangPy3, sonicYangModels,]

setup_requirements = ['pytest-runner']

test_requirements = ['pytest>=3']
Expand All @@ -37,23 +22,6 @@ class pkgBuild(build_py):
"""Custom Build PLY"""

def run (self):
# install libyang and sonic_yang_models
for req in build_requirements:
if '.deb' in req:
pkg_install_cmd = "sudo dpkg -i {}".format(req)
if (system(pkg_install_cmd)):
print("{} installation failed".format(req))
exit(1)
else:
print("{} installed".format(req))
elif '.whl' in req:
pkg_install_cmd = "pip3 install {}".format(req)
if (system(pkg_install_cmd)):
print("{} installation failed".format(req))
exit(1)
else:
print("{} installed".format(req))

# run pytest for libyang python APIs
self.pytest_args = []
errno = pytest.main(self.pytest_args)
Expand Down
25 changes: 1 addition & 24 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,9 @@

from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from os import system, environ
from os import system
from sys import exit

# find path of pkgs from environment vars
prefix = '../../'; debs = environ["IMAGE_DISTRO_DEBS_PATH"]
deps_path = '{}/{}'.format(prefix, debs)
# dependencies
libyang = '{}/{}'.format(deps_path, environ["LIBYANG"])
libyangCpp = '{}/{}'.format(deps_path, environ["LIBYANG_CPP"])
libyangPy2 = '{}/{}'.format(deps_path, environ["LIBYANG_PY2"])
libyangPy3 = '{}/{}'.format(deps_path, environ["LIBYANG_PY3"])

# important reuirements parameters
build_requirements = [libyang, libyangCpp, libyangPy2, libyangPy3,]

setup_requirements = ['pytest-runner']

test_requirements = ['pytest>=3']
Expand All @@ -33,16 +21,6 @@ class pkgBuild(build_py):
"""Custom Build PLY"""

def run (self):
# install libyang
for req in build_requirements:
if '.deb'in req:
pkg_install_cmd = "sudo dpkg -i {}".format(req)
if (system(pkg_install_cmd)):
print("{} installation failed".format(req))
exit(1)
else:
print("{} installed".format(req))

# json file for YANG model test cases.
test_yangJson_file = './tests/yang_model_tests/yangTest.json'
# YANG models are in below dir
Expand All @@ -53,7 +31,6 @@ def run (self):
test_yang_cmd = "python {} -f {} -y {}".format(yang_test_py, test_yangJson_file, yang_model_dir)
if (system(test_yang_cmd)):
print("YANG Tests failed\n")
# below line will be uncommented after libyang python support PR #
exit(1)
else:
print("YANG Tests passed\n")
Expand Down

0 comments on commit 8720192

Please sign in to comment.