proj/portage:master commit in: lib/portage/dep/, man/

"Matt Turner" <[email protected]>
Newsgroups gmane.linux.gentoo.cvs
Message-ID <1785963928.e983b5ea9add519432487733edb6dd468a4bfea1.mattst88@gentoo>
commit:     e983b5ea9add519432487733edb6dd468a4bfea1
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  2 14:10:57 2026 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Aug  5 21:05:28 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e983b5ea

dep: add a PORTAGE_NATIVE_DEP_PARSER kill switch

The native C parser and the pure-Python path are meant to be
indistinguishable.  Provide an escape hatch so that can be verified, and
so a user who does hit a defect in the C parser has a way to keep
working while it is fixed.

Setting PORTAGE_NATIVE_DEP_PARSER=0 in the environment forces the
pure-Python path.  It is read once, when portage.dep is imported, which
happens long before make.conf is parsed -- so it is an environment
variable only, and is documented alongside the other Portage development
variables in emerge(1).

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 lib/portage/dep/__init__.py |  5 +++++
 man/emerge.1                | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 9dc2fc8ce..48b41849c 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -30,6 +30,7 @@ __all__ = [
     "use_reduce",
 ]
 
+import os
 import re
 import warnings
 from functools import lru_cache
@@ -59,6 +60,10 @@ try:
 except ImportError:
     _c_dep_parser = None
 
+# PORTAGE_NATIVE_DEP_PARSER=0 forces the pure-Python path.  See emerge(1).
+if os.environ.get("PORTAGE_NATIVE_DEP_PARSER") == "0":
+    _c_dep_parser = None
+
 if TYPE_CHECKING:
     from _emerge.Package import Package
 

diff --git a/man/emerge.1 b/man/emerge.1
index 00a015586..389caafde 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1509,6 +1509,17 @@ dependency resolution and fall back to the previous implementation.
 This variable is internal and experimental; it may be removed or changed
 in a future release.
 .TP
+.BR PORTAGE_NATIVE_DEP_PARSER
+If this environment variable is set to \fI0\fR, then Portage will not use
+the native C dependency\-string parser and will fall back to the
+pure\-Python implementation.  Both paths are expected to produce identical
+results; the variable exists to verify that, and to work around a defect in
+the native parser should one be found.  It is read once, when the
+\fBportage.dep\fR module is imported, so it must be set in the environment
+before Portage starts.
+This variable is internal and experimental; it may be removed or changed
+in a future release.
+.TP
 .BR PORTAGE_DO_NOT_EXPORT_PMS_VARS
 If this environment variable is set, then Portage will not export PMS
 variables regardless of the EAPI.  The variables are still available
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.