astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.8k stars 467 forks source link

Generate env file to be used in vscode #178

Open futurist opened 1 year ago

futurist commented 1 year ago

When using vscode with rye, vscode plugins like pylance don't know the rye tool, and lead to some problems analysis and autocomplete about python source code.

Maybe it's a way to export rye related env to file (like PYTHONPATH etc.) then vscode can reference this env in settings.json:

{
  "python.analysis.extraPaths": [
    "${workspaceRoot}/.venv/site-packages?"
  ],
  "python.envFile": "${workspaceRoot}/.env"
}

Maybe the sub-command can be named: rye env or sth?

mitsuhiko commented 1 year ago

Somehow my vscode picks up on .venv automatically. Not sure how I have accomplished this.

cnpryer commented 1 year ago

IIRC the Python extension will locate it.

asosnovsky-sumologic commented 1 year ago

So the default behavior in vscode does work for intellisense. I got it working as expected by specifying

{
    "python.defaultInterpreterPath": ".venv/bin/python",
    "python.autoComplete.extraPaths": [
        "${workspaceRoot}/.venv/lib/python3.10/site-packages",
    ],
}

maybe add this to the docs somewhere?