Пример #1
0
def main(argv=None, **kw):
    # TODO: allow cmdline override of org config?
    config.setup_org_config()
    run_setup_command(
        pyinstall,
        usage=USAGE,
        argv=argv,
        # We need update here as well for the -U flag
        cmdclass={"pyinstall": pyinstall, "update": update},
        **kw
    )
Пример #2
0
def main():
    """
    Simply calls 'paster create <opts>', defaulting to the pkglib_project template
    """
    # TODO: allow cmdline override of org config?
    config.setup_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()
Пример #3
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.
    """
    # TODO: allow cmdline override of org config?
    config.setup_org_config()


    def gen_usage(script_name):
        script = os.path.basename(script_name)
        return usage % vars()

    def with_ei_usage(f):
        old_gen_usage = distutils.core.gen_usage
        try:
            distutils.core.gen_usage = gen_usage
            return f()
        finally:
            distutils.core.gen_usage = old_gen_usage

    class DistributionWithoutHelpCommands(Distribution):
        common_usage = command.description

        def _show_help(self, *args, **kw):
            with_ei_usage(lambda: 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

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

    global_opts = []
    for l, s, _ in [i[:3] for i in Distribution.global_options]:
        global_opts += ['--%s' % l, '-%s' % s]

    args = [i for i in argv if i in global_opts] + \
           [command.__name__] + \
           [i for i in argv if i not in global_opts]

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

    with_ei_usage(lambda:
        setup(
            script_args=args,
            script_name=sys.argv[0],
            distclass=DistributionWithoutHelpCommands,
            cmdclass=cmdclass,
            **kw))
Пример #4
0
def main():
    """Main method of pycheckout"""
    # TODO: allow cmdline override of org config?
    config.setup_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)
Пример #5
0
def main(argv=sys.argv[1:]):
    """Script entry point.
    """
    # TODO: allow cmdline override of org config 
    config.setup_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,
    }

    try:
        ns = parse_options(argv)
    except errors.UserError, e:
        terminate(str(e))
Пример #6
0
"""
PkgLib Testing Library
===================

This library contains useful helpers for writing unit and acceptance tests.
"""

# Many of the features here require pkglib configuration, we'll  parse this on
# import for simplicity's sake.
from pkglib import config

config.setup_org_config()
Пример #7
0
def main(argv=None, **kw):
    """ Run a test package's tests.
    """
    # TODO: allow cmdline override of org config?
    config.setup_org_config()

    from path import path

    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 = path(test_dist.location) / 'EGG-INFO' / 'test_options.txt'
    if test_options.isfile():
        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 = path(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()
Пример #8
0
 def __init__(self, **kwargs):
     config.setup_org_config()
     mongod_dir = tempfile.mkdtemp(dir=self.get_base_dir())
     super(MongoTestServer, self).__init__(workspace=mongod_dir, **kwargs)
Пример #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.

    """
    # Setup all our packaging config
    config.setup_org_config(kwargs.get('org_config'))

    set_working_dir()
    # Base set of defaults
    call_args = dict(
        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=False,
        namespace_packages=[],
        cmdclass={
          'develop': develop.develop,
          'egg_info': egg_info.egg_info,
          'jenkins': jenkins.jenkins,
          'update': update.update,
          'depgraph': depgraph.depgraph,
          'pyinstall': pyinstall.pyinstall,
          'build_sphinx': build_sphinx.build_sphinx,
          'build_ext': build_ext.build_ext,
          'build_ext_static_interpreter': build_ext_static_interpreter.build_ext_static_interpreter,
          'ext_gcov_test': ext_gcov_test.ext_gcov_test,
          'test_egg': test_egg.test_egg,
          'upload': upload.upload,
          'register': register.register,
          'upload_docs': upload_docs.upload_docs,
          'deploy': deploy.deploy,
          'cleanup': cleanup.cleanup,
          'tidy': tidy.tidy,
          'release_externals': release_externals.release_externals,
          # Uninstall synonyms
          'uninstall': pyuninstall.pyuninstall,
          'remove': pyuninstall.pyuninstall,
          # Test synonyms
          'test': test.test,
          'nosetests': test.test,
          'pytest': test.test,
    })

    # Get the package metadata from the setup.cfg file
    metadata = config.parse_pkg_metadata(config.get_pkg_cfg_parser())

    # Determine namespace packages based off of the name
    call_args['namespace_packages'] = get_namespace_packages(metadata['name'])

    # Update the long description based off of README,CHANGES etc.
    metadata['long_description'] = get_pkg_description(metadata)

    # Overrides from setup.cfg file. console_scripts is a bit special in this regards as
    # it lives under entry_points
    call_args.update(metadata)
    if 'console_scripts' in call_args:
        call_args['entry_points']['console_scripts'] = call_args['console_scripts']
        del(call_args['console_scripts'])

    # Overrides/Updates from call arguments. Override for scalar, update for dict.
    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

    if 'install_requires' in call_args:
        call_args['install_requires'] = clean_requires(call_args['install_requires'])

    # Call base setup method, retrieve distribution
    dist = _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):
    # TODO: allow cmdline override of org config?
    config.setup_org_config()
    run_setup_command(depgraph, usage=USAGE, argv=argv, **kw)
Пример #11
0
def main(argv=None, **kw):
    # TODO: allow cmdline override of org config?
    config.setup_org_config()
    run_setup_command(cleanup, argv=argv, **kw)