Repository navigation
馃悰 fix(discovery): match relative interpreter paths with ".." - #158
Merged
Merged
Conversation
A relative spec that steps up a directory, such as ../venv/bin/python or ..\other\Scripts\python.exe, never matched. get_interpreter returned None and iter_interpreters yielded nothing, even though the file exists and was interrogated. virtualenv hands -p straight to get_interpreter, so virtualenv -p ../venv/bin/python could not find the interpreter either. _check_exe proposed the candidate as Path(path).absolute(), which drops "." parts but keeps "..", while PythonInfo._satisfies_path compares the executable with os.path.abspath(spec.path), which collapses them. The two strings never agreed, and neither the is_abs shortcut nor the basename fallback applies to a relative path. The proposer used os.path.abspath before the standalone rewrite in tox-dev#28, and the existing relative-path test only used a path below the cwd. _check_exe now returns os.path.abspath(path) again, so the proposed executable is spelled the way the comparison expects. try_first_with entries are already resolved and absolute specs are accepted on is_abs, so for them the only change is that an absolute spec with ".." reports a normalized executable.
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.

A relative interpreter path that steps up a directory, such as
../venv/bin/python, was found and queried, then rejected, soget_interpreterreturnedNoneanditer_interpretersyielded nothing. 馃悰virtualenv -p ../venv/bin/pythonfailed the same way, as did./../x,a/../b, and the Windows spellings with\or/. Once this merges those paths find their interpreter.Discovery proposes each candidate path, and the interpreter info then checks it against the spec. The two spelled the same file differently: the proposer kept
..in the absolute path, while the check collapsed it, so the comparison never matched. The proposer collapses..again, as it did before #28 rewrote it. Normalizing on the comparison side instead would also match, but the returnedexecutablewould keep the... A base interpreter'sexecutablewould then stop equaling itssystem_executable, which costs an extra lookup and caches the..spelling.An absolute spec that contains
..already matched; the only visible change for it is that the returnedexecutableis now normalized.