Skip to content

Commit f409344

Browse files
committed
When node-scraper runs as an entry point script, Python adds venv/bin (or venv\Scripts on Windows) to sys.path[0]
This breaks importlib.metadata.distributions() from discovering editable installs which results in xternal plugins from packages like amd-error-scraper weren't being found
1 parent 4493e17 commit f409344

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

nodescraper/cli/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ def discover_external_plugins():
124124
return extra_pkgs
125125

126126

127+
# Fix sys.path[0] if it's the venv/bin directory to avoid breaking editable install discovery
128+
_original_syspath0 = sys.path[0]
129+
if _original_syspath0.endswith("/bin") or _original_syspath0.endswith("\\Scripts"):
130+
sys.path[0] = ""
131+
127132
extra_pkgs = discover_external_plugins()
128133

134+
# Restore original sys.path[0]
135+
sys.path[0] = _original_syspath0
136+
129137

130138
def build_parser(
131139
plugin_reg: PluginRegistry,

0 commit comments

Comments
 (0)