def test_install_six_yields_non_empty_freeze_output( pip: Pip, project_dir, download_dir, current_platform, requirement_parser ): lib_dir = os.path.join(project_dir, "lib") requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) pip.download_sources(requirements, download_dir) pip.install( requirements, source_directories=[download_dir], target_directory=lib_dir ) assert pip.freeze([lib_dir])
def test_pip_downloads_sources_to_target_directory( pip: Pip, project_dir: str, current_platform: TargetPlatform, requirement_parser: RequirementParser, ): download_path = os.path.join(project_dir, "download") requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) pip.download_sources(requirements=requirements, target_directory=download_path) assert list_files(download_path)
def test_freeze_respects_additional_python_path( pip: Pip, project_dir: str, current_platform: TargetPlatform, requirement_parser: RequirementParser, ): prefix = os.path.join(project_dir, "custom-prefix") download_dir = os.path.join(project_dir, "download") requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) pip.download_sources(requirements, download_dir) pip.install( requirements, target_directory=prefix, source_directories=[download_dir] ) freeze_without_six = pip.freeze([]) freeze_with_six = pip.freeze(python_path=[prefix]) assert len(freeze_without_six) < len(freeze_with_six)
def test_install_to_target_directory_does_not_install_to_default_directory( pip: Pip, project_dir, download_dir, current_platform, requirement_parser ): requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) target_directory = os.path.join(project_dir, "target-directory") os.makedirs(target_directory) pip.download_sources(requirements, download_dir) assert not os.listdir(target_directory) pip.install( requirements, source_directories=[download_dir], target_directory=target_directory, ) assert os.listdir(target_directory)
def test_pip_can_install_wheels_previously_downloaded( pip: Pip, project_dir: str, current_platform: TargetPlatform, requirement_parser: RequirementParser, download_dir: Path, wheels_dir: Path, ): requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) pip.download_sources(requirements, download_dir) pip.build_wheels( requirements=requirements, source_directories=[download_dir], target_directory=wheels_dir, ) assert wheels_dir.list_files() assert any(map(lambda x: x.endswith(".whl"), wheels_dir.list_files()))
def test_install_to_target_directory_does_not_install_to_default_directory( pip: Pip, project_dir: str, download_dir: Path, current_platform: TargetPlatform, requirement_parser: RequirementParser, ): requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("six")) target_directory = Path(project_dir) / "target-directory" target_directory.ensure_directory() pip.download_sources(requirements, download_dir) assert not target_directory.list_files() pip.install( requirements, source_directories=[download_dir], target_directory=target_directory, ) assert target_directory.list_files()
def test_pip_downloads_nothing_when_no_requirements_are_given( pip: Pip, download_dir, current_platform): pip.download_sources(requirements=RequirementSet(current_platform), target_directory=download_dir) assert not list_files(download_dir)