Fix bug 1614 - fixing build to allow python3 -m build 88/11088/3
authorsousaedu <eduardo.sousa@canonical.com>
Thu, 29 Jul 2021 12:55:35 +0000 (14:55 +0200)
committersousaedu <eduardo.sousa@canonical.com>
Tue, 3 Aug 2021 15:23:19 +0000 (17:23 +0200)
Change-Id: Id2db32f81dd4f4e7b411ebc2a189f6817a26d63c
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
.gitignore
MANIFEST.in
Makefile
osm_im/validation.py
setup.py

index f1e4221..fc7eb3c 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+venv
+
+.tox
+
 *.pyc
 .cache
 
@@ -36,7 +40,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
index a4fe252..93778db 100644 (file)
@@ -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
index 703f73c..e7e9978 100644 (file)
--- 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
index 6cc4f0d..561e716 100644 (file)
@@ -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
 
index 71c7eae..ec75988 100644 (file)
--- 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)