Skip to content

Commit

Permalink
auto-install Python requirements from pulled repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
gfursin committed May 27, 2021
1 parent 0d1ab11 commit 56e4bc6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* removed outdated and unnecessary files
* added --command flag to "run docker" to run a specific command such as
ck run docker:xyz --command="ck show env"
* auto-install Python requirements from pulled repositories

* V2.4.0
* added module "docker.template" to support adaptive CK containers
Expand Down
51 changes: 51 additions & 0 deletions ck/repo/module/repo/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,12 @@ def add(i):
if r['return'] > 0:
return r

# Check Python requirements
r = requirements({'path':p,
'out':o})
if r['return'] > 0:
return r

# Check deps
if o == 'con':
ck.out(' ========================================')
Expand Down Expand Up @@ -1189,6 +1195,12 @@ def pull(i):

# Check deps
if tt != 'clone': # clone is done in add ...
# Check Python requirements
r = requirements({'path':p,
'out':o})
if r['return'] > 0:
return r

if o == 'con':
ck.out(' ========================================')
ck.out(' Checking dependencies on other repos ...')
Expand Down Expand Up @@ -2095,6 +2107,45 @@ def import_repo(i):
i['import'] = 'yes'
return add(i)

##############################################################################
# process requirements

def requirements(i):
"""
Input: {
(path) - path to .cmr.json
}
Output: {
return - return code = 0, if successful
> 0, if error
(error) - error text if return > 0
}
"""

if ck.cfg.get('skip_repo_requirements','')!='yes':

o=i.get('out','')
p=i['path']

if p!='':
p1=os.path.join(p, 'requirements.txt')
if os.path.isfile(p1):
if o == 'con':
import sys
c = sys.executable + ' -m pip install -r '+p1

ck.out(' ========================================')
ck.out(' Processing Python requirements ...')
ck.out('')
ck.out(' '+c)
ck.out('')

os.system(c)

return {'return':0}

##############################################################################
# resolve dependencies for a repo

Expand Down

0 comments on commit 56e4bc6

Please sign in to comment.