Example #1
0
def pip(
    request,
    nix,
    project_dir,
    current_platform,
    logger,
    requirement_parser: RequirementParser,
):
    if request.param == "nix":
        return NixPip(
            nix=nix,
            project_directory=project_dir,
            extra_build_inputs=[],
            extra_env="",
            wheels_cache=[],
            target_platform=current_platform,
            logger=logger,
            requirement_parser=requirement_parser,
        )
    else:
        pip = VirtualenvPip(
            logger=logger,
            target_platform=current_platform,
            target_directory=os.path.join(project_dir, "venv-pip"),
            env_builder=venv.EnvBuilder(with_pip=True),
            requirement_parser=requirement_parser,
        )
        pip.prepare_virtualenv()
        return pip
def test_pip_with_data_directory_index_can_download_six(
    pip_from_data_directory: VirtualenvPip,
    download_dir: str,
    requirement_parser: RequirementParser,
    current_platform: TargetPlatform,
) -> None:
    requirements = RequirementSet(current_platform)
    requirements.add(requirement_parser.parse("six"))
    pip_from_data_directory.download_sources(requirements, download_dir)
def test_pip_without_index_cannot_download_six(
    pip_without_index: VirtualenvPip,
    download_dir: str,
    requirement_parser: RequirementParser,
    current_platform: TargetPlatform,
) -> None:
    requirements = RequirementSet(current_platform)
    requirements.add(requirement_parser.parse("six"))
    with pytest.raises(PipFailed):
        pip_without_index.download_sources(requirements, download_dir)
def test_pip_without_index_cannot_be_prepared_without_wheel_supplied(
    logger: Logger,
    current_platform: TargetPlatform,
    project_dir: str,
    requirement_parser: RequirementParser,
) -> None:
    pip = VirtualenvPip(
        logger=logger,
        target_platform=current_platform,
        target_directory=os.path.join(project_dir, "pip-without-index-venv"),
        env_builder=venv.EnvBuilder(with_pip=True),
        no_index=True,
        requirement_parser=requirement_parser,
    )
    with pytest.raises(PipFailed):
        pip.prepare_virtualenv()
Example #5
0
def test_that_set_environment_variable_undoes_changes_when_exiting(
    pip_without_index: VirtualenvPip,
):
    old_environment = dict(os.environ)
    with pip_without_index._set_environment_variable({"test": "definitly_unset"}):
        pass
    assert dict(os.environ) == old_environment
def pip_without_index(
    logger: Logger,
    current_platform: TargetPlatform,
    project_dir: str,
    wheel_distribution_archive_path: str,
    requirement_parser: RequirementParser,
) -> VirtualenvPip:
    pip = VirtualenvPip(
        logger=logger,
        target_platform=current_platform,
        target_directory=os.path.join(project_dir, "pip-without-index-venv"),
        env_builder=venv.EnvBuilder(with_pip=True),
        no_index=True,
        wheel_distribution_path=wheel_distribution_archive_path,
        requirement_parser=requirement_parser,
    )
    pip.prepare_virtualenv()
    return pip