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

feature: expands entry point to install dependencies from extra_depen… #78

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ RUN pip install wheel \

COPY docker_overlay/ /

RUN neon-messagebus install-dependencies

CMD ["neon-messagebus", "run"]
16 changes: 15 additions & 1 deletion neon_messagebus/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import click
import sys
from typing import List

from click_default_group import DefaultGroup
from neon_utils.packaging_utils import get_package_version_spec
from neon_utils.configuration_utils import init_config_dir

from ovos_config.config import Configuration
from ovos_utils.log import LOG, log_deprecation

@click.group("neon-messagebus", cls=DefaultGroup,
no_args_is_help=True, invoke_without_command=True,
Expand All @@ -44,6 +47,17 @@ def neon_messagebus_cli(version: bool = False):
click.echo(f"neon_messagebus version "
f"{get_package_version_spec('neon_messagebus')}")

@neon_messagebus_cli.command(help="Install neon-messagebus module dependencies from config & cli")
@click.option("--package", "-p", default=[], multiple=True,
help="Additional package to install (can be repeated)")
def install_dependencies(package: List[str]):
from neon_utils.packaging_utils import install_packages_from_pip
from neon_messagebus.util.package_utils import build_extra_dependency_list
config = Configuration()
dependencies = build_extra_dependency_list(config, list(package))
result = install_packages_from_pip("neon-messagebus", dependencies)
LOG.info(f"pip exit code: {result}")
sys.exit(result)

@neon_messagebus_cli.command(help="Start Neon Messagebus module")
def run():
Expand Down
35 changes: 35 additions & 0 deletions neon_messagebus/util/package_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Framework
# All trademark and other rights reserved by their respective owners
# Copyright 2008-2022 Neongecko.com Inc.
# Contributors: Daniel McKnight, Guy Daniels, Elon Gasper, Richard Leeds,
# Regina Bloomstine, Casimiro Ferreira, Andrii Pernatii, Kirill Hrymailo
# BSD-3 License
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from typing import List, Union
from ovos_config.config import Configuration

def build_extra_dependency_list(config: Union[dict, Configuration], additional: List[str] = []) -> List[str]:
extra_dependencies = config.get("extra_dependencies", {})
dependencies = additional + extra_dependencies.get("global", []) + extra_dependencies.get("messagebus", [])

return dependencies
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ ovos_utils~=0.0.32
ovos-config~=0.0.10
ovos-bus-client~=0.0.6
tornado~=6.0,>=6.0.3
neon_utils[network]~=1.6
neon-utils[network]~=1.8,>=1.8.3a5
click~=8.0
click-default-group~=1.2
Loading