Merge "Refactor heat-translator setup.py"
authorjulien zhang <zhang.jun3g@zte.com.cn>
Sun, 10 Sep 2017 14:37:28 +0000 (14:37 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Sun, 10 Sep 2017 14:37:28 +0000 (14:37 +0000)
tosca2heat/heat-translator/setup.cfg
tosca2heat/heat-translator/setup.py

index 863b97d..2a10811 100644 (file)
@@ -1,5 +1,5 @@
 [metadata]
-name = heat-translator
+name = nfv-heattranslator
 version =
 url = https://wiki.opnfv.org/display/parser
 summary = Tool to translate non-heat templates to Heat Orchestration Template in nfv.
index 566d844..bf9aa00 100644 (file)
 # limitations under the License.
 
 # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
+import os
 import setuptools
 
+from distutils.command.install_data import install_data
+from setuptools.command.build_py import build_py
+from setuptools.command.install import install
+
 # In python < 2.7.4, a lazy loading of package `pbr` will break
 # setuptools if some other modules registered functions in `atexit`.
 # solution from: http://bugs.python.org/issue15881#msg170215
@@ -24,6 +29,48 @@ try:
 except ImportError:
     pass
 
+
+class HeatTranslator_build_py(build_py):
+    """Override build_py to call customized build."""
+
+    def run(self):
+        print(" ===  Before nfv heat translator build === ")
+        # self.run_command('xxx')
+        super(HeatTranslator_build_py, self).run()
+        print(" ===  After nfv heat heat translator build === ")
+
+
+class HeatTranslator_install(install):
+    """Override install to call customized install."""
+
+    def run(self):
+        print(" ===  Before nfv heat translator install === ")
+        # Make sure uninstall toscaparser from openstack
+        os.system("pip uninstall -y heat-translator")
+
+        super(HeatTranslator_install, self).run(self)
+        # Custom stuff here
+        # distutils.command.install actually has some nice helper methods
+        # and interfaces. I strongly suggest reading the docstrings.
+        print(" === After nfv heat translator install === ")
+
+
+class HeatTranslator_post_install(install_data):
+    """Override install_data to call customized install_data."""
+
+    def run(self):
+        print(" === Before nfv heat translator post install data === ")
+        # Call parent
+        super(HeatTranslator_post_install, self).run(self)
+        # Execute commands
+        print(" === After nfv heat translator post install data ===")
+
+
 setuptools.setup(
     setup_requires=['pbr>=2.0.0'],
+    cmdclass={
+        "build_py": HeatTranslator_build_py,
+        "install_data": HeatTranslator_install,
+        "post_install": HeatTranslator_post_install,
+    },
     pbr=True)