blob: 096e1562d6bb38c43cb999c139cb773b103aff03 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
from subprocess import Popen, PIPE, check_output, CalledProcessError
def conda_search(pkgname):
command = ['conda', 'list', pkgname]
proc = Popen(command, stdout=PIPE)
out, _ = proc.communicate()
for line in out.decode('utf-8').splitlines():
if line.startswith('#'):
continue
line = line.split();
break
if not line:
return ''
return '-'.join(line)
def conda_install(pkgname):
# Until I can figure out a good way to build with the conda API
# we'll use the CLI interface:
command = 'conda install --use-local --yes {0}'.format(pkgname).split()
try:
for line in (check_output(command).decode('utf-8').splitlines()):
print(line)
except CalledProcessError as cpe:
print('{0}\nexit={1}'.format(' '.join(cpe.cmd), cpe.returncode))
|