Example #1
0
def projects_from_metadata(metadata):
    """Extract the project dependencies from a metadata spec."""
    projects = []
    for data in metadata:
        meta = distlib.metadata.Metadata(fileobj=io.StringIO(data))
        projects.extend(pypi.just_name(project) for project in meta.run_requires)
    return frozenset(map(packaging.utils.canonicalize_name, projects))
Example #2
0
def projects_from_metadata(metadata):
    """Extract the project dependencies from a metadata spec."""
    projects = []
    for data in metadata:
        meta = distlib.metadata.Metadata(fileobj=io.StringIO(data))
        projects.extend(pypi.just_name(project) for project in meta.run_requires)
    return projects
def dependencies(project_name):
    """Get the dependencies for a project."""
    log = logging.getLogger('ciu')
    log.info('Locating dependencies for {}'.format(project_name))
    located = distlib.locators.locate(project_name, prereleases=True)
    if not located:
        log.warning('{0} not found'.format(project_name))
        return None
    return {packaging.utils.canonicalize_name(pypi.just_name(dep))
            for dep in located.run_requires}
Example #4
0
 def _dependencies(self):
     projects = []
     for attr in ('install_requires', 'tests_require'):
         requirements = getattr(self.distribution, attr, None) or []
         for project in requirements:
             if not project:
                 continue
             projects.append(pypi.just_name(project))
     extras = getattr(self.distribution, 'extras_require', None) or {}
     for value in extras.values():
         projects.extend(map(pypi.just_name, value))
     return projects
Example #5
0
def dependencies(project_name):
    """Get the dependencies for a project."""
    log = logging.getLogger('ciu')
    deps = []
    log.info('Locating {0}'.format(project_name))
    located = distlib.locators.locate(project_name, prereleases=True)
    if located is None:
        log.warning('{0} not found'.format(project_name))
        return None
    for dep in located.run_requires:
        # Drop any version details from the dependency name.
        deps.append(pypi.just_name(dep))
    return deps
Example #6
0
 def test_metadata(self):
     want = 'foo'
     got = pypi.just_name("foo; sys.platform == 'okook'")
     self.assertEqual(got, want)
Example #7
0
 def test_bad_requirements(self):
     # From the OpenStack requirements file:
     # https://raw2.github.com/openstack/requirements/master/global-requirements.txt
     want = 'warlock'
     got = pypi.just_name(want + '>1.01<2')
     self.assertEqual(got, want)
Example #8
0
 def test_requirements(self):
     want = 'project.name'
     got = pypi.just_name(want + '>=2.0.1')
     self.assertEqual(got, want)
Example #9
0
 def test_simple(self):
     want = 'simple-name_with.everything-separator_known'
     got = pypi.just_name(want)
     self.assertEqual(got, want)