Пример #1
0
def pin_requirements(dist, all_dists):
    """
    Override versions of things we're tagging to be explicit pins. 
    This will 'flatten' the dependency graph for anything that is third-party so that nothing 
    shifts under our feet when we install this later.
    """
    get_log().info("Pinning requirements for %s" % dist)

    with chdir(dist.location):
        parser = get_parser()
        cfg = get_metadata(parser)
        new_reqs = set()
        for req in pkg_resources.parse_requirements(cfg['install_requires']):
            if not req.key in all_dists:
                raise PackageError("Dependency %s is not installed, cannot pin to version." % req.project_name)
            req_dist = all_dists[req.key]
            if is_third_party(req_dist):
                # Flatten third-party requirement graphs.
                [new_reqs.add(i.as_requirement()) for i in resolve_dependencies([req_dist]).values()]
            else:
                new_reqs.add(all_dists[req.key].as_requirement())
        
        parser.set('metadata','install_requires',  '\n'.join(str(i) for i in new_reqs))

        # Save setup file away so we can go back to the un-pinned version
        shutil.copyfile('setup.cfg', 'setup.cfg.unpinned')

        # Write out pinned requirements 
        with open('setup.cfg', 'wb') as fp:
            parser.write(fp)
        return new_reqs
Пример #2
0
def pin_requirements(dist, all_dists):
    """
    Override versions of things we're tagging to be explicit pins. 
    This will 'flatten' the dependency graph for anything that is third-party so that nothing 
    shifts under our feet when we install this later.
    """
    get_log().info("Pinning requirements for %s" % dist)

    with chdir(dist.location):
        parser = get_parser()
        cfg = get_metadata(parser)
        new_reqs = set()
        for req in pkg_resources.parse_requirements(cfg['install_requires']):
            if not req.key in all_dists:
                raise PackageError(
                    "Dependency %s is not installed, cannot pin to version." %
                    req.project_name)
            req_dist = all_dists[req.key]
            if is_third_party(req_dist):
                # Flatten third-party requirement graphs.
                [
                    new_reqs.add(i.as_requirement())
                    for i in resolve_dependencies([req_dist]).values()
                ]
            else:
                new_reqs.add(all_dists[req.key].as_requirement())

        parser.set('metadata', 'install_requires',
                   '\n'.join(str(i) for i in new_reqs))

        # Save setup file away so we can go back to the un-pinned version
        shutil.copyfile('setup.cfg', 'setup.cfg.unpinned')

        # Write out pinned requirements
        with open('setup.cfg', 'wb') as fp:
            parser.write(fp)
        return new_reqs
Пример #3
0
def get_dist_name(pkg_dir):
    with chdir(pkg_dir):
        return get_metadata(get_parser())['name']
Пример #4
0
def get_dist_name(pkg_dir):
    with chdir(pkg_dir):
        return get_metadata(get_parser())['name']