Use sys.executable for the fuzzywuzzy auto-install fallback - #445
Open
ethando1984 wants to merge 1 commit into
Open
Use sys.executable for the fuzzywuzzy auto-install fallback#445ethando1984 wants to merge 1 commit into
ethando1984 wants to merge 1 commit into
Conversation
The ImportError fallback shelled out to a hardcoded `pip3`, which resolves to whatever pip is first on PATH rather than the interpreter running XSStrike. Inside a virtualenv this installed into the wrong environment, and on externally-managed installs (Homebrew, Debian) it failed outright with externally-managed-environment. Use `sys.executable -m pip` so the install always targets the running interpreter, and pass an argument list via subprocess.call so paths containing spaces aren't word-split by the shell. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
fuzzywuzzyImportError fallback inxsstrike.pyshells out to a hardcodedpip3:pip3resolves to whatever pip happens to be first onPATH, which is not necessarily the interpreter running XSStrike. That produces two failure modes:Inside a virtualenv —
pip3may resolve outside the venv, so the package installs into a different environment. XSStrike then prints "fuzzywuzzy has been installed, restart XSStrike", but the next run fails the import again, in a loop.On externally-managed installs (Homebrew, Debian/Ubuntu per PEP 668) — the install aborts outright:
The user sees a pip error with no obvious connection to XSStrike. This is likely related to the recurring "I installed the dependencies but it still says fuzzywuzzy isn't installed" reports, and is why the bug report template has to ask whether
pip3was used.Fix
sys.executable -m pipalways targets the interpreter actually running the script, which is the standard recommendation for programmatic pip invocation.Passing an argument list via
subprocess.callinstead of a shell string also avoids word-splitting — this matters becausesys.executablecontains spaces on macOS framework builds:import osis dropped since it existed only for theos.systemcall andosis unused elsewhere in the file.sysis imported at module level further down, but that is below thistryblock, so the local import inside the handler is still needed.Testing
Exercised the fallback path rather than only reading it — created a venv with
tldandrequestsbut deliberately withoutfuzzywuzzy, then ran XSStrike under it:fuzzywuzzyinto that venvBefore the change, the same scenario on Homebrew Python failed with
externally-managed-environment.No behavior change when
fuzzywuzzyis already present. Return-code handling is unchanged (subprocess.callreturns the exit status, same as the existingret_code != 0check expects).🤖 Generated with Claude Code