pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

IntelliSense fails to detect editable installs after setuptools update

Open stur86 opened this issue 1 year ago • 5 comments

Type: Bug

Behaviour

Expected vs. Actual

IntelliSense should detect pip-installed packages even if the -e option was used to install them in editable mode. However, a few weeks ago, in order to comply with PEP 660 (see also https://github.com/pypa/setuptools/issues/3548 ), setuptools changed the way editable installs work, by introducing __editable__<pkg>_finder.py files in place of symlinks. This has made IntelliSense unable to detect them.

Steps to reproduce:

  1. Create a new clean environment
  2. Install a local package with pip install -e <path-to-pkg>
  3. Launch VSCode, pick the environment, and try to import the installed package

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): PipEnv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User Settings


languageServer: "Pylance"

Extension version: 2022.12.1 VS Code version: Code 1.70.2 (e4503b30fc78200f846c62cf8091b76ff5547662, 2022-08-16T05:35:13.448Z) OS version: Windows_NT x64 10.0.22000 Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.85GB (6.53GB free)
Process Argv --crash-reporter-id 76063c4e-ccc2-4582-a085-59632bf67ccf
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonvspyt551:30345470
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30557514
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
pylanb8912:30545647
vsclangdc:30486549
c4g48928:30535728
hb751961:30553087
dsvsc012:30540252
azure-dev_surveyone:30548225
i497e931:30553904

stur86 avatar Aug 31 '22 08:08 stur86

Any updates on this?

stur86 avatar Sep 07 '22 13:09 stur86

See this issue for additional details: https://github.com/microsoft/pyright/issues/3880.

erictraut avatar Sep 07 '22 13:09 erictraut

Yeah, there's a quick and dirty solution:

pip uninstall your_package
export SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
pip install -e your_package

huntzhan avatar Sep 08 '22 06:09 huntzhan

Thanks, that should do as a fix for the meantime! Any future plans/routes to actually solve this for good?

EDIT: it actually doesn't do as a fix for me; it still doesn't work.

stur86 avatar Sep 08 '22 13:09 stur86

@stur86, we're thinking about it. This is not going to be a quick fix.

debonte avatar Sep 08 '22 15:09 debonte

There has been discussion about ways to solve this problem. See this typing-sig thread. If a solution is found, agreed upon by typing-sig, and standardized, Pylance will consider supporting it.

However, for the time being this is by design since your editable install is using an import hook. There are more details including workarounds here.

debonte avatar Oct 13 '22 18:10 debonte