Skip to content

Conversation

@atrskv
Copy link

@atrskv atrskv commented Aug 21, 2025

Problem

The current implementation works fine with absolute paths, as described in the README.md, but does not support relative paths such as .venv/bin/python

For example, running:

which python

returns:

/Users/yourname/projects/my-project/.venv/bin/python

While this absolute path works, it includes the project-specific folder name, meaning you need to update settings.json every time you switch projects

You can use a relative path like:

{
  "pythonFuncRunner.pythonPath": ".venv/bin/python"
}

And it works: when we tap the Run button, it executes the command:

".venv/bin/python" -m pytest -rpP tests/...

However, debugging fails because the debugger does not resolve relative paths against the workspace folder

Proposed solution

Introduced a new utility function resolvePythonPath which checks if the provided path is absolute. If the path is relative, resolves it against the workspace folder to produce an absolute path:

function resolvePythonPath(configPath: string, uri: vscode.Uri): string {
  if (path.isAbsolute(configPath)) return configPath;

  const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
  if (!workspaceFolder) return configPath;

  return path.join(workspaceFolder.uri.fsPath, configPath);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant