#2613·mempalace

_strip_leaked_pythonpath_from_sys_path() 仍然会从分离的 venv 中删除 site-packages(第 2496 项保护仅涵盖解释器自身的 sysconfig 路径)

作者: GirottoAf创建于 2026年9月28日更新于 2026年9月28日

This is not exotic — it is the layout of Hermes' PM (package manager), which pins a standalone Python under ~/.hermes/tools/ and activates a managed environment directory by putting its site-packages on PYTHONPATH:

interpreter : <tools>/Python-3.14.7/bin/python3        # NOT the venv's Python
PYTHONPATH  : <installs>/<env>/venv/lib/python3.14/site-packages
sysconfig purelib: <tools>/Python-3.14.7/lib/python3.14/site-packages   # ≠ the venv
sys.executable                       -> <tools>/Python-3.14.7/bin/python3
sysconfig.get_paths()["purelib"]     -> <tools>/Python-3.14.7/lib/python3.14/site-packages
PYTHONPATH (the managed venv)        -> <installs>/<env>/venv/lib/python3.14/site-packages

<installs>/<env>/venv/lib/python3.14/site-packages is not in own_site_packages, so _belongs_to_this_environment() returns False and the guard removes it.

内容来源: MemPalace/mempalace