Пример #1
0
def blockers(project_names):
    log = logging.getLogger('ciu')
    overrides = pypi.manual_overrides()

    def supports_py3(project_name):
        if project_name in overrides:
            return True
        else:
            return pypi.supports_py3(project_name)

    check = []
    evaluated = set(overrides)
    for project in project_names:
        log.info('Checking top-level project: {0} ...'.format(project))
        evaluated.add(project)
        if not supports_py3(project):
            check.append(project)
    reasons = {project: None for project in check}
    thread_pool_executor = concurrent.futures.ThreadPoolExecutor(
            max_workers=ciu.CPU_COUNT)
    with thread_pool_executor as executor:
        while len(check) > 0:
            new_check = []
            for parent, deps in zip(check, executor.map(dependencies, check)):
                if deps is None:
                    # Can't find any results for a project, so ignore it so as
                    # to not accidentally consider indefinitely that a project
                    # can't port.
                    del reasons[parent]
                    continue
                log.info('Dependencies of {0}: {1}'.format(project, deps))
                unchecked_deps = []
                for dep in deps:
                    if dep in evaluated:
                        log.info('{0} already checked'.format(dep))
                    else:
                        unchecked_deps.append(dep)
                deps_status = zip(unchecked_deps,
                                  executor.map(supports_py3,
                                               unchecked_deps))
                for dep, ported in deps_status:
                    if not ported:
                        reasons[dep] = parent
                        new_check.append(dep)
                    # Make sure there's no data race in recording a dependency
                    # has been evaluated but not reported somewhere.
                    evaluated.add(dep)
            check = new_check
    return reasons_to_paths(reasons)
Пример #2
0
def blockers(project_names):
    log = logging.getLogger('ciu')
    overrides = pypi.manual_overrides()

    def supports_py3(project_name):
        if project_name in overrides:
            return True
        else:
            return pypi.supports_py3(project_name)

    check = []
    evaluated = set(overrides)
    for project in project_names:
        log.info('Checking top-level project: {0} ...'.format(project))
        evaluated.add(project)
        if not supports_py3(project):
            check.append(project)
    reasons = {project: None for project in check}
    thread_pool_executor = concurrent.futures.ThreadPoolExecutor(
        max_workers=ciu.CPU_COUNT)
    with thread_pool_executor as executor:
        while len(check) > 0:
            new_check = []
            for parent, deps in zip(check, executor.map(dependencies, check)):
                if deps is None:
                    # Can't find any results for a project, so ignore it so as
                    # to not accidentally consider indefinitely that a project
                    # can't port.
                    del reasons[parent]
                    continue
                log.info('Dependencies of {0}: {1}'.format(project, deps))
                unchecked_deps = []
                for dep in deps:
                    if dep in evaluated:
                        log.info('{0} already checked'.format(dep))
                    else:
                        unchecked_deps.append(dep)
                deps_status = zip(unchecked_deps,
                                  executor.map(supports_py3, unchecked_deps))
                for dep, ported in deps_status:
                    if not ported:
                        reasons[dep] = parent
                        new_check.append(dep)
                    # Make sure there's no data race in recording a dependency
                    # has been evaluated but not reported somewhere.
                    evaluated.add(dep)
            check = new_check
    return reasons_to_paths(reasons)
Пример #3
0
def check(requirements_paths=[], metadata=[], projects=[]):
    """Return True if all of the specified dependencies have been ported to Python 3.

    The requirements_paths argument takes a sequence of file paths to
    requirements files. The 'metadata' argument takes a sequence of strings
    representing metadata. The 'projects' argument takes a sequence of project
    names.

    Any project that is not listed on PyPI will be considered ported.
    """
    dependencies = []
    dependencies.extend(main.projects_from_requirements(requirements_paths))
    dependencies.extend(main.projects_from_metadata(metadata))
    dependencies.extend(projects)

    manual_overrides = pypi.manual_overrides()

    for dependency in dependencies:
        if dependency in manual_overrides:
            continue
        elif not pypi.supports_py3(dependency):
            return False
    return True
Пример #4
0
 def test_success(self):
     overrides = pypi.manual_overrides()
     self.assertTrue(len(overrides) > 10)
     self.assertIn("unittest2", overrides)
Пример #5
0
 def test_canonicalization(self):
     for name in pypi.manual_overrides():
         self.assertEqual(name, packaging.utils.canonicalize_name(name))
Пример #6
0
 def test_success(self):
     overrides = pypi.manual_overrides()
     self.assertTrue(len(overrides) > 10)
     self.assertIn("unittest2", overrides)
Пример #7
0
 def test_canonicalization(self):
     for name in pypi.manual_overrides():
         self.assertEqual(name, packaging.utils.canonicalize_name(name))