def test_location_related_install_option_fails( script: PipTestEnvironment) -> None: simple_sdist = create_basic_sdist_for_package(script, "simple", "0.1.0") reqs_file = script.scratch_path.joinpath("reqs.txt") reqs_file.write_text("simple --install-option='--home=/tmp'") result = script.pip( "install", "--no-index", "-f", str(simple_sdist.parent), "-r", reqs_file, expect_error=True, ) assert "['--home'] from simple" in result.stderr
def test_new_resolver_only_builds_sdists_when_needed(script): create_basic_wheel_for_package( script, "base", "0.1.0", depends=["dep"], ) create_basic_sdist_for_package( script, "dep", "0.1.0", # Replace setup.py with something that fails extra_files={"setup.py": "assert False"}, ) create_basic_sdist_for_package( script, "dep", "0.2.0", ) # We only ever need to check dep 0.2.0 as it's the latest version script.pip( "install", "--no-cache-dir", "--no-index", "--find-links", script.scratch_path, "base" ) assert_installed(script, base="0.1.0", dep="0.2.0") # We merge criteria here, as we have two "dep" requirements script.pip( "install", "--no-cache-dir", "--no-index", "--find-links", script.scratch_path, "base", "dep" ) assert_installed(script, base="0.1.0", dep="0.2.0")
def test_new_resolver_does_not_reinstall_when_from_a_local_index(script): create_basic_sdist_for_package( script, "simple", "0.1.0", ) script.pip( "install", "--no-cache-dir", "--no-index", "--find-links", script.scratch_path, "simple" ) assert_installed(script, simple="0.1.0") result = script.pip( "install", "--no-cache-dir", "--no-index", "--find-links", script.scratch_path, "simple" ) # Should not reinstall! assert "Installing collected packages: simple" not in result.stdout, str(result) assert "Requirement already satisfied: simple" in result.stdout, str(result) assert_installed(script, simple="0.1.0")
def test_new_resolver_does_reinstall_local_sdists(script): archive_path = create_basic_sdist_for_package( script, "pkg", "1.0", ) script.pip( "install", "--no-cache-dir", "--no-index", archive_path, ) assert_installed(script, pkg="1.0") result = script.pip( "install", "--no-cache-dir", "--no-index", archive_path, expect_stderr=True, ) assert "Installing collected packages: pkg" in result.stdout, str(result) assert "DEPRECATION" in result.stderr, str(result) assert_installed(script, pkg="1.0")
def _create_find_links(script): sdist_path = create_basic_sdist_for_package(script, "base", "0.1.0") wheel_path = create_basic_wheel_for_package(script, "base", "0.1.0") sdist_hash = hashlib.sha256(sdist_path.read_bytes()).hexdigest() wheel_hash = hashlib.sha256(wheel_path.read_bytes()).hexdigest() index_html = script.scratch_path / "index.html" index_html.write_text(""" <a href="{sdist_url}#sha256={sdist_hash}">{sdist_path.stem}</a> <a href="{wheel_url}#sha256={wheel_hash}">{wheel_path.stem}</a> """.format( sdist_url=path_to_url(sdist_path), sdist_hash=sdist_hash, sdist_path=sdist_path, wheel_url=path_to_url(wheel_path), wheel_hash=wheel_hash, wheel_path=wheel_path, )) return _FindLinks(index_html, sdist_hash, wheel_hash)
def _create_find_links(script: PipTestEnvironment) -> _FindLinks: sdist_path = create_basic_sdist_for_package(script, "base", "0.1.0") wheel_path = create_basic_wheel_for_package(script, "base", "0.1.0") sdist_hash = hashlib.sha256(sdist_path.read_bytes()).hexdigest() wheel_hash = hashlib.sha256(wheel_path.read_bytes()).hexdigest() index_html = script.scratch_path / "index.html" index_html.write_text(""" <!DOCTYPE html> <a href="{sdist_url}#sha256={sdist_hash}">{sdist_path.stem}</a> <a href="{wheel_url}#sha256={wheel_hash}">{wheel_path.stem}</a> """.format( sdist_url=sdist_path.as_uri(), sdist_hash=sdist_hash, sdist_path=sdist_path, wheel_url=wheel_path.as_uri(), wheel_hash=wheel_hash, wheel_path=wheel_path, ).strip()) return _FindLinks(index_html, sdist_hash, wheel_hash)
def _arg_recording_sdist_maker(name: str) -> ArgRecordingSdist: extra_files = {"setup.py": arg_writing_setup_py.format(name=name)} sdist_path = create_basic_sdist_for_package(script, name, "0.1.0", extra_files) args_path = output_dir / f"{name}.json" return ArgRecordingSdist(sdist_path, args_path)