You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pylance by default assumes that your entire source tree is visible to every python file, which may not be true in production. Integration of build systems and pylance may be out of scrobe, but perhaps this request will introduce functionality that would enable a build system aware extension to do the right thing.
If you are using the Bazel build system for each python build target it will create a directory that looks like the declared runtime environment. Specifically, it creates symlinks to all of the files declared as build dependencies. You can use vscode to test if the built python program using a launch.json file like:
If there was a way to tell pylance to use a relative path like the one specified as the PYTHONPATH above as the root directory import lookup it would really amazing.
Just to check if this is different than #275, does this work as expected if you use MPLS (languageServer set to Microsoft), which does support PYTHONPATH?
From a user perspective it would be having the ability to specify an extraPath with variable substitution, such as "bazel-bin/${relativeFileDirname}/${fileBasenameNoExtension}.runfiles/main", and disable other search paths other than the python environment search paths. I imagine that would be hard to handle efficiently on the language server side.
We also have this issue where I work. If full support of the variable expansion in python.analysis.extraPaths isn't feasible, supporting * and **glob wildcards would be workable, since we could do something like this in our settings and get working import resolutions:
Activity
jakebailey commentedon Oct 12, 2020
Just to check if this is different than #275, does this work as expected if you use MPLS (languageServer set to Microsoft), which does support PYTHONPATH?
onet-git commentedon Oct 12, 2020
I have not be able to get feature from MPLS, which is not to say it is not possible.
I do not believe supporting
.envfiles is not sufficient because there is a unique directory per input file. According to the documentation MPLS only supports environment variable substitution in environment files, not vscode variable substitution. https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-fileFrom a user perspective it would be having the ability to specify an extraPath with variable substitution, such as "bazel-bin/${relativeFileDirname}/${fileBasenameNoExtension}.runfiles/main", and disable other search paths other than the python environment search paths. I imagine that would be hard to handle efficiently on the language server side.
AlexanderOtavka commentedon Mar 25, 2022
We also have this issue where I work. If full support of the variable expansion in
python.analysis.extraPathsisn't feasible, supporting*and**glob wildcards would be workable, since we could do something like this in our settings and get working import resolutions:This is assuming that extraPaths is able to correctly follow symlinks.
judej commentedon Jun 13, 2022
Moving this issue to discussion as an enhancement request for comments and upvotes.