From c80c6767915b086fb41f6c81fbc6161e2b30ece1 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 5 Jun 2015 12:21:51 +0000 Subject: Set PYTHONPATH when running deployment extensions After moving deployment extensions into the definitions repository, but they need access to shared code, so deployment extensions need to import code which lives in definitions. However morph runs a copy of them in a temporary directory. Version 5 will allow deployment extensions to depend only on code which is also in definitions and the Python standard library, though they may also include code from elsewhere as described in PYTHONPATH. Change-Id: I998f01830656a5118bba1e579f649ec98f5f82c6 --- morphlib/plugins/deploy_plugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index c0018edd..42d27ff3 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -507,6 +507,14 @@ class DeployPlugin(cliapp.Plugin): deployment_type, location = deployment_type_and_location( system_id, final_env, is_upgrade) + extensions_dir = os.path.join( + root_repo_dir.dirname, + os.path.dirname(deployment_type)) + if 'PYTHONPATH' in final_env: + final_env['PYTHONPATH'] += ':%s' % extensions_dir + else: + final_env['PYTHONPATH'] = extensions_dir + components = self._sanitise_morphology_paths( deploy_params.get('partial-deploy-components', []), sb) if self.app.settings['partial']: -- cgit v1.2.1