Beispiel #1
0
    def get_test_roots(self):
        """ Find test directories, skipping nested dirs and anything marked
            to skip under [pytest]:norecursedirs
        """
        from path import path
        res = []
        no_recurse = []
        cfg = config.get_pkg_cfg_parser()
        if cfg.has_section('pytest') and \
           cfg.has_option('pytest', 'norecursedirs'):
            [no_recurse.extend(path.getcwd().glob(i)) for i in
             cfg.get('pytest', 'norecursedirs').split()]
            no_recurse = [i.abspath() for i in no_recurse]

        test_dirs = [i for i in
                     path.getcwd().walkdirs(CONFIG.test_dirname)]
        test_dirs.sort(key=len)
        for i in test_dirs:
            try:
                for j in res + no_recurse:
                    if i.startswith(j):
                        raise ValueError
            except ValueError:
                pass
            else:
                res.append(i)
        log.debug("Test roots: {0}".format(res))
        return res
Beispiel #2
0
 def create_pytest_config(self, filename):
     """
     Extracts the pytest specific sections from setup.cfg and puts them into
     a separate config file in the build dir
     """
     parser = config.get_pkg_cfg_parser()
     [parser.remove_section(s) for s in parser.sections() if s != 'pytest']
     if parser.has_section('pytest'):
         with filename.open('wb') as fp:
             parser.write(fp)
Beispiel #3
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))
Beispiel #4
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)