Exemplo n.º 1
0
def test_backend_path_and_dep(tmpdir, data):
    """Check we can call a requirement's backend successfully"""
    project_dir = make_project(tmpdir,
                               backend="dummy_internal_backend",
                               backend_path=['.'])
    (project_dir / 'dummy_internal_backend.py'
     ).write_text("from dummy_backend import build_wheel")
    req = InstallRequirement(None, None, source_dir=project_dir)
    req.load_pyproject_toml()
    env = BuildEnvironment()
    finder = make_test_finder(find_links=[data.backends])
    env.install_requirements(finder, ["dummy_backend"], 'normal', "Installing")

    assert hasattr(req.pep517_backend, 'build_wheel')
    with env:
        assert req.pep517_backend.build_wheel("dir") == "Backend called"
Exemplo n.º 2
0
def test_backend(tmpdir: Path, data: TestData) -> None:
    """Check we can call a requirement's backend successfully"""
    project_dir = make_project(tmpdir, backend="dummy_backend")
    req = InstallRequirement(None, None)
    req.source_dir = project_dir  # make req believe it has been unpacked
    req.load_pyproject_toml()
    env = BuildEnvironment()
    finder = make_test_finder(find_links=[data.backends])
    env.install_requirements(finder, ["dummy_backend"],
                             "normal",
                             kind="Installing")
    conflicting, missing = env.check_requirements(["dummy_backend"])
    assert not conflicting and not missing
    assert hasattr(req.pep517_backend, "build_wheel")
    with env:
        assert req.pep517_backend is not None
        assert req.pep517_backend.build_wheel("dir") == "Backend called"
Exemplo n.º 3
0
def test_backend_path_and_dep(tmpdir: Path, data: TestData) -> None:
    """Check we can call a requirement's backend successfully"""
    project_dir = make_project(
        tmpdir, backend="dummy_internal_backend", backend_path=["."]
    )
    (project_dir / "dummy_internal_backend.py").write_text(
        "from dummy_backend import build_wheel"
    )
    req = InstallRequirement(None, None)
    req.source_dir = project_dir  # make req believe it has been unpacked
    req.load_pyproject_toml()
    env = BuildEnvironment()
    finder = make_test_finder(find_links=[data.backends])
    env.install_requirements(finder, ["dummy_backend"], "normal", "Installing")

    assert hasattr(req.pep517_backend, "build_wheel")
    with env:
        assert req.pep517_backend is not None
        assert req.pep517_backend.build_wheel("dir") == "Backend called"
Exemplo n.º 4
0
def test_build_env_allow_only_one_install(script):
    create_basic_wheel_for_package(script, 'foo', '1.0')
    create_basic_wheel_for_package(script, 'bar', '1.0')
    finder = make_test_finder(find_links=[script.scratch_path])
    build_env = BuildEnvironment()
    for prefix in ('normal', 'overlay'):
        build_env.install_requirements(finder, ['foo'], prefix,
                                       'installing foo in %s' % prefix)
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, ['bar'], prefix,
                                           'installing bar in %s' % prefix)
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, [], prefix,
                                           'installing in %s' % prefix)
Exemplo n.º 5
0
def test_build_env_allow_only_one_install(script):
    create_basic_wheel_for_package(script, 'foo', '1.0')
    create_basic_wheel_for_package(script, 'bar', '1.0')
    finder = PackageFinder([script.scratch_path], [], session=PipSession())
    build_env = BuildEnvironment()
    for prefix in ('normal', 'overlay'):
        build_env.install_requirements(finder, ['foo'], prefix,
                                       'installing foo in %s' % prefix)
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, ['bar'], prefix,
                                           'installing bar in %s' % prefix)
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, [], prefix,
                                           'installing in %s' % prefix)
Exemplo n.º 6
0
def test_build_env_allow_only_one_install(script: PipTestEnvironment) -> None:
    create_basic_wheel_for_package(script, "foo", "1.0")
    create_basic_wheel_for_package(script, "bar", "1.0")
    finder = make_test_finder(find_links=[script.scratch_path])
    build_env = BuildEnvironment()
    for prefix in ("normal", "overlay"):
        build_env.install_requirements(finder, ["foo"], prefix,
                                       f"installing foo in {prefix}")
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, ["bar"], prefix,
                                           f"installing bar in {prefix}")
        with pytest.raises(AssertionError):
            build_env.install_requirements(finder, [], prefix,
                                           f"installing in {prefix}")
Exemplo n.º 7
0
def test_build_env_allow_empty_requirements_install():
    build_env = BuildEnvironment()
    for prefix in ('normal', 'overlay'):
        build_env.install_requirements(None, [], prefix, None)
Exemplo n.º 8
0
def test_build_env_allow_empty_requirements_install():
    build_env = BuildEnvironment()
    for prefix in ('normal', 'overlay'):
        build_env.install_requirements(None, [], prefix, None)
Exemplo n.º 9
0
def test_build_env_allow_empty_requirements_install() -> None:
    finder = make_test_finder()
    build_env = BuildEnvironment()
    for prefix in ("normal", "overlay"):
        build_env.install_requirements(finder, [], prefix,
                                       "Installing build dependencies")
Exemplo n.º 10
-1
def test_backend(tmpdir, data):
    """Check we can call a requirement's backend successfully"""
    project_dir = make_project(tmpdir, backend="dummy_backend")
    req = InstallRequirement(None, None, source_dir=project_dir)
    req.load_pyproject_toml()
    env = BuildEnvironment()
    finder = PackageFinder([data.backends], [], session=PipSession())
    env.install_requirements(finder, ["dummy_backend"], 'normal', "Installing")
    conflicting, missing = env.check_requirements(["dummy_backend"])
    assert not conflicting and not missing
    assert hasattr(req.pep517_backend, 'build_wheel')
    with env:
        assert req.pep517_backend.build_wheel("dir") == "Backend called"