Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install module deps to ~/.opsdroid #167

Merged
merged 2 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions opsdroid/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
MODULES_DIRECTORY = "opsdroid-modules"
DEFAULT_ROOT_PATH = os.path.join(os.path.expanduser("~"), ".opsdroid")
DEFAULT_MODULES_PATH = os.path.join(DEFAULT_ROOT_PATH, "modules")
DEFAULT_MODULE_DEPS_PATH = os.path.join(DEFAULT_ROOT_PATH, "site-packages")
DEFAULT_CONFIG_PATH = os.path.join(DEFAULT_ROOT_PATH, "configuration.yaml")
DEFAULT_MODULE_BRANCH = "master"
EXAMPLE_CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
Expand Down
13 changes: 11 additions & 2 deletions opsdroid/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import yaml
from opsdroid.const import (
DEFAULT_GIT_URL, MODULES_DIRECTORY, DEFAULT_MODULES_PATH,
DEFAULT_MODULE_BRANCH, DEFAULT_CONFIG_PATH, EXAMPLE_CONFIG_FILE)
DEFAULT_MODULE_BRANCH, DEFAULT_CONFIG_PATH, EXAMPLE_CONFIG_FILE,
DEFAULT_MODULE_DEPS_PATH)


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -90,7 +91,11 @@ def git_clone(git_url, install_path, branch):
@staticmethod
def pip_install_deps(requirements_path):
"""Pip install a requirements.txt file and wait for finish."""
process = subprocess.Popen(["pip", "install", "-r", requirements_path],
process = subprocess.Popen(["pip", "install",
"--target={}".format(
DEFAULT_MODULE_DEPS_PATH),
"--ignore-installed",
"-r", requirements_path],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand Down Expand Up @@ -181,6 +186,10 @@ def _load_modules(self, modules_type, modules):
_LOGGER.debug("Loading " + modules_type + " modules")
loaded_modules = []

if not os.path.isdir(DEFAULT_MODULE_DEPS_PATH):
os.makedirs(DEFAULT_MODULE_DEPS_PATH)
sys.path.append(DEFAULT_MODULE_DEPS_PATH)

for module in modules:

# Set up module config
Expand Down