Ejemplo n.º 1
0
def handle_requires(requires):
    pypi_pkgs = []
    git_repos = []
    for require in requires:
        if isinstance(require, dict):
            require_type = require.get(constants.REQUIRE_TYPE, "")
            if require_type.upper() == constants.GIT_REQUIRE:
                git_repos.append(
                    GitRequire(
                        git_url=require.get(constants.GIT_URL),
                        branch=require.get(constants.GIT_BRANCH),
                        submodule=require.get(
                            constants.GIT_HAS_SUBMODULE, False
                        ),
                    )
                )
            elif require_type.upper() == constants.PYPI_REQUIRE:
                pypi_pkgs.append(require.get(constants.PYPI_PACKAGE_NAME))
        else:
            if is_repo(require):
                git_repos.append(GitRequire(require))
            else:
                pypi_pkgs.append(require)
    if pypi_pkgs:
        pip_install(pypi_pkgs)
    if git_repos:
        git_clone(git_repos)
Ejemplo n.º 2
0
def test_pip_install(fake_check_all):
    import sys
    from moban.utils import pip_install

    pip_install(["package1", "package2"])
    fake_check_all.assert_called_with(
        [sys.executable, "-m", "pip", "install", "package1 package2"])
Ejemplo n.º 3
0
def handle_requires(requires):
    pypi_pkgs = []
    git_repos = []
    git_repos_with_sub = []
    for require in requires:
        if isinstance(require, dict):
            require_type = require.get(constants.REQUIRE_TYPE, "")
            if require_type.upper() == constants.GIT_REQUIRE:
                submodule_flag = require.get(constants.GIT_HAS_SUBMODULE)
                if submodule_flag is True:
                    git_repos_with_sub.append(require.get(constants.GIT_URL))
                else:
                    git_repos.append(require.get(constants.GIT_URL))
            elif require_type.upper() == constants.PYPI_REQUIRE:
                pypi_pkgs.append(require.get(constants.PYPI_PACKAGE_NAME))
        else:
            if is_repo(require):
                git_repos.append(require)
            else:
                pypi_pkgs.append(require)
    if pypi_pkgs:
        pip_install(pypi_pkgs)
    if git_repos:
        git_clone(git_repos)
    if git_repos_with_sub:
        git_clone(git_repos_with_sub, submodule=True)
Ejemplo n.º 4
0
def handle_requires(requires):
    pip_install(requires)