fix(perplexity-sidecar): auto-updater must respect requirements.txt pin
The previous loop ran 'pip install --upgrade perplexity-webui-scraper'
with no version constraint, so it walked past the requirements.txt pin
and pulled whatever PyPI shipped as latest. That is what dragged the
sidecar from 0.7.0 onto the 1.0.x API break (issue #212).
Changes:
* Read the version specifier for perplexity-webui-scraper from the
requirements.txt that lives next to app.py at startup. Parse handles
PEP 503 name normalisation, '#' comments, ';' env markers, '-e'
editables, and bare names. Falls back to a hard-coded mirror of the
repo pin when the file is missing or malformed.
* Pass the resulting pip spec ('perplexity-webui-scraper>=1.0.2,<2')
into the upgrade subprocess. pip itself enforces the constraint, so
a future 2.x release is a no-op rather than a silent breaking
upgrade.
* Drop _get_pypi_version() and the version-string equality check.
Compare _get_installed_version() before and after the pip call
instead; only restart when something actually changed. This also
avoids spurious restarts when PyPI publishes an out-of-pin release.
* importlib.invalidate_caches() between the upgrade and the
post-version read so the metadata loader sees freshly written
.dist-info files in the same process.
Verified: 12 edge cases for requirements.txt parsing pass (exact pin,
range pin, name normalisation, comments, env markers, missing file,
missing line, mixed deps). 'pip install --upgrade
"perplexity-webui-scraper>=1.0.2,<2"' against the installed 1.0.2 is
a no-op (rc=0, version unchanged), so the loop will not restart in a
tight cycle. I
itsmylife44 committed
abba67f68cc2ea0ba98edecbe02f876daf5f99e4
Parent: 5e50b59