check_required_use, human_readable_required_use, match_from_list, \
_repo_separator
from portage.dep._slot_operator import ignore_built_slot_operator_deps
-from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
+from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use, \
+ _get_eapi_attrs
from portage.exception import (InvalidAtom, InvalidDependString,
PackageNotFound, PortageException)
from portage.output import colorize, create_color_func, \
darkgreen, green
bad = create_color_func("BAD")
-from portage.package.ebuild.config import _feature_flags
+from portage.package.ebuild.config import _get_feature_flags
from portage.package.ebuild.getmaskingstatus import \
_getmaskingstatus, _MaskReason
from portage._sets import SETPREFIX
in ("y", "auto"))
newuse = "--newuse" in self._frozen_config.myopts
changed_use = "changed-use" == self._frozen_config.myopts.get("--reinstall")
+ feature_flags = _get_feature_flags(
+ _get_eapi_attrs(pkg.metadata["EAPI"]))
if newuse or (binpkg_respect_use and not changed_use):
flags = set(orig_iuse.symmetric_difference(
cur_iuse).difference(forced_flags))
flags.update(orig_iuse.intersection(orig_use).symmetric_difference(
cur_iuse.intersection(cur_use)))
- flags.difference_update(_feature_flags)
+ flags.difference_update(feature_flags)
if flags:
return flags
elif changed_use or binpkg_respect_use:
flags = set(orig_iuse.intersection(orig_use).symmetric_difference(
cur_iuse.intersection(cur_use)))
- flags.difference_update(_feature_flags)
+ flags.difference_update(feature_flags)
if flags:
return flags
return None
for key in use_expand:
if key in self.use_expand_hidden:
continue
- self.verboseadd += _create_use_string(self.conf, key.upper(),
+ self.verboseadd += _create_use_string(pkg, self.conf, key.upper(),
cur_iuse_map[key], iuse_forced[key],
cur_use_map[key], old_iuse_map[key],
old_use_map[key], self.is_new,
from portage import os
from portage import _encodings, _unicode_encode
from portage._sets.base import InternalPackageSet
+from portage.eapi import _get_eapi_attrs
from portage.output import (blue, bold, colorize, create_color_func,
green, red, teal, turquoise, yellow)
bad = create_color_func("BAD")
-from portage.package.ebuild.config import _feature_flags
+from portage.package.ebuild.config import _get_feature_flags
from portage.util import shlex_split, writemsg
from portage.util.SlotObject import SlotObject
from portage.versions import catpkgsplit
mystr=mystr[:mycount]+","+mystr[mycount:]
return mystr+" kB"
-def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
+def _create_use_string(pkg, conf, name, cur_iuse, iuse_forced, cur_use,
old_iuse, old_use,
is_new, reinst_flags):
any_iuse = cur_iuse.union(old_iuse)
any_iuse = list(any_iuse)
any_iuse.sort()
+ feature_flags = _get_feature_flags(_get_eapi_attrs(pkg.metadata["EAPI"]))
for flag in any_iuse:
flag_str = None
isEnabled = False
elif flag in old_use:
flag_str = green("-" + flag) + "*"
if flag_str:
- if flag in _feature_flags:
+ if flag in feature_flags:
flag_str = "{" + flag_str + "}"
elif flag in iuse_forced:
flag_str = "(" + flag_str + ")"
_eapi_attrs = collections.namedtuple('_eapi_attrs',
'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
- 'iuse_defaults iuse_effective '
+ 'feature_flag_test iuse_defaults iuse_effective '
'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
'src_uri_arrows strong_blocks use_deps use_dep_defaults')
dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
+ feature_flag_test = True,
iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)),
repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
if sys.hexversion >= 0x3000000:
basestring = str
-_feature_flags = frozenset(["test"])
+_feature_flags_cache = {}
+
+def _get_feature_flags(eapi_attrs):
+ cache_key = (eapi_attrs.feature_flag_test,)
+ flags = _feature_flags_cache.get(cache_key)
+ if flags is not None:
+ return flags
+
+ flags = []
+ if eapi_attrs.feature_flag_test:
+ flags.append("test")
+
+ flags = frozenset(flags)
+ _feature_flags_cache[cache_key] = flags
+ return flags
def autouse(myvartree, use_cache=1, mysettings=None):
warnings.warn("portage.autouse() is deprecated",