def test_that_we_can_generate_objects_from_source_archives(
    source_distribution_archive,
    logger: Logger,
    requirement_parser: RequirementParser,
):
    SourceDistribution.from_archive(source_distribution_archive,
                                    logger,
                                    requirement_parser=requirement_parser)
def test_that_trying_to_create_source_distribution_from_random_zip_throws(
        test_zip_path, logger: Logger, requirement_parser: RequirementParser):
    archive = Archive(path=test_zip_path)
    with pytest.raises(DistributionNotDetected):
        SourceDistribution.from_archive(
            archive,
            logger,
            requirement_parser=requirement_parser,
        )
Exemplo n.º 3
0
 def _get_build_dependencies_for_distribution(
         self, distribution: SourceDistribution) -> RequirementSet:
     self.source_distributions[distribution.name] = distribution
     build_dependencies = distribution.build_dependencies(
         self.target_platform).filter(lambda requirement: requirement.name(
         ) not in [distribution.name])
     for dependency in build_dependencies:
         self._dependency_graph.set_buildtime_dependency(
             dependent=distribution.to_loose_requirement(),
             dependency=dependency)
     return build_dependencies
Exemplo n.º 4
0
def test_that_we_can_detect_setup_requirements_for_setup_cfg_projects(
        distribution_archive_for_jsonschema, current_platform, logger,
        requirement_parser):
    distribution = SourceDistribution.from_archive(
        distribution_archive_for_jsonschema, logger)
    assert "setuptools-scm" in distribution.build_dependencies(
        current_platform, requirement_parser)
Exemplo n.º 5
0
 def generate_setuptools_package(
         self,
         name: str,
         version: str = "1.0",
         install_requires: List[str] = []) -> SourceDistribution:
     with TemporaryDirectory() as directory_path_string:
         build_directory: Path = Path(directory_path_string)
         self._generate_setup_py(build_directory,
                                 name=name,
                                 version=version)
         self._generate_setup_cfg(
             build_directory,
             name=name,
             version=version,
             install_requires=install_requires,
         )
         built_distribution_archive = self._build_package(
             build_directory=build_directory, name=name, version=version)
         source_distribution = SourceDistribution.from_archive(
             built_distribution_archive,
             logger=self._logger,
             requirement_parser=self._requirement_parser,
         )
         self._move_package_target_directory(built_distribution_archive)
     return source_distribution
Exemplo n.º 6
0
 def _get_build_dependencies_for_distribution(
         self, distribution: SourceDistribution) -> RequirementSet:
     self.source_distributions[distribution.name] = distribution
     build_dependencies = distribution.build_dependencies(
         self.target_platform).filter(lambda requirement: requirement.name(
         ) not in [distribution.name])
     self.additional_build_dependencies[
         distribution.name] += build_dependencies
     return build_dependencies
def source_distribution(
    six_source_distribution_archive,
    logger: Logger,
    requirement_parser: RequirementParser,
):
    return SourceDistribution.from_archive(
        six_source_distribution_archive,
        logger,
        requirement_parser=requirement_parser)
Exemplo n.º 8
0
def test_build_dependencies_for_invalid_deps_logs_warning(
        data_directory, current_platform, logger: Logger):
    spacy_distribution_path = os.path.join(data_directory,
                                           "spacy-2.1.0.tar.gz")
    archive = Archive(spacy_distribution_path)

    dist = SourceDistribution.from_archive(archive, logger)

    assert "WARNING:" not in get_logger_output(logger)
    dist.build_dependencies(current_platform)
    assert "WARNING:" in get_logger_output(logger)
Exemplo n.º 9
0
def test_invalid_build_dependencies_for_setupcfg_package_logs_warning(
        data_directory, current_platform, logger):
    distribution_path = os.path.join(data_directory, "setupcfg-package",
                                     "setupcfg-package.tar.gz")
    archive = Archive(distribution_path)

    dist = SourceDistribution.from_archive(archive, logger)

    assert "WARNING:" not in get_logger_output(logger)
    dist.build_dependencies(current_platform)
    assert "WARNING:" in get_logger_output(logger)
Exemplo n.º 10
0
 def get_uninspected_source_distributions(self) -> List[SourceDistribution]:
     archives = [
         Archive(path=path) for path in list_files(self.download_directory)
         if path not in self.inspected_source_distribution_files
     ]
     distributions = list()
     for archive in archives:
         try:
             distributions.append(
                 SourceDistribution.from_archive(archive, self.logger))
         except DistributionNotDetected:
             continue
     return distributions
Exemplo n.º 11
0
def flit_distribution(pip, project_dir, download_dir, flit_requirements,
                      logger):
    pip.download_sources(flit_requirements, download_dir)
    archives = [
        Archive(path=os.path.join(download_dir, filename))
        for filename in os.listdir(download_dir)
    ]
    distributions = list(
        map(lambda archive: SourceDistribution.from_archive(archive, logger),
            archives))
    for distribution in distributions:
        if distribution.name == "flit":
            return distribution
    raise Exception("Could not download source distribution for `flit`")
Exemplo n.º 12
0
 def get_uninspected_source_distributions(self) -> List[SourceDistribution]:
     archives = [
         Archive(path=str(path))
         for path in self._download_directory.list_files()
         if path not in self.inspected_source_distribution_files
     ]
     distributions = list()
     for archive in archives:
         try:
             distribution = SourceDistribution.from_archive(
                 archive,
                 self.logger,
                 requirement_parser=self.requirement_parser)
         except DistributionNotDetected:
             continue
         distributions.append(distribution)
     return distributions
Exemplo n.º 13
0
 def generate_setuptools_package(
     self,
     name: str,
     version: str = "1.0",
     install_requires: List[str] = [],
     extras_require: Dict[str, List[str]] = {},
 ) -> SourceDistribution:
     with TemporaryDirectory() as directory_path_string:
         build_directory: Path = Path(directory_path_string)
         self._generate_setup_py(build_directory,
                                 name=name,
                                 version=version)
         self._generate_setup_cfg(
             build_directory,
             name=name,
             version=version,
             install_requires=install_requires,
             extras_require=extras_require,
         )
         self._generate_python_module(
             build_directory,
             name=name,
         )
         built_distribution_archive = self._build_package(
             build_directory=build_directory, name=name, version=version)
         source_distribution = SourceDistribution.from_archive(
             built_distribution_archive,
             logger=self._logger,
             requirement_parser=self._requirement_parser,
         )
         self._move_package_target_directory(built_distribution_archive)
         self._sources.add(
             name=name,
             source=PathSource(
                 path=str(self._get_distribution_path(name, version))),
         )
     return source_distribution
Exemplo n.º 14
0
def flit_distribution(data_directory, logger):
    archive = Archive(os.path.join(data_directory, "flit-1.3.tar.gz"))
    return SourceDistribution.from_archive(archive, logger)
def test_that_flit_build_dependencies_contains_requests(
        flit_distribution: SourceDistribution,
        current_platform: TargetPlatform):
    assert "requests" in flit_distribution.build_dependencies(current_platform)
def test_that_a_source_distributions_name_is_canonicalized(
        logger: Logger, requirement_parser: RequirementParser):
    distribution = SourceDistribution(name="NaMe_teSt",
                                      logger=logger,
                                      requirement_parser=requirement_parser)
    assert distribution.name == "name-test"
def flit_distribution(data_directory, logger: Logger,
                      requirement_parser: RequirementParser):
    archive = Archive(os.path.join(data_directory, "flit-1.3.tar.gz"))
    return SourceDistribution.from_archive(
        archive, logger, requirement_parser=requirement_parser)
Exemplo n.º 18
0
def test_that_we_can_generate_objects_from_source_archives(
        source_distribution_archive, logger):
    SourceDistribution.from_archive(source_distribution_archive, logger)
Exemplo n.º 19
0
def test_that_a_source_distributions_name_is_canonicalized(logger):
    distribution = SourceDistribution(name="NaMe_teSt", logger=logger)
    assert distribution.name == "name-test"
Exemplo n.º 20
0
def source_distribution(six_source_distribution_archive, logger):
    return SourceDistribution.from_archive(six_source_distribution_archive,
                                           logger)