Exemplo n.º 1
0
def create_projects(env, **proj_metadata):
    """
    Create git repositories and an index for projects within env.

    env should be an Environment

    proj_metadata should be a dict mapping project names to
    DistributionMetadata objects representing their metadata.  

    Returns (index,projdirs) where:

    * index is the path to the locally-generated index

    * projdirs is a dict mapping project names to the paths to the
      locally-generated git repositories.
    """
    from distutils2.metadata import DistributionMetadata

    index = env.scratch_path/'index'
    mktree(index)
    repo = env.scratch_path/'repo'
    
    open(index/'index.html', 'w').write(
        '\n'.join(
            ['<html><head><title>Simple Index</title></head><body>']
            + [ '<a href=%r/>%s</a><br/>' % (p,p) for p in proj_metadata ]
            + ['</body></html>'])
        )
    
    projects = {}

    for p,metadata in proj_metadata.items():

        mktree(index/p)
        
        root = repo/p
        projects[p] = Project(p, root, env)
        mktree(root)

        env.run('git', 'init', cwd = root)

        dot_ryppl = root/'.ryppl'

        if isinstance(metadata, basestring):
            m = DistributionMetadata()
            m.read_file(StringIO(metadata))
            metadata = m
        elif isinstance(metadata, dict):
            m = DistributionMetadata()
            for k,v in metadata.items():
                m[k] = v
            metadata = m

        metadata['Name'] = p
        if metadata['Version'] == 'UNKNOWN':
            metadata['Version'] = '0.9'
        if metadata['Requires-Python'] == 'UNKNOWN':
            metadata['Requires-Python'] = '>2.0'
            

        mktree(dot_ryppl)
        metadata.write(dot_ryppl/'METADATA')

        # mktree(root/p)
        # open(root/p/'__init__.py', 'w').write('print "importing module %s"' % p)

        env.run('git', 'add', '*', Path('.ryppl')/'*', cwd = root)
        env.run('git', 'commit', '-m', 'initial checkin', cwd = root)

        repo_url = pathname2url(root)

        open(index/p/'index.html', 'w').write(
            '<html><head><title>Links for %(p)s</title></head>'
            '<body>'
            '<h1>Links for %(p)s</h1>'
            '<a href="git+file://%(repo_url)s#egg=%(p)s">Git Repository</a><br/>'
            '</body></html>'
            % locals()
            )
        
    return 'file://'+pathname2url(index),projects
Exemplo n.º 2
0
                    os.path.join(self.build_base, 'install_manifest.txt'),
                    self.record)

                # Add the .egg-info directory and its contents to the install_record.txt
                open(
                    self.record,
                    'a+').write('\n'.join(install_egg_info_cmd.get_outputs()) +
                                '\n')

            else:
                _install.run(self)


# Read the metadata out of the project's .ryppl/METADATA file
metadata = DistributionMetadata(path=os.path.join(os.getcwd(), '.ryppl',
                                                  'METADATA'),
                                platform_dependant=True)


def metadata_to_setup_keywords(metadata):
    """
    Convert a Distutils2 metadata object into a dict of named
    arguments to be passed to setup()
    """
    if use_distutils2:
        # Everything *should* be this easy.
        return dict(metadata.items())
    else:

        class item_to_attribute(object):
            """