コード例 #1
0
ファイル: run.py プロジェクト: MrMalina/Source.Python
def _metadata(dispatcher, args, **kw):
    opts = _parse_args(args[1:], 'f:', [])
    if opts['args']:
        name = opts['args'][0]
        dist = get_distribution(name, use_egg_info=True)
        if dist is None:
            logger.warning('%r not installed', name)
            return 1
    elif os.path.isfile('setup.cfg'):
        logger.info('searching local dir for metadata')
        dist = Distribution()  # XXX use config module
        dist.parse_config_files()
    else:
        logger.warning('no argument given and no local setup.cfg found')
        return 1

    metadata = dist.metadata

    if 'f' in opts:
        keys = (k for k in opts['f'] if k in metadata)
    else:
        keys = metadata.keys()

    for key in keys:
        if key in metadata:
            print(metadata._convert_name(key) + ':')
            value = metadata[key]
            if isinstance(value, list):
                for v in value:
                    print('   ', v)
            else:
                print('   ', value.replace('\n', '\n    '))
コード例 #2
0
ファイル: run.py プロジェクト: MrMalina/Source.Python
def _run(dispatcher, args, **kw):
    parser = dispatcher.parser
    args = args[1:]

    commands = STANDARD_COMMANDS  # FIXME display extra commands

    if args == ['--list-commands']:
        print('List of available commands:')
        for cmd in commands:
            cls = dispatcher.cmdclass.get(cmd) or get_command_class(cmd)
            desc = getattr(cls, 'description', '(no description available)')
            print('  %s: %s' % (cmd, desc))
        return

    while args:
        args = dispatcher._parse_command_opts(parser, args)
        if args is None:
            return

    # create the Distribution class
    # need to feed setup.cfg here !
    dist = Distribution()

    # Find and parse the config file(s): they will override options from
    # the setup script, but be overridden by the command line.

    # XXX still need to be extracted from Distribution
    dist.parse_config_files()

    for cmd in dispatcher.commands:
        # FIXME need to catch MetadataMissingError here (from the check command
        # e.g.)--or catch any exception, print an error message and exit with 1
        dist.run_command(cmd, dispatcher.command_options[cmd])

    return 0
コード例 #3
0
ファイル: install.py プロジェクト: MrMalina/Source.Python
def _run_packaging_install(path):
    # XXX check for a valid setup.cfg?
    dist = Distribution()
    dist.parse_config_files()
    try:
        dist.run_command('install_dist')
        name = dist.metadata['Name']
        return database.get_distribution(name) is not None
    except (IOError, os.error, PackagingError, CCompilerError) as msg:
        raise ValueError("Failed to install, " + str(msg))
コード例 #4
0
ファイル: test_config.py プロジェクト: Naddiseo/cpython
 def get_dist(self):
     dist = Distribution()
     dist.parse_config_files()
     return dist