diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-06-05 12:21:51 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-12 08:58:05 +0000 |
commit | c80c6767915b086fb41f6c81fbc6161e2b30ece1 (patch) | |
tree | 741b1b6c7b31bc119dde6bbbc0649e8ce67db831 | |
parent | d95bd9ec7cdf78ee74c69ebe9df07d418bb1e5db (diff) | |
download | morph-c80c6767915b086fb41f6c81fbc6161e2b30ece1.tar.gz |
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
-rw-r--r-- | morphlib/plugins/deploy_plugin.py | 8 |
1 files changed, 8 insertions, 0 deletions
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']: |