Пример #1
0
def main(argv=sys.argv[1:]):
    """Script entry point.
    """
    # TODO: allow cmdline override of org config
    org.setup_global_org_config()
    virtualenv_dir = sys.exec_prefix

    commands = {
        "use": use_command,
        "up": up_command,
        "develop": develop_command,
        "undevelop": undevelop_command,
        "info": info_command,
        "list": list_command,
        "versions": versions_command,
        "components": components_command,
    }

    ns = parse_options(argv)
    command = commands[ns.command]
    try:
        plat = platypus.Platypus(virtualenv_dir,
                                 quiet=ns.quiet,
                                 debug=ns.debug)
        command(plat, ns)
    except Exception as e:
        if plat.captured_out:
            errormsg("Sub-command output:")
            print(plat.captured_out)
        terminate(str(e))
Пример #2
0
def run_setup_command(command, cmdclass=None, usage=DEFAULT_USAGE, argv=None,
                      **kw):
    """ Cribbed from distribute.setuptools.command.easy_install. Runs a
        setup command via an entry point.
    """
    org.setup_global_org_config()

    class DistributionWithoutHelpCommands(Distribution):
        common_usage = command.description

        def _show_help(self, *args, **kw):
            with ei_usage(usage):
                Distribution._show_help(self, *args, **kw)

        def find_config_files(self):
            files = Distribution.find_config_files(self)
            if 'setup.cfg' in files:
                files.remove('setup.cfg')
            return files

    args = _create_args(argv, command)

    if cmdclass is None:
        cmdclass = {command.__name__: command}

    with ei_usage(usage):
        setup(
            script_args=args,
            script_name=sys.argv[0],
            distclass=DistributionWithoutHelpCommands,
            cmdclass=cmdclass,
            **kw)
Пример #3
0
def main(argv=sys.argv[1:]):
    """Script entry point.
    """
    # TODO: allow cmdline override of org config
    org.setup_global_org_config()
    virtualenv_dir = sys.exec_prefix

    commands = {
        "use": use_command,
        "up": up_command,
        "develop": develop_command,
        "undevelop": undevelop_command,
        "info": info_command,
        "list": list_command,
        "versions": versions_command,
        "components": components_command,
    }

    ns = parse_options(argv)
    command = commands[ns.command]
    try:
        plat = platypus.Platypus(virtualenv_dir, quiet=ns.quiet, debug=ns.debug)
        command(plat, ns)
    except Exception as e:
        if plat.captured_out:
            errormsg("Sub-command output:")
            print(plat.captured_out)
        terminate(str(e))
Пример #4
0
def run_setup_command(command,
                      cmdclass=None,
                      usage=DEFAULT_USAGE,
                      argv=None,
                      **kw):
    """ Cribbed from distribute.setuptools.command.easy_install. Runs a
        setup command via an entry point.
    """
    org.setup_global_org_config()

    class DistributionWithoutHelpCommands(Distribution):
        common_usage = command.description

        def _show_help(self, *args, **kw):
            with ei_usage(usage):
                Distribution._show_help(self, *args, **kw)

        def find_config_files(self):
            files = Distribution.find_config_files(self)
            if 'setup.cfg' in files:
                files.remove('setup.cfg')
            return files

    args = _create_args(argv, command)

    if cmdclass is None:
        cmdclass = {command.__name__: command}

    with ei_usage(usage):
        setup(script_args=args,
              script_name=sys.argv[0],
              distclass=DistributionWithoutHelpCommands,
              cmdclass=cmdclass,
              **kw)
Пример #5
0
def main():
    """
    Simply calls 'paster create <opts>', defaulting to the pkglib_project template
    """
    org.setup_global_org_config()

    if not [i for i in sys.argv if i.startswith('-t')]:
        sys.argv = sys.argv[:1] + ['-t', 'pkglib_project'] + sys.argv[1:]
    sys.argv.insert(1, 'create')
    run()
Пример #6
0
def main():
    """
    Simply calls 'paster create <opts>', defaulting to the pkglib_project template
    """
    org.setup_global_org_config()

    if not [i for i in sys.argv if i.startswith('-t')]:
        sys.argv = sys.argv[:1] + ['-t', 'pkglib_project'] + sys.argv[1:]
    sys.argv.insert(1, 'create')
    run()
Пример #7
0
def main():
    """Main method of pycheckout"""
    # TODO: allow cmdline override of org config?
    org.setup_global_org_config()
    options = get_options()

    try:
        pypi = PyPi(options.pypi)
        process_pkg(pypi, options.package, options.dest_dir, options,
                    options.deps)
        log.info("Done!")

    except (CalledProcessError, UserError), e:
        log.fatal(e)
        sys.exit(15)
Пример #8
0
def main():
    """Main method of pycheckout"""
    # TODO: allow cmdline override of org config?
    org.setup_global_org_config()
    options = get_options()

    try:
        pypi = PyPi(options.pypi)
        process_pkg(pypi, options.package, options.dest_dir, options,
                    options.deps)
        log.info("Done!")

    except (CalledProcessError, UserError), e:
        log.fatal(e)
        sys.exit(15)
Пример #9
0
def setup(**kwargs):
    """
    Call the regular `setuptools.setup` function with data read from
    our setup.cfg file.

    Parameters
    ----------
    kwargs : arguments dictionary
        Override any of the default `setuptools.setup` keyword arguments.

    """
    org.setup_global_org_config()
    check_multiple_call()
    original_cwd = os.getcwd()
    set_working_dir()
    test.gather_trailing_args()
    # Base set of defaults
    call_args = dict(
        distclass=Distribution,
        name='',
        version='',
        description='',
        long_description='',
        keywords='',
        author='',
        author_email='',
        url='',
        setup_requires=[],
        install_requires=[],
        tests_require=[],
        license='Proprietary',
        classifiers=[],
        entry_points={},
        scripts=[],
        ext_modules=[],
        packages=find_packages(exclude=['test*']),
        include_package_data=True,
        zip_safe=True,
        namespace_packages=[],
        original_cwd=original_cwd,
        cmdclass=dict(DEFAULT_CMD_CLASS),
        options=dict(
             aliases=dict(ALIASES),
        ))

    # Get the package metadata from the setup.cfg file
    call_args.update(parse.parse_pkg_metadata(parse.get_pkg_cfg_parser()))

    # Overrides/updates attributes from call arguments.
    # Override for scalar, update for dictionaries.
    for k, v in kwargs.items():
        if type(v) is dict and k in call_args:
            call_args[k].update(v)
        else:
            call_args[k] = v

    check_distclass(call_args["distclass"])

    # Call base setup method, retrieve distribution
    dist = setuptools_setup(**call_args)

    # Check if we've set a failed flag this may be due to a failed upload.
    if hasattr(dist, '_failed') and dist._failed:
        raise SystemExit(1)
Пример #10
0
def main(argv=None, **kw):
    """ Run a test package's tests.
    """
    org.setup_global_org_config()

    USAGE = """\
usage: %(script)s <package name> [test options]
   or: %(script)s --help
""" % {
        'script': sys.argv[0] or 'runtests'
    }

    if argv is None:
        argv = sys.argv[1:]

    if not argv:
        print "Please specify a package name."
        print USAGE
        sys.exit(1)

    pkg_name, argv = argv[0], argv[1:]
    test_pkg_name = 'test.%s' % pkg_name

    # Find our
    real_dist = [i for i in working_set if i.project_name == pkg_name]
    if not real_dist:
        print "Package %s is not installed" % pkg_name
        sys.exit(1)
    real_dist = real_dist[0]

    test_dist = [i for i in working_set if i.project_name == test_pkg_name]
    if not test_dist:
        print "Test package %s is not installed" % test_pkg_name
        sys.exit(1)
    test_dist = test_dist[0]

    # Construct a distutils.Distribtion class from the pkg_resources.Distribution
    # of the real package so we can pass it into the test command class.
    # We have checked that the packages are already installed so we set the install
    # requirements to blank.

    args = {
        'name': real_dist.project_name,
        'install_requires': [],
        'tests_require': [],
        'namespace_packages':
        list(real_dist._get_metadata('namespace_packages')),
        'packages': [real_dist.project_name],
    }
    real_cmd_dist = Distribution(args)
    cmd = test(real_cmd_dist)
    cmd.args = argv

    # Read in the test options saved away during egg_info and set the command defaults,
    # this would normally be done by the setup() method via the Distribution class
    test_options = join(test_dist.location, 'EGG-INFO', 'test_options.txt')
    if isfile(test_options):
        real_cmd_dist.parse_config_files([test_options])
    for k, v in real_cmd_dist.get_option_dict('test').items():
        print "Found test option in %s: %s = %s" % (v[0], k, v[1])
        setattr(cmd, k, v[1])

    # Finalize and run the command, overriding the test root to be inside the test egg
    cmd.finalize_options()
    cmd.test_root = join(test_dist.location, CONFIG.test_egg_namespace,
                         real_dist.project_name.replace('.', '/'))
    # Pylint is only for regular Jenkins jobs, this in itself should not trigger even if
    # running under Jenkins
    cmd.no_pylint = True
    cmd.run()
Пример #11
0
def setup(**kwargs):
    """
    Call the regular `setuptools.setup` function with data read from
    our setup.cfg file.

    Parameters
    ----------
    kwargs : arguments dictionary
        Override any of the default `setuptools.setup` keyword arguments.

    """
    org.setup_global_org_config()
    check_multiple_call()
    original_cwd = os.getcwd()
    set_working_dir()
    test.gather_trailing_args()
    # Base set of defaults
    call_args = dict(distclass=Distribution,
                     name='',
                     version='',
                     description='',
                     long_description='',
                     keywords='',
                     author='',
                     author_email='',
                     url='',
                     setup_requires=[],
                     install_requires=[],
                     tests_require=[],
                     license='Proprietary',
                     classifiers=[],
                     entry_points={},
                     scripts=[],
                     ext_modules=[],
                     packages=find_packages(exclude=['test*']),
                     include_package_data=True,
                     zip_safe=True,
                     namespace_packages=[],
                     original_cwd=original_cwd,
                     cmdclass=dict(DEFAULT_CMD_CLASS),
                     options=dict(aliases=dict(ALIASES), ))

    # Get the package metadata from the setup.cfg file
    call_args.update(parse.parse_pkg_metadata(parse.get_pkg_cfg_parser()))

    # Overrides/updates attributes from call arguments.
    # Override for scalar, update for dictionaries.
    for k, v in kwargs.items():
        if type(v) is dict and k in call_args:
            call_args[k].update(v)
        else:
            call_args[k] = v

    check_distclass(call_args["distclass"])

    # Call base setup method, retrieve distribution
    dist = setuptools_setup(**call_args)

    # Check if we've set a failed flag this may be due to a failed upload.
    if hasattr(dist, '_failed') and dist._failed:
        raise SystemExit(1)
Пример #12
0
def main(argv=None, **kw):
    """ Run a test package's tests.
    """
    org.setup_global_org_config()

    USAGE = """\
usage: %(script)s <package name> [test options]
   or: %(script)s --help
""" % {'script': sys.argv[0] or 'runtests'}

    if argv is None:
        argv = sys.argv[1:]

    if not argv:
        print "Please specify a package name."
        print USAGE
        sys.exit(1)

    pkg_name, argv = argv[0], argv[1:]
    test_pkg_name = 'test.%s' % pkg_name

    # Find our
    real_dist = [i for i in working_set if i.project_name == pkg_name]
    if not real_dist:
        print "Package %s is not installed" % pkg_name
        sys.exit(1)
    real_dist = real_dist[0]

    test_dist = [i for i in working_set if i.project_name == test_pkg_name]
    if not test_dist:
        print "Test package %s is not installed" % test_pkg_name
        sys.exit(1)
    test_dist = test_dist[0]

    # Construct a distutils.Distribtion class from the pkg_resources.Distribution
    # of the real package so we can pass it into the test command class.
    # We have checked that the packages are already installed so we set the install
    # requirements to blank.

    args = {'name': real_dist.project_name,
            'install_requires': [],
            'tests_require': [],
            'namespace_packages': list(real_dist._get_metadata('namespace_packages')),
            'packages': [real_dist.project_name],
            }
    real_cmd_dist = Distribution(args)
    cmd = test(real_cmd_dist)
    cmd.args = argv

    # Read in the test options saved away during egg_info and set the command defaults,
    # this would normally be done by the setup() method via the Distribution class
    test_options = join(test_dist.location, 'EGG-INFO', 'test_options.txt')
    if isfile(test_options):
        real_cmd_dist.parse_config_files([test_options])
    for k, v in real_cmd_dist.get_option_dict('test').items():
        print "Found test option in %s: %s = %s" % (v[0], k, v[1])
        setattr(cmd, k, v[1])

    # Finalize and run the command, overriding the test root to be inside the test egg
    cmd.finalize_options()
    cmd.test_root = join(test_dist.location, CONFIG.test_egg_namespace ,
                         real_dist.project_name.replace('.', '/'))
    # Pylint is only for regular Jenkins jobs, this in itself should not trigger even if
    # running under Jenkins
    cmd.no_pylint = True
    cmd.run()