Exemple #1
0
    def add_packages(self, project, env_spec_name, packages, channels):
        """Attempt to install packages then add them to anaconda-project.yml.

        If the environment spec name is None rather than an env
        name, packages are added in the global packages
        section (to all environments).

        The returned ``Status`` should be a ``RequirementStatus`` for
        the environment requirement if it evaluates to True (on success),
        but may be another subtype of ``Status`` on failure. A False
        status will have an ``errors`` property with a list of error
        strings.

        Args:
            project (Project): the project
            env_spec_name (str): environment spec name or None for all environment specs
            packages (list of str): packages (with optional version info, as for conda install)
            channels (list of str): channels (as they should be passed to conda --channel)

        Returns:
            ``Status`` instance

        """
        return project_ops.add_packages(project=project,
                                        env_spec_name=env_spec_name,
                                        packages=packages,
                                        channels=channels)
Exemple #2
0
def add_packages(project, environment, packages, channels):
    """Add packages to the project."""
    project = load_project(project)
    status = project_ops.add_packages(project, env_spec_name=environment, packages=packages, channels=channels)
    package_list = ", ".join(packages)
    if environment is None:
        success_message = "Added packages to project file: %s." % (package_list)
    else:
        success_message = "Added packages to environment %s in project file: %s." % (environment, package_list)
    return _handle_status(status, success_message)