Skip to content

Commit eea5812

Browse files
GenPagegbin
authored andcommitted
Add docker support for installing package dependencies (#1245)
1 parent 5273c2e commit eea5812

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

errbot/plugin_manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def install_packages(req_path: Path):
6363
6464
Return an exc_info if it fails otherwise None.
6565
"""
66+
def is_docker():
67+
with open('/proc/1/cgroup') as d:
68+
return 'docker' in d.read()
69+
6670
log.info('Installing packages from "%s".', req_path)
6771
# use sys.executable explicitly instead of just 'pip' because depending on how the bot is deployed
6872
# 'pip' might not be available on PATH: for example when installing errbot on a virtualenv and
@@ -75,6 +79,9 @@ def install_packages(req_path: Path):
7579
if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and (sys.base_prefix != sys.prefix)):
7680
# this is a virtualenv, so we can use it directly
7781
subprocess.check_call(pip_cmdline + ['install', '--requirement', str(req_path)])
82+
elif is_docker():
83+
# this is a docker container, so we can use it directly
84+
subprocess.check_call(pip_cmdline + ['install', '--requirement', str(req_path)])
7885
else:
7986
# otherwise only install it as a user package
8087
subprocess.check_call(pip_cmdline + ['install', '--user', '--requirement', str(req_path)])

0 commit comments

Comments
 (0)