def test_install_does_not_install_anything_with_empty_requirements( pip: Pip, project_dir, current_platform ): target_directory = os.path.join(project_dir, "target_dir") os.makedirs(target_directory) pip.install(RequirementSet(current_platform), [], target_directory) assert not os.listdir(target_directory)
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_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_can_install_generated_packages( pip: Pip, current_platform: TargetPlatform, requirement_parser: RequirementParser, target_directory: Path, install_target: Path, package_generator: PackageGenerator, ): package_generator.generate_setuptools_package(name="testpackage") requirements = RequirementSet(current_platform) requirements.add(requirement_parser.parse("testpackage")) pip.install( requirements, source_directories=[target_directory], target_directory=install_target, ) assert "testpackage" in pip.freeze(python_path=[install_target])
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_can_generate_packages_with_requirements( package_generator: PackageGenerator, requirement_parser: RequirementParser, pip: Pip, target_directory: Path, install_target: Path, current_platform: TargetPlatform, ): package_generator.generate_setuptools_package( name="testpackage", install_requires=["other-package"]) package_generator.generate_setuptools_package(name="other-package") requirements = RequirementSet(target_platform=current_platform) requirements.add(requirement_parser.parse("testpackage")) pip.install( requirements, source_directories=[target_directory], target_directory=install_target, ) assert "other-package" in pip.freeze([install_target])
def test_can_generate_valid_packages_with_extras_require( package_generator: PackageGenerator, requirement_parser: RequirementParser, pip: Pip, target_directory: Path, install_target: Path, current_platform: TargetPlatform, ): package_generator.generate_setuptools_package( name="testpackage", extras_require={"extra": ["extrapackage"]}) package_generator.generate_setuptools_package(name="extrapackage") requirements = RequirementSet(target_platform=current_platform) requirements.add(requirement_parser.parse("testpackage[extra]")) pip.install( requirements, source_directories=[target_directory], target_directory=install_target, ) installed_packages = pip.freeze([install_target]) assert "extrapackage" in installed_packages
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_can_generate_valid_packages_with_two_runtime_dependencies( package_generator: PackageGenerator, requirement_parser: RequirementParser, pip: Pip, target_directory: Path, install_target: Path, current_platform: TargetPlatform, ): package_generator.generate_setuptools_package( name="testpackage", install_requires=["dependency1", "dependency2"]) package_generator.generate_setuptools_package(name="dependency1") package_generator.generate_setuptools_package(name="dependency2") requirements = RequirementSet(target_platform=current_platform) requirements.add(requirement_parser.parse("testpackage")) pip.install( requirements, source_directories=[target_directory], target_directory=install_target, ) installed_packages = pip.freeze([install_target]) assert "dependency1" in installed_packages assert "dependency2" in installed_packages
def test_install_does_not_install_anything_with_empty_requirements( pip: Pip, project_dir: str, current_platform: TargetPlatform): target_directory = Path(project_dir) / "target_dir" target_directory.ensure_directory() pip.install(RequirementSet(current_platform), [], target_directory) assert not target_directory.list_files()