Skip to content

Commit

Permalink
Added install_python_requirements to the CM repo description (#1300)
Browse files Browse the repository at this point in the history
We got requests to install extra PIP packages when pulling CM
repositories. This flag will force to install extra dependencies from
requirements.txt file when pulling such CM repositories ...
  • Loading branch information
gfursin authored Oct 3, 2024
2 parents 4ffeb19 + a0d6fac commit 090f0cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion cm/cmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions cm/cmind/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 090f0cb

Please sign in to comment.