示例#1
0
def before_scenario(context, scenario):  # pylint: disable=unused-argument
    """Environment preparation before other cli tests are run.
    Installs kedro by running pip in the top level directory.
    """
    if _should_exclude_scenario(scenario):
        scenario.skip()

    def call(cmd, verbose=False):
        res = run(cmd, env=context.env)
        if res.returncode or verbose:
            print(">", " ".join(cmd))
            print(res.stdout)
            print(res.stderr)
        assert res.returncode == 0

    # make a venv
    if "E2E_VENV" in os.environ:
        context.venv_dir = Path(os.environ["E2E_VENV"])
    else:
        context.venv_dir = Path(create_new_venv())

    # note the locations of some useful stuff
    # this is because exe resolution in supbrocess doens't respect a passed env
    if os.name == "posix":
        bin_dir = context.venv_dir / "bin"
        path_sep = ":"
    else:
        bin_dir = context.venv_dir / "Scripts"
        path_sep = ";"
    context.pip = str(bin_dir / "pip")
    context.python = str(bin_dir / "python")
    context.kedro = str(bin_dir / "kedro")

    # clone the environment, remove any condas and venvs and insert our venv
    context.env = os.environ.copy()
    path = context.env["PATH"].split(path_sep)
    path = [p for p in path if not (Path(p).parent / "pyvenv.cfg").is_file()]
    path = [p for p in path if not (Path(p).parent / "conda-meta").is_dir()]
    path = [str(bin_dir)] + path
    # Activate environment
    context.env["PATH"] = path_sep.join(path)

    # install this plugin by resolving the requirements using pip-compile
    # from pip-tools due to this bug in pip: https://github.com/pypa/pip/issues/988
    call([context.python, "-m", "pip", "install", "-U", "pip", "pip-tools"])
    pip_compile = str(bin_dir / "pip-compile")
    with tempfile.TemporaryDirectory() as tmpdirname:
        compiled_reqs = Path(tmpdirname) / "compiled_requirements.txt"
        call([
            pip_compile, "--output-file",
            str(compiled_reqs), "requirements.txt"
        ])
        call([context.pip, "install", "-r", str(compiled_reqs)])

    for wheel_path in glob.glob("dist/*.whl"):
        os.remove(wheel_path)
    call([context.python, "setup.py", "clean", "--all", "bdist_wheel"])

    call([context.pip, "install", "-U"] + glob.glob("dist/*.whl"))
    context.temp_dir = Path(tempfile.mkdtemp())
def before_all(context):
    """Environment preparation before other cli tests are run.
    Installs kedro by running pip in the top level directory.
    """

    # make a venv
    if "E2E_VENV" in os.environ:
        context.venv_dir = Path(os.environ["E2E_VENV"])
    else:
        context.venv_dir = create_new_venv()

    context = _setup_context_with_venv(context, context.venv_dir)

    call(
        [
            context.python,
            "-m",
            "pip",
            "install",
            "-U",
            # Temporarily pin pip to fix https://github.com/jazzband/pip-tools/issues/1503
            # This can be removed when Kedro 0.17.6 is released, because pip-tools is upgraded
            # for that version.
            "pip>=20.0,<21.3",
            "setuptools>=38.0",
            "wheel",
            ".",
        ],
        env=context.env,
    )

    # install the plugin
    call([context.python, "setup.py", "install"], env=context.env)
示例#3
0
def before_all(context):
    """Environment preparation before other cli tests are run.
    Installs (core) kedro by running pip in the top level directory.
    """
    def call(cmd):
        res = run(cmd, env=context.env)
        if res.returncode:
            print(res.stdout)
            print(res.stderr)
            assert False

    # make a venv
    if "E2E_VENV" in os.environ:
        context.venv_dir = Path(os.environ["E2E_VENV"])
    else:
        context.venv_dir = Path(create_new_venv())

    # note the locations of some useful stuff
    # this is because exe resolution in subprocess doesn't respect a passed env
    if os.name == "posix":
        bin_dir = context.venv_dir / "bin"
        path_sep = ":"
    else:
        bin_dir = context.venv_dir / "Scripts"
        path_sep = ";"
    context.bin_dir = bin_dir
    context.pip = str(bin_dir / "pip")
    context.python = str(bin_dir / "python")
    context.kedro = str(bin_dir / "kedro")
    context.requirements_path = Path("requirements.txt").resolve()

    # clone the environment, remove any condas and venvs and insert our venv
    context.env = os.environ.copy()
    path = context.env["PATH"].split(path_sep)
    path = [p for p in path if not (Path(p).parent / "pyvenv.cfg").is_file()]
    path = [p for p in path if not (Path(p).parent / "conda-meta").is_dir()]
    path = [str(bin_dir)] + path
    context.env["PATH"] = path_sep.join(path)

    # Create an empty pip.conf file and point pip to it
    pip_conf_path = context.venv_dir / "pip.conf"
    pip_conf_path.touch()
    context.env["PIP_CONFIG_FILE"] = str(pip_conf_path)

    # install Kedro
    # these versions should match what's in the Makefile
    call([
        context.python,
        "-m",
        "pip",
        "install",
        "-U",
        "pip>=20.0, <21.0",
        "setuptools>=38.0, <47.0",
        "wheel",
    ])
    call([context.pip, "install", "--upgrade", "setuptools"])
    call([context.pip, "install", "."])
示例#4
0
def before_all(context):
    """Environment preparation before other cli tests are run.
    Installs kedro by running pip in the top level directory.
    """
    def call(cmd, verbose=False):
        res = run(cmd, env=context.env)
        if res.returncode or verbose:
            print(">", " ".join(cmd))
            print(res.stdout)
            print(res.stderr)
        assert not res.returncode

    # make a venv
    if "E2E_VENV" in os.environ:
        context.venv_dir = Path(os.environ["E2E_VENV"])
    else:
        context.venv_dir = create_new_venv()

    # note the locations of some useful stuff
    # this is because exe resolution in subprocess doesn't respect a passed env
    if os.name == "posix":
        bin_dir = Path(context.venv_dir) / "bin"
        path_sep = ":"
    else:
        bin_dir = Path(context.venv_dir) / "Scripts"
        path_sep = ";"
    context.pip = str(bin_dir / "pip")
    context.python = str(bin_dir / "python")
    context.kedro = str(bin_dir / "kedro")

    # clone the environment, remove any condas and venvs and insert our venv
    context.env = os.environ.copy()
    path = context.env["PATH"].split(path_sep)
    path = [p for p in path if not (Path(p).parent / "pyvenv.cfg").is_file()]
    path = [p for p in path if not (Path(p).parent / "conda-meta").is_dir()]
    path = [str(bin_dir)] + path
    context.env["PATH"] = path_sep.join(path)

    # resolve the requirements using pip-compile from pip-tools due to
    # this bug in pip: https://github.com/pypa/pip/issues/988
    call([context.python, "-m", "pip", "install", "-U", "pip", "pip-tools"])
    pip_compile = str(bin_dir / "pip-compile")
    with tempfile.TemporaryDirectory() as tmpdirname:
        compiled_reqs = str(Path(tmpdirname) / "requirements.txt")
        call([pip_compile, "requirements.txt", "-o", compiled_reqs])
        call([context.pip, "install", "-r", compiled_reqs])

    # install the plugin
    call([context.pip, "install", "."])
示例#5
0
def before_all(context):
    """Environment preparation before other cli tests are run.
    Installs kedro by running pip in the top level directory.
    """
    def call(cmd):
        res = run(cmd, env=context.env)
        if res.returncode:
            print(res.stdout)
            print(res.stderr)
            assert False

    # make a venv
    if "E2E_VENV" in os.environ:
        context.venv_dir = Path(os.environ["E2E_VENV"])
    else:
        context.venv_dir = Path(create_new_venv())

    # note the locations of some useful stuff
    # this is because exe resolution in supbrocess doens't respect a passed env
    if os.name == "posix":
        bin_dir = context.venv_dir / "bin"
        path_sep = ":"
    else:
        bin_dir = context.venv_dir / "Scripts"
        path_sep = ";"
    context.bin_dir = bin_dir
    context.pip = str(bin_dir / "pip")
    context.python = str(bin_dir / "python")
    context.kedro = str(bin_dir / "kedro")

    # clone the environment, remove any condas and venvs and insert our venv
    context.env = os.environ.copy()
    path = context.env["PATH"].split(path_sep)
    path = [p for p in path if not (Path(p).parent / "pyvenv.cfg").is_file()]
    path = [p for p in path if not (Path(p).parent / "conda-meta").is_dir()]
    path = [str(bin_dir)] + path
    context.env["PATH"] = path_sep.join(path)

    # install Kedro
    call([context.python, "-m", "pip", "install", "-U", "pip"])
    for wheel_path in Path("dist").glob("*.whl"):
        wheel_path.unlink()
    call([context.pip, "install", "wheel"])
    call([context.python, "setup.py", "clean", "--all", "bdist_wheel"])
    call([context.pip, "install", "-U"] + glob.glob("dist/*.whl"))
def before_scenario(context, scenario):  # pylint: disable=unused-argument
    """Environment preparation before other cli tests are run.
    Installs kedro by running pip in the top level directory.
    """
    def call(cmd, print_output=False):
        res = run(cmd, env=context.env)
        if res.returncode or print_output:
            print(">", " ".join(cmd))
            print(res.stdout)
            print(res.stderr)
        assert res.returncode == 0

    # make a venv
    context.venv_dir = create_new_venv()

    # note the locations of some useful stuff
    # this is because exe resolution in supbrocess doens't respect a passed env
    if os.name == "posix":
        bin_dir = context.venv_dir / "bin"
        path_sep = ":"
    else:
        bin_dir = context.venv_dir / "Scripts"
        path_sep = ";"
    context.pip = str(bin_dir / "pip")
    context.python = str(bin_dir / "python")
    context.kedro = str(bin_dir / "kedro")
    context.airflow = str(bin_dir / "airflow")

    # clone the environment, remove any condas and venvs and insert our venv
    context.env = os.environ.copy()
    path = context.env["PATH"].split(path_sep)
    path = [p for p in path if not (Path(p).parent / "pyvenv.cfg").is_file()]
    path = [p for p in path if not (Path(p).parent / "conda-meta").is_dir()]
    path = [str(bin_dir)] + path
    context.env["PATH"] = path_sep.join(path)

    # pip install us
    call([context.python, "-m", "pip", "install", "-U", "pip", "pip-tools"])
    call([context.pip, "install", "-r", "test_requirements.txt"])
    call([context.pip, "install", "."])

    # pylint: disable=unused-argument
    context.temp_dir = Path(tempfile.mkdtemp())