From 439ba4a8ca0e3504099801abd33fc21de462e6bc Mon Sep 17 00:00:00 2001 From: sousaedu Date: Thu, 29 Jul 2021 14:55:35 +0200 Subject: [PATCH] Fix bug 1613 - fixing build to allow python3 -m build Change-Id: Id2db32f81dd4f4e7b411ebc2a189f6817a26d63c Signed-off-by: sousaedu --- .gitignore | 7 +++++++ MANIFEST.in | 4 +++- Makefile | 12 +++++++++--- osm_im/validation.py | 3 +-- setup.py | 14 +++++++++++++- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6fa1dcf..3dee5c4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +venv + +.tox + *.pyc .cache @@ -40,7 +44,10 @@ osm_im/nst.py osm_im/nsi.py osm_im/osm.yaml osm_im/etsi-nfv-nsd.py +osm_im/etsi_nfv_nsd.py osm_im/etsi-nfv-vnfd.py +osm_im/etsi_nfv_vnfd.py +sol006_model #Pyang and other tools' folders pyangbind diff --git a/MANIFEST.in b/MANIFEST.in index a4fe252..93778db 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,5 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +include Makefile recursive-include osm_im *.py *.txt -recursive-include models *.yang \ No newline at end of file +recursive-include models *.yang +recursive-include patch *.patch \ No newline at end of file diff --git a/Makefile b/Makefile index 703f73c..e7e9978 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ PYANG_OPTIONS := -Werror all: models trees openapi_schemas $(MAKE) package -models: sol006_deps $(PYTHON_MODELS) +models: sol006_deps $(PYTHON_MODELS) rename_etsi_nfv_py trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES) @@ -89,7 +89,7 @@ $(TREES_DIR): osm.yaml: yang-ietf yang2swagger $(Q)echo generating $@ - $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.11/swagger-generator-cli-1.1.11-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@ + $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.14/swagger-generator-cli-1.1.14-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@ yang-ietf: $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-yang-types.yang @@ -101,7 +101,7 @@ yang2swagger: $(Q)mkdir -p ${HOME}/.m2 $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml git clone https://github.com/bartoszm/yang2swagger.git - git -C yang2swagger checkout tags/1.1.11 + git -C yang2swagger checkout tags/1.1.14 mvn -f yang2swagger/pom.xml clean install package: @@ -116,5 +116,11 @@ sol006_deps: $(Q)patch -p2 < patch/deref_warnings.patch $(Q)patch -p2 < patch/nested_workaround.patch +rename_etsi_nfv_py: + mv osm_im/etsi-nfv-nsd.py osm_im/etsi_nfv_nsd.py + mv osm_im/etsi-nfv-vnfd.py osm_im/etsi_nfv_vnfd.py + clean: $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR) + $(Q)rm -rf debian/osm-imdocs.install osm_im/etsi_nfv_nsd.py osm_im/etsi_nfv_vnfd.py osm_im/nsd.py + $(Q)rm -rf osm_im/nsi.py osm_im/nst.py osm_im/osm.yaml osm_im/vnfd.py diff --git a/osm_im/validation.py b/osm_im/validation.py index 6cc4f0d..561e716 100644 --- a/osm_im/validation.py +++ b/osm_im/validation.py @@ -18,8 +18,7 @@ import importlib from osm_im.vnfd import vnfd as vnfd_im from osm_im.nsd import nsd as nsd_im from osm_im.nst import nst as nst_im -etsi_nfv_vnfd = importlib.import_module("osm_im.etsi-nfv-vnfd") -etsi_nfv_nsd = importlib.import_module("osm_im.etsi-nfv-nsd") +from osm_im import etsi_nfv_vnfd, etsi_nfv_nsd from pyangbind.lib.serialise import pybindJSONDecoder import pyangbind.lib.pybindJSON as pybindJSON diff --git a/setup.py b/setup.py index 71c7eae..ec75988 100644 --- a/setup.py +++ b/setup.py @@ -35,11 +35,23 @@ class Install_osm_im(install): import pyangbind print("Using dir {}/{} for python artifacts".format(os.getcwd(), self.im_dir)) path = "{}/{}".format(os.getcwd(), self.im_dir) + protoc_command = ["make", "models"] if subprocess.call(protoc_command) != 0: sys.exit(-1) + # To ensure generated files are copied to the python installation folder - self.copy_tree(self.im_dir, "{}{}".format(self.install_lib, self.im_dir)) + install_path = "{}{}".format(self.install_lib, self.im_dir) + self.copy_tree(self.im_dir, install_path) + if os.path.isfile("{}/etsi-nfv-nsd.py".format(install_path)): + self.move_file( + "{}/etsi-nfv-nsd.py".format(install_path), "{}/etsi_nfv_nsd.py".format(install_path) + ) + if os.path.isfile("{}/etsi-nfv-vnfd.py".format(install_path)): + self.move_file( + "{}/etsi-nfv-vnfd.py".format(install_path), "{}/etsi_nfv_vnfd.py".format(install_path) + ) + install.run(self) -- 2.25.1