Add function to install packages from pip too

This commit is contained in:
yuvipanda
2018-06-26 17:38:56 -07:00
parent 92558e913e
commit f7813a9385
2 changed files with 28 additions and 0 deletions

View File

@@ -47,3 +47,16 @@ def ensure_conda_packages(prefix, packages):
output = json.loads(filtered_output)
if 'success' in output and output['success'] == True:
return
def ensure_pip_packages(prefix, packages):
"""
Ensure pip packages are installed in the given conda prefix.
"""
abspath = os.path.abspath(prefix)
pip_executable = [os.path.join(abspath, 'bin', 'python'), '-m', 'pip']
subprocess.run(pip_executable + [
'install',
'--no-cache-dir',
] + packages)