summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-09-07 10:54:36 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-09-07 11:00:56 +0800
commit41da4cef96c039b39eaaa86ba4d922885f319d81 (patch)
tree3001612db3c55f4b98df3984e94c8033a2226341 /tosca2heat/heat-translator
parentdd361d8d9df7a69a4fc7c004db5b959440a024c2 (diff)
Refactor heat-translator setup.py
Overwrite setup.py in heat-translator project to uninstall openstack heat-translator before build/install nfv-heattranslator. JIRA: PARSER-151 Change-Id: I65da014439e3c07b866b3baf8643e569d813165c Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/heat-translator')
-rw-r--r--tosca2heat/heat-translator/setup.cfg2
-rw-r--r--tosca2heat/heat-translator/setup.py47
2 files changed, 48 insertions, 1 deletions
diff --git a/tosca2heat/heat-translator/setup.cfg b/tosca2heat/heat-translator/setup.cfg
index 863b97d..2a10811 100644
--- a/tosca2heat/heat-translator/setup.cfg
+++ b/tosca2heat/heat-translator/setup.cfg
@@ -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.
diff --git a/tosca2heat/heat-translator/setup.py b/tosca2heat/heat-translator/setup.py
index 566d844..bf9aa00 100644
--- a/tosca2heat/heat-translator/setup.py
+++ b/tosca2heat/heat-translator/setup.py
@@ -14,8 +14,13 @@
# 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)