Fixed dotpath venv guessing

This commit is contained in:
Kamil Krzyśków
2025-07-23 22:04:07 +02:00
committed by Martin Donath
parent 88bdcf5f16
commit 6d4f756461
2 changed files with 20 additions and 18 deletions

View File

@@ -204,15 +204,16 @@ class InfoPlugin(BasePlugin[InfoConfig]):
# Guess other Virtual Environment paths in case we forget to activate # Guess other Virtual Environment paths in case we forget to activate
# them or in case we have multiple. Making sure which venv is activated # them or in case we have multiple. Making sure which venv is activated
# is not necessary, as it is an optional step in the guidelines. # is not necessary, as it is an optional step in the guidelines.
for path in glob.iglob( for abs_root, dirnames, filenames in os.walk(os.getcwd()):
pathname = "**/pyvenv.cfg", for filename in filenames:
root_dir = os.getcwd(), if filename.lower() != "pyvenv.cfg":
recursive = True continue
):
path = os.path.join(os.getcwd(), os.path.dirname(path)) path = abs_root[0].upper() + abs_root[1:]
if path not in site.PREFIXES:
print(f"Possible inactive venv: {path}") if path not in site.PREFIXES:
self.exclusion_patterns.append(_resolve_pattern(path)) print(f"Possible inactive venv: {path}")
self.exclusion_patterns.append(_resolve_pattern(path))
# Exclude site_dir for projects # Exclude site_dir for projects
if projects_plugin: if projects_plugin:

View File

@@ -204,15 +204,16 @@ class InfoPlugin(BasePlugin[InfoConfig]):
# Guess other Virtual Environment paths in case we forget to activate # Guess other Virtual Environment paths in case we forget to activate
# them or in case we have multiple. Making sure which venv is activated # them or in case we have multiple. Making sure which venv is activated
# is not necessary, as it is an optional step in the guidelines. # is not necessary, as it is an optional step in the guidelines.
for path in glob.iglob( for abs_root, dirnames, filenames in os.walk(os.getcwd()):
pathname = "**/pyvenv.cfg", for filename in filenames:
root_dir = os.getcwd(), if filename.lower() != "pyvenv.cfg":
recursive = True continue
):
path = os.path.join(os.getcwd(), os.path.dirname(path)) path = abs_root[0].upper() + abs_root[1:]
if path not in site.PREFIXES:
print(f"Possible inactive venv: {path}") if path not in site.PREFIXES:
self.exclusion_patterns.append(_resolve_pattern(path)) print(f"Possible inactive venv: {path}")
self.exclusion_patterns.append(_resolve_pattern(path))
# Exclude site_dir for projects # Exclude site_dir for projects
if projects_plugin: if projects_plugin: