def enabled_actions_for_env(env):
    """Returns actions to perform when processing the given environment."""
    def enabled(config_value, required):
        if config_value is Config.TriBool.No:
            return False
        if config_value is Config.TriBool.Yes:
            return True
        assert config_value is Config.TriBool.IfNeeded
        return bool(required)

    # Some old Python versions do not support HTTPS downloads and therefore can
    # not download installation packages from PyPI. To run setuptools or pip
    # based installations on such Python versions, all the required
    # installation packages need to be downloaded locally first using a
    # compatible Python version (e.g. Python 2.4.4 for Python 2.4.3) and then
    # installed locally.
    download_supported = not ((2, 4, 3) <= env.sys_version_info < (2, 4, 4))

    local_install = config.installation_cache_folder() is not None

    actions = set()

    pip_required = False
    run_pip_based_installations = enabled(config.install_environments, True)
    if run_pip_based_installations:
        actions.add("run pip based installations")
        pip_required = True
    if download_supported and enabled(config.download_installations,
            local_install and run_pip_based_installations):
        actions.add("download pip based installations")
        pip_required = True

    setuptools_required = False
    run_pip_installation = enabled(config.install_environments, pip_required)
    if run_pip_installation:
        actions.add("run pip installation")
        setuptools_required = True
    if download_supported and enabled(config.download_installations,
            local_install and run_pip_installation):
        actions.add("download pip installation")
        setuptools_required = True

    if enabled(config.setup_setuptools, setuptools_required):
        actions.add("setup setuptools")

    return actions
def enabled_actions_for_env ( env ) : def enabled ( config_value , required ) : if config_value is Config . TriBool . No : return False if config_value is Config . TriBool . Yes : return True assert config_value is Config . TriBool . IfNeeded return bool ( required ) download_supported = not ( ( 2 , 4 , 3 ) <= env . sys_version_info < ( 2 , 4 , 4 ) ) local_install = config . installation_cache_folder ( ) is not None actions = set ( ) pip_required = False run_pip_based_installations = enabled ( config . install_environments , True ) if run_pip_based_installations : actions . add ( "run pip based installations" ) pip_required = True if download_supported and enabled ( config . download_installations , local_install and run_pip_based_installations ) : actions . add ( "download pip based installations" ) pip_required = True setuptools_required = False run_pip_installation = enabled ( config . install_environments , pip_required ) if run_pip_installation : actions . add ( "run pip installation" ) setuptools_required = True if download_supported and enabled ( config . download_installations , local_install and run_pip_installation ) : actions . add ( "download pip installation" ) setuptools_required = True if enabled ( config . setup_setuptools , setuptools_required ) : actions . add ( "setup setuptools" ) return actions
Returns actions to perform when processing the given environment.