(config)
For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
    For an example, see: https://github.com/tox-dev/tox-travis
For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
    For an example, see: https://github.com/tox-dev/tox-travis
For more info see : https : // tox . readthedocs . io / en / latest / plugins . html For an example see : https : // github . com / tox - dev / tox - travis
def tox_configure(config):
    """
    For more info, see: https://tox.readthedocs.io/en/latest/plugins.html
    For an example, see: https://github.com/tox-dev/tox-travis
    """
    sections = config._cfg.sections
    base_testenv = sections.get('testenv', {})

    # Default to false so:
    # 1. we don't affect other projects using tox
    # 2. check migrations can happen gradually
    if str(base_testenv.get(STYLE_FLAG, 'false')).lower() == 'true':
        # Disable flake8 since we already include that
        config.envlist[:] = [env for env in config.envlist if not env.endswith('flake8')]

        make_envconfig = get_make_envconfig()
        reader = get_reader(config)

        add_style_checker(config, sections, make_envconfig, reader)
        add_style_formatter(config, sections, make_envconfig, reader)

    # Workaround for https://github.com/tox-dev/tox/issues/1593
    #
    # Do this only after all dynamic environments have been created
    if str(base_testenv.get(FIX_DEFAULT_ENVDIR_FLAG, 'false')).lower() == 'true':
        for env_name, env_config in config.envconfigs.items():
            if env_config.envdir == config.toxinidir:
                env_config.envdir = config.toxworkdir / env_name
                env_config.envlogdir = env_config.envdir / 'log'
                env_config.envtmpdir = env_config.envdir / 'tmp'

    # Conditionally set 'e2e ready' depending on env variables or environment markers
    for cfg in config.envconfigs.values():
        if E2E_READY_CONDITION not in cfg.description:
            continue

        data, var = cfg.description.split(' if ')
        var = var.strip()

        if var in os.environ:
            cfg.description = data
        else:
            from packaging.markers import InvalidMarker, Marker

            try:
                marker = Marker(var)
            except InvalidMarker:
                cfg.description = '{} is missing'.format(var)
            else:
                if marker.evaluate():
                    cfg.description = data
                else:
                    cfg.description = 'environment does not match: {}'.format(var)

    # Next two sections hack the sequencing of Tox's package installation.
    #
    # Tox package installation order:
    #   1. Install `deps`, which typically looks like:
    #        deps =
    #            -e../datadog_checks_base[deps]
    #            -rrequirements-dev.txt
    #   2. Install check package, editable mode
    #   3. Execute `commands` which typically looks like:
    #        commands =
    #            pip install -r requirements.in
    #            pytest -v {posargs} --benchmark-skip

    # Forcibly remove any dependencies from the `tox.ini` deps that are meant to be unpinned
    # This should have the effect of relying on a package's setup.py for installation
    # We manually pip install `datadog_checks_base[deps]` to ensure that test dependencies are installed,
    # but this should have no effect on the version of the base package.
    force_unpinned = os.getenv('TOX_FORCE_UNPINNED', None)
    if force_unpinned:
        for env in config.envlist:
            deps = [d for d in config.envconfigs[env].deps if force_unpinned not in d.name]
            config.envconfigs[env].deps = deps
            config.envconfigs[env].commands.insert(0, 'pip install datadog_checks_base[deps]'.split())

    # Workaround for tox's `--force-dep` having limited functionality when package is already installed.
    # Primarily meant for pinning datadog-checks-base to a specific version, but could be
    # applied to other packages in the future. Since we typically install checks base via
    # editable mode, we need to force the reinstall to ensure that the PyPI package installs.
    force_install = os.getenv('TOX_FORCE_INSTALL', None)
    if force_install:
        command = f'pip install --force-reinstall {force_install}'.split()

        for env in config.envlist:
            config.envconfigs[env].commands.insert(0, command)
def tox_configure ( config ) : sections = config . _cfg . sections base_testenv = sections . get ( 'testenv' , { } ) # Default to false so: # 1. we don't affect other projects using tox # 2. check migrations can happen gradually if str ( base_testenv . get ( STYLE_FLAG , 'false' ) ) . lower ( ) == 'true' : # Disable flake8 since we already include that config . envlist [ : ] = [ env for env in config . envlist if not env . endswith ( 'flake8' ) ] make_envconfig = get_make_envconfig ( ) reader = get_reader ( config ) add_style_checker ( config , sections , make_envconfig , reader ) add_style_formatter ( config , sections , make_envconfig , reader ) # Workaround for https://github.com/tox-dev/tox/issues/1593 # # Do this only after all dynamic environments have been created if str ( base_testenv . get ( FIX_DEFAULT_ENVDIR_FLAG , 'false' ) ) . lower ( ) == 'true' : for env_name , env_config in config . envconfigs . items ( ) : if env_config . envdir == config . toxinidir : env_config . envdir = config . toxworkdir / env_name env_config . envlogdir = env_config . envdir / 'log' env_config . envtmpdir = env_config . envdir / 'tmp' # Conditionally set 'e2e ready' depending on env variables or environment markers for cfg in config . envconfigs . values ( ) : if E2E_READY_CONDITION not in cfg . description : continue data , var = cfg . description . split ( ' if ' ) var = var . strip ( ) if var in os . environ : cfg . description = data else : from packaging . markers import InvalidMarker , Marker try : marker = Marker ( var ) except InvalidMarker : cfg . description = '{} is missing' . format ( var ) else : if marker . evaluate ( ) : cfg . description = data else : cfg . description = 'environment does not match: {}' . format ( var ) # Next two sections hack the sequencing of Tox's package installation. # # Tox package installation order: #   1. Install `deps`, which typically looks like: #        deps = #            -e../datadog_checks_base[deps] #            -rrequirements-dev.txt #   2. Install check package, editable mode #   3. Execute `commands` which typically looks like: #        commands = #            pip install -r requirements.in #            pytest -v {posargs} --benchmark-skip # Forcibly remove any dependencies from the `tox.ini` deps that are meant to be unpinned # This should have the effect of relying on a package's setup.py for installation # We manually pip install `datadog_checks_base[deps]` to ensure that test dependencies are installed, # but this should have no effect on the version of the base package. force_unpinned = os . getenv ( 'TOX_FORCE_UNPINNED' , None ) if force_unpinned : for env in config . envlist : deps = [ d for d in config . envconfigs [ env ] . deps if force_unpinned not in d . name ] config . envconfigs [ env ] . deps = deps config . envconfigs [ env ] . commands . insert ( 0 , 'pip install datadog_checks_base[deps]' . split ( ) ) # Workaround for tox's `--force-dep` having limited functionality when package is already installed. # Primarily meant for pinning datadog-checks-base to a specific version, but could be # applied to other packages in the future. Since we typically install checks base via # editable mode, we need to force the reinstall to ensure that the PyPI package installs. force_install = os . getenv ( 'TOX_FORCE_INSTALL' , None ) if force_install : command = f'pip install --force-reinstall {force_install}' . split ( ) for env in config . envlist : config . envconfigs [ env ] . commands . insert ( 0 , command )