def install(self, candidate: Candidate) -> None: if self.use_install_cache and candidate.req.is_named: # Only cache wheels from PyPI installer = install_wheel_with_cache else: installer = install_wheel installer(candidate.build(), self.environment, candidate.direct_url())
def test_cache_vcs_immutable_revision(project): req = parse_requirement( "git+https://github.com/test-root/demo.git@master#egg=demo") candidate = Candidate(req, project.environment) wheel = candidate.build() with pytest.raises(ValueError): Path(wheel).relative_to(project.cache_dir) assert candidate.revision == "1234567890abcdef" req = parse_requirement( "git+https://github.com/test-root/demo.git@1234567890abcdef#egg=demo") candidate = Candidate(req, project.environment) wheel = candidate.build() assert Path(wheel).relative_to(project.cache_dir) assert candidate.revision == "1234567890abcdef" # test the revision can be got correctly after cached candidate = Candidate(req, project.environment) wheel = candidate.prepare(True) assert not candidate.source_dir assert candidate.revision == "1234567890abcdef"
def test_sdist_candidate_with_wheel_cache(project, mocker): file_link = Link( path_to_url((FIXTURES / "artifacts/demo-0.0.1.tar.gz").as_posix())) built_path = (FIXTURES / "artifacts/demo-0.0.1-py2.py3-none-any.whl").as_posix() wheel_cache = project.make_wheel_cache() cache_path = wheel_cache.get_path_for_link(file_link) if not Path(cache_path).exists(): Path(cache_path).mkdir(parents=True) shutil.copy2(built_path, cache_path) req = parse_requirement(file_link.url) candidate = Candidate(req, project.environment) downloader = mocker.patch("pdm.models.pip_shims.unpack_url") candidate.prepare(True) downloader.assert_not_called() assert Path(candidate.wheel) == Path(cache_path) / Path(built_path).name candidate.wheel = None builder = mocker.patch("pdm.builders.WheelBuilder.build") candidate.build() builder.assert_not_called() assert Path(candidate.wheel) == Path(cache_path) / Path(built_path).name
def test_cache_egg_info_sdist(project): req = parse_requirement( "demo @ http://fixtures.test/artifacts/demo-0.0.1.tar.gz") candidate = Candidate(req, project.environment) wheel = candidate.build() assert Path(wheel).relative_to(project.cache_dir)