commit:     a134f37a6f38bc334d8050a5978a7ef3f2f5eda8
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Dec 12 20:44:59 2023 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Fri Nov 21 23:56:20 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=a134f37a

refactor: move const.incrementals into profiles.

The incrementals list is basically for profile data, even
if portage_conf and domain was written otherwise.  Thus
move the list into profiles (out of const); this is in
preparation for eventually refactoring the incremental
configuration processing from portage_conf and domain into
a profile subclass so the logic is contained all there.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/const.py        | 15 ---------------
 src/pkgcore/ebuild/domain.py       |  7 ++++---
 src/pkgcore/ebuild/portage_conf.py |  2 +-
 src/pkgcore/ebuild/profiles.py     | 31 +++++++++++++++++++++++--------
 tests/ebuild/test_profiles.py      |  6 +++---
 5 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/src/pkgcore/ebuild/const.py b/src/pkgcore/ebuild/const.py
index 86618c5f..3cf6d1fd 100644
--- a/src/pkgcore/ebuild/const.py
+++ b/src/pkgcore/ebuild/const.py
@@ -6,21 +6,6 @@ from snakeoil.osutils import pjoin
 
 from ..const import EBD_PATH
 
-incrementals = (
-    "ACCEPT_KEYWORDS",
-    "ACCEPT_LICENSE",
-    "CONFIG_PROTECT",
-    "CONFIG_PROTECT_MASK",
-    "FEATURES",
-    "IUSE_IMPLICIT",
-    "PROFILE_ONLY_VARIABLES",
-    "USE",
-    "USE_EXPAND",
-    "USE_EXPAND_HIDDEN",
-    "USE_EXPAND_IMPLICIT",
-    "USE_EXPAND_UNPREFIXED",
-    "ENV_UNSET",
-)
 
 incrementals_unfinalized = ("USE",)
 

diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index c7ca74b9..9c1dfb65 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -42,6 +42,7 @@ from ..restrictions import packages, values
 from ..restrictions.delegated import delegate
 from ..util.parserestrict import ParseError, parse_match
 from . import const
+from .profiles import INCREMENTALS
 from . import repository as ebuild_repo
 from .atom import atom as _atom
 from .eapi import get_latest_PMS_eapi
@@ -319,7 +320,7 @@ class domain(config_domain):
 
         # reformat env.d and make.conf incrementals
         system_profile_settings = {}
-        for x in const.incrementals:
+        for x in INCREMENTALS:
             system_profile_val = self.system_profile.get(x, ())
             make_conf_val = settings.get(x, ())
             if isinstance(system_profile_val, str):
@@ -336,11 +337,11 @@ class domain(config_domain):
             if k not in settings:
                 settings[k] = v
                 continue
-            if k in const.incrementals:
+            if k in INCREMENTALS:
                 settings[k] = system_profile_settings[k] + v + settings[k]
 
         # next we finalize incrementals.
-        for incremental in const.incrementals:
+        for incremental in INCREMENTALS:
             # Skip USE/ACCEPT_LICENSE for the time being; hack; we need the
             # negations currently so that pkg iuse induced enablings can be
             # disabled by negations. For example, think of the profile doing

diff --git a/src/pkgcore/ebuild/portage_conf.py 
b/src/pkgcore/ebuild/portage_conf.py
index 44286fb4..f8937600 100644
--- a/src/pkgcore/ebuild/portage_conf.py
+++ b/src/pkgcore/ebuild/portage_conf.py
@@ -308,7 +308,7 @@ class PortageConfig(DictMixin):
                 return
 
             if incrementals:
-                for key in econst.incrementals:
+                for key in profiles.INCREMENTALS:
                     if key in vars_dict and key in new_vars:
                         new_vars[key] = f"{vars_dict[key]} {new_vars[key]}"
             # quirk of read_bash_dict; it returns only what was mutated.

diff --git a/src/pkgcore/ebuild/profiles.py b/src/pkgcore/ebuild/profiles.py
index fea1eacc..4d875acb 100644
--- a/src/pkgcore/ebuild/profiles.py
+++ b/src/pkgcore/ebuild/profiles.py
@@ -29,6 +29,21 @@ from . import misc, repo_objs
 from .atom import atom
 from .eapi import EAPI, get_eapi
 
+INCREMENTALS = (
+    "ACCEPT_KEYWORDS",
+    "ACCEPT_LICENSE",
+    "CONFIG_PROTECT",
+    "CONFIG_PROTECT_MASK",
+    "FEATURES",
+    "IUSE_IMPLICIT",
+    "PROFILE_ONLY_VARIABLES",
+    "USE",
+    "USE_EXPAND",
+    "USE_EXPAND_HIDDEN",
+    "USE_EXPAND_IMPLICIT",
+    "USE_EXPAND_UNPREFIXED",
+    "ENV_UNSET",
+)
 
 class ProfileError(errors.ParsingError):
     def __init__(self, path, filename, error):
@@ -157,7 +172,7 @@ def _load_and_invoke(
         ) from e
 
 
-_make_incrementals_dict = partial(misc.IncrementalsDict, const.incrementals)
+_make_incrementals_dict = partial(misc.IncrementalsDict, INCREMENTALS)
 _Packages = namedtuple("_Packages", ("system", "profile"))
 
 
@@ -703,7 +718,7 @@ class ProfileStack:
     @klass.jit_attr
     def default_env(self):
         d = dict(self.node.default_env.items())
-        for incremental in const.incrementals:
+        for incremental in INCREMENTALS:
             v = d.pop(incremental, "").split()
             if v:
                 if incremental in const.incrementals_unfinalized:
@@ -718,14 +733,14 @@ class ProfileStack:
 
     @property
     def profile_only_variables(self):
-        if "PROFILE_ONLY_VARIABLES" in const.incrementals:
+        if "PROFILE_ONLY_VARIABLES" in INCREMENTALS:
             return frozenset(self.default_env.get("PROFILE_ONLY_VARIABLES", 
()))
         return frozenset(self.default_env.get("PROFILE_ONLY_VARIABLES", 
"").split())
 
     @klass.jit_attr
     def use_expand(self):
         """USE_EXPAND variables defined by the profile."""
-        if "USE_EXPAND" in const.incrementals:
+        if "USE_EXPAND" in INCREMENTALS:
             return frozenset(self.default_env.get("USE_EXPAND", ()))
         return frozenset(self.default_env.get("USE_EXPAND", "").split())
 
@@ -750,25 +765,25 @@ class ProfileStack:
 
     @property
     def use_expand_hidden(self):
-        if "USE_EXPAND_HIDDEN" in const.incrementals:
+        if "USE_EXPAND_HIDDEN" in INCREMENTALS:
             return frozenset(self.default_env.get("USE_EXPAND_HIDDEN", ()))
         return frozenset(self.default_env.get("USE_EXPAND_HIDDEN", "").split())
 
     @property
     def iuse_implicit(self):
-        if "IUSE_IMPLICIT" in const.incrementals:
+        if "IUSE_IMPLICIT" in INCREMENTALS:
             return frozenset(self.default_env.get("IUSE_IMPLICIT", ()))
         return frozenset(self.default_env.get("IUSE_IMPLICIT", "").split())
 
     @property
     def use_expand_implicit(self):
-        if "USE_EXPAND_IMPLICIT" in const.incrementals:
+        if "USE_EXPAND_IMPLICIT" in INCREMENTALS:
             return frozenset(self.default_env.get("USE_EXPAND_IMPLICIT", ()))
         return frozenset(self.default_env.get("USE_EXPAND_IMPLICIT", 
"").split())
 
     @property
     def use_expand_unprefixed(self):
-        if "USE_EXPAND_UNPREFIXED" in const.incrementals:
+        if "USE_EXPAND_UNPREFIXED" in INCREMENTALS:
             return frozenset(self.default_env.get("USE_EXPAND_UNPREFIXED", ()))
         return frozenset(self.default_env.get("USE_EXPAND_UNPREFIXED", 
"").split())
 

diff --git a/tests/ebuild/test_profiles.py b/tests/ebuild/test_profiles.py
index 4e61d3e6..74e2d7e3 100644
--- a/tests/ebuild/test_profiles.py
+++ b/tests/ebuild/test_profiles.py
@@ -730,7 +730,7 @@ class TestPmsProfileNode(profile_mixin):
         assert self.klass(child).default_env == {"y": "narf", "x": "narf 
twice"}
 
     def test_default_env_incrementals(self, tmp_path):
-        assert "USE" in const.incrementals
+        assert "USE" in profiles.INCREMENTALS
         profile1 = tmp_path / self.profile
         (profile2 := profile1 / "sub").mkdir()
         (profile3 := profile2 / "sub").mkdir()
@@ -1645,8 +1645,8 @@ class TestOnDiskProfile(profile_mixin):
 
     def test_default_env(self, tmp_path):
         assert "USE" in const.incrementals_unfinalized
-        assert "USE" in const.incrementals
-        assert "USE_EXPAND" in const.incrementals
+        assert "USE" in profiles.INCREMENTALS
+        assert "USE_EXPAND" in profiles.INCREMENTALS
 
         # first, verify it behaves correctly for unfinalized incrementals.
         self.mk_profiles(tmp_path, {})

Reply via email to