Пример #1
0
def get_inhouse_dependencies(pkg_dir, exceptions=[], indent_txt=''):
    """
    Yields a list of dependencies to setup.
    """
    with chdir(pkg_dir):
        if os.path.isfile('setup.cfg'):
            metadata = config.parse_pkg_metadata(config.get_pkg_cfg_parser())
            for req in parse_requirements(
                list(r for r in metadata.get('install_requires', [])
                     if is_inhouse_package(r))):
                if req.project_name not in exceptions:
                    yield req.project_name
        else:
            get_log().warn("%s Package at %s has no setup.cfg file, cannot find dependencies." % (indent_txt, pkg_dir))
Пример #2
0
def setup():
    """ Mirror pkglib's setup() method for each sub-package in this repository.
    """
    top_level_parser = config.parse.get_pkg_cfg_parser()
    cfg = config._parse_metadata(top_level_parser, 'multipkg', ['pkg_dirs'])
    rc = [0]
    for dirname in cfg['pkg_dirs']:
        with manage.chdir(dirname):
            # Update sub-package setup.cfg with top-level version
            sub_parser = config.parse.get_pkg_cfg_parser()
            sub_cfg = config.parse_pkg_metadata(sub_parser)
            if sub_cfg['version'] != cfg['version']:
                print ("Updating setup.cfg version for {0}: {1} -> {2}"
                       .format(dirname, sub_cfg['version'], cfg['version']))
                sub_parser.set('metadata', 'version', cfg['version'])
                with open('setup.cfg', 'w') as sub_cfg_file:
                    sub_parser.write(sub_cfg_file)

            cmd = [sys.executable, "setup.py"] + sys.argv[1:]
            print ("In directory {0}: Running '{1}'"
                   .format(dirname, ' '.join(cmd)))
            p = subprocess.Popen(cmd)
            p.communicate()
            if p.returncode != 0:
                # Here we exit straight away, unless this was a run as
                # 'python setup.py test'. Reason for this is that we want to
                # run all the packages' tests through and gather the results.
                # Exception: using the -x/--exitfirst option.
                # For any other setup.py command, a failure here is likely
                # some sort of build or config issue and it's best not to
                # plow on.
                print "Command failed with exit code {0}".format(p.returncode)
                if 'test' in cmd and not '-x' in ' '.join(cmd)  \
                                and not '--exitfirst' in ' '.join(cmd):
                    rc[0] = p.returncode
                else:
                    sys.exit(p.returncode)
    sys.exit(rc[0])
Пример #3
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)