From 0c026ba64841a4c94f0136ccae089b43b2641642 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Wed, 2 Oct 2024 17:03:29 +0200 Subject: [PATCH] added `install_python_requirements` to the CM repo description (cmr.yaml) to install requirements to a current python with CM installation if needed --- cm/CHANGES.md | 4 ++++ cm/cmind/__init__.py | 2 +- cm/cmind/repos.py | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index 5432520cf..f6e0fd48b 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,3 +1,7 @@ +## V2.3.9.1 + - added `install_python_requirements` to the CM repo description (cmr.yaml) + to install requirements to a current python with CM installation if needed + ## V2.3.9 - added `--min` == `--skip` to `cm init` for readability - added `--checkout` to `cm init` to handle checkout diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index 215b3eff0..513769b98 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "2.3.9" +__version__ = "2.3.9.1" from cmind.core import access from cmind.core import error diff --git a/cm/cmind/repos.py b/cm/cmind/repos.py index b116677da..8175613e2 100644 --- a/cm/cmind/repos.py +++ b/cm/cmind/repos.py @@ -547,6 +547,26 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des warnings = r.get('warnings', []) + # Check if need to install requirements + install_python_requirements = meta.get('install_python_requirements', False) + + if install_python_requirements: + import sys + + python_exec = sys.executable + + cmd = python_exec + ' -m pip install -r requirements.txt' + + if console: + print ('') + print (cmd) + print ('') + + r = os.system(cmd) + + if r>0: + return {'return':1, 'error':'pip install -r requirements failed for this CM repository'} + # Go back to original directory os.chdir(cur_dir)