pulumi / templates

Templates used by `pulumi new`
Apache License 2.0
100 stars 66 forks source link

Python: Add IDE workspace settings that have the Python interpreter path preconfigured #147

Open justinvp opened 3 years ago

justinvp commented 3 years ago

We should consider adding IDE workspace settings files to our Python templates that have the path to the Python interpreter inside the virtual environment already configured.

For VS Code, this would be a .vscode/settings.json file that looks like:

{
    "python.pythonPath": "${workspaceFolder}/venv/bin/python"
}

This way, users won't have to manually select the interpreter path in VS Code to get the nice intellisense features.

As a bonus, for VS Code, we should also consider including a .vscode/extensions.json file, with recommended extensions for the project (e.g. the Python extension and Pylance).

Need to look into whether there are equivalent settings files we could include for PyCharm.

One minor hiccup is if you specify -g (--generate-only) to pulumi new, a virtual environment is not created, and there's currently no way to conditionally avoid emitting template files, so the files would be emitted configured to use a venv directory that doesn't exist. But I suspect it'd still be a net improvement to include these files, so that the default experience is better when using these two popular IDEs out-of-the-box. Users who aren't using the default virtual environment support or are using other IDEs can simply delete or ignore these files.

infin8x commented 3 years ago

Related to #179

justinvp commented 3 years ago

It looks like python.pythonPath is being deprecated.

https://github.com/microsoft/vscode-python/issues/12313 https://github.com/microsoft/vscode-python/wiki/AB-Experiments#pythondeprecatepythonpath

However, there is a read-only replacement python.defaultInterpreterPath setting that can be used:

{
    "python.defaultInterpreterPath": "${workspaceFolder}/venv/bin/python"
}