Skip to content

Remove old code for folder support in interpreter path settings #12452

Closed

Description

@karrtikr

This check is done to ensure if entered interpreter path is valid, and if so, the path is returned. I don't see the point of these checks, as we shouldn't support entering interpreter paths this way.

Variable 'pythonPath' refers to the path user entered

const KnownPythonExecutables = ['python', 'python4', 'python3.6', 'python3.5', 'python3', 'python2.7', 'python2'];
for (let executableName of KnownPythonExecutables) {
// Suffix with 'python' for linux and 'osx', and 'python.exe' for 'windows'.
if (IS_WINDOWS) {
executableName = `${executableName}.exe`;
if (isValidPythonPath(path.join(pythonPath, executableName))) {
return path.join(pythonPath, executableName);
}
if (isValidPythonPath(path.join(pythonPath, 'scripts', executableName))) {
return path.join(pythonPath, 'scripts', executableName);
}
} else {
if (isValidPythonPath(path.join(pythonPath, executableName))) {
return path.join(pythonPath, executableName);
}
if (isValidPythonPath(path.join(pythonPath, 'bin', executableName))) {
return path.join(pythonPath, 'bin', executableName);
}
}
}
return pythonPath;

Also, the first check when ensuring if interpreter path is valid is we should be checking if the entered path exists, which we're not doing.
This leads to us launching 14 exec commands <python> -c '1234' everytime a user enters an invalid path - leading to extension consuming too much CPU.

cc Don Jayamanne (@DonJayamanne) Karthik Nadig (@karthiknadig)

Activity

  1. added
    bugIssue identified by VS Code Team member as probable bug
    triage-neededNeeds assignment to the proper sub-team
    on Jun 19, 2020
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jun 22, 2020
  3. DonJayamanne commented on Jun 23, 2020

    @DonJayamanne

    This was for portability.
    Users wanted to set the python path in their settings for all users in a team across multiple os.
    E.g. assume users have a relative path to a virtual env in their workspace .venv, that would work on Mac Linux and windows without any other change.

    Brett Cannon (@brettcannon) might recall this change bring added into the extension.

  4. karrtikr commented on Jun 23, 2020

    @karrtikr
    Author

    I see, Karthik Nadig (@karthiknadig) has observed that having these checks can wreck the SSH connection because of the 14 spawns made at worst case.
    Also, I don't see this documented anywhere, wonder how many users are using this feature. Maybe we should add telemetry before deciding to removing these, or maybe have this as an optional feature?

  5. brettcannon commented on Jun 23, 2020

    @brettcannon
    Member

    Thanks to removing python.pythonPath, I don't think this is necessary anymore and we should just expect people to specify the full path to their environment's Python interpreter.

  6. removed their assignment
    on Jun 23, 2020
  7. 12 remaining items

  8. added
    debtCode quality issues
    and removed
    bugIssue identified by VS Code Team member as probable bug
    on Nov 2, 2023
  9. karrtikr commented on Nov 2, 2023

    @karrtikr
    Author

    We now have folder support inbuilt in the new discovery code, the old code is no longer needed.

  10. karrtikr commented on Nov 2, 2023

    @karrtikr
    Author

    Verification steps:

    • Python: Select Interpreter -> Enter interpreter path -> Enter full path to the environment folder (for eg. full path to .venv folder, can even contain ~)
    • Ensure interpreter still gets selected
  11. changed the title [-]Add telemetry for folder support in interpreter path settings[/-] [+]Remove old code for folder support in interpreter path settings[/+] on Nov 2, 2023
  12. added
    bugIssue identified by VS Code Team member as probable bug
    on Nov 2, 2023
  13. locked as resolved and limited conversation to collaborators on Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugdebtCode quality issuesverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions