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
{{ message }}
Repository navigation
pyvsc-run-isolated.py removes pip "editable" installations from sys.path, breaks pytest #14570
In #14014, pythonFiles/pyvsc-run-isolated.py script has been modified to remove all occurrences of cwd or '' from sys.path. Previously, this script just blindly replaced (and before that it removed) sys.path[0]. The purpose of #14014 was to handle situations in which cwd is not the first item in sys.path.
The unintended side effect of #14014 arises when a package residing in cwd is installed with pip install -e . (as an editable install). Such installation causes cwd to be added at the end of sys.path. In these situations, cwd exists twice in sys.path: first as '' and second as cwd. Removing both occurrences breaks everything that needs to import the package installed as editable.
In my case what is broken is running pytest tests from the GUI. Side note: why is pytest run using the isolate script?
We have marked this issue as "needs decision" to make sure we have a conversation about your issue. We plan to leave this request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.
Same her: running tests from GUI is broken on a package installed using 'setup.py develop'. Likely related, pylint is also broken, marking same package imports as not found.
Reacted by akukuq, David Laing, Ben Falk, Simon Keith, Kyle Gottfried, Randolph Busch and Jason Harrison
Sorry, I am still fairly new to python. What is the expected way for the target package to be installed locally when running pytest? From the pytest documentation it seems like installing pip install -e is suggested.
Not sure if this is related, but the latest extension (v2020.10.33229234) also breaks my tests. When running via GUI I get "Cannot read property 'testsuites' of null". Running pytest from command line works fine. Downgrading to previous extension restores normal operation of my tests.
Domen Jurkovic (@schperplata) If you can try the latest insiders build, it has a flag to turn off isolation. Please try that and let us know if it works for you. The setting is "python.useIsolation": false. This should be set in the User settings.
Thank you! I chose weekly insiders, added the setting: "python.useIsolation": false and that fixed it for me!
Thanks for vscode+python! And thanks for your volunteer work on this open source project. ❤️
I tried the insiders build with the insiders version of python extensions, and turned off isolation, but I believe my editable pip install still was removed from python path when running tests from the GUI. because they still fail with the same message even tho they are discovered and work in debug mode:
ImportError while loading conftest 'c:\Users\mikm\Projects\pvlib-python\pvlib\tests\conftest.py'.
pvlib\tests\conftest.py:10: in <module>
import pvlib
E ModuleNotFoundError: No module named 'pvlib'
Error: TypeError: Cannot read property 'testsuites' of null
I opened #15398 before I found this issue, but I don't know if they're duplicates or not. I apologize for creating redundancy, and I'm happy to close it if it is. Thanks!
This error has returned for me on pylint 2.7.2, using the weekly dev extension, and turning off isolation. I'm getting the "no name in module" problem report on my imports for editable installs.
pylint 2.7.2
astroid 2.5.1
Python 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 18:42:56)
[Clang 10.0.1 ]
TLDR my test passes collectively but fails when run individually
In my case there is no '' or cwd in sys.path to begin with when I run an individual test (pyvsc-run-isolated.py). But when I add sys.path.append(os.getcwd()) my tests passes individually.
Can someone shed some light if this is the same issue or different?
RE: my comment above the issue was in pvlib-python, tests was not a package and had a conftest.py file that used imported into tests relatively. Resolved in pvlib/pvlib-python#1204
What is the status with this issue? Use of a global user setting (python.useIsolation) is quite unfortunate in this scenario - it should be a workspace setting since some other workspace might have a different requirements. ATM, I am the maintainer of a couple of projects that have VSC workspaces and they all have its own venv and are used as packages - what I assume is a correct approach, without any hacks. But yet, we still need to use exact very old extension version since otherwise running (not debugging) does not work. Seems to me like other use cases are covered, but this one is not.
Brett Cannon (@brettcannon) I must confess I don't quite understand this. Can you please provide a bit more info?
Bottom line: are we stuck with this old version OR do I have to prepare instructions for everyone that use any of our VSC workspaces, to set theri python.useIsolation? I must be missing something very obvious if I am the only one with this issue!
Domen Jurkovic (@schperplata) we're waiting on a feature from VS Code which we hope will become available in the next couple of releases/months, at which point we can drop the setting.
Reacted by Domen Jurkovic, Kyle Gottfried and Eric Gorohoff
TLDR my test passes collectively but fails when run individually
In my case there is no '' or cwd in sys.path to begin with when I run an individual test (pyvsc-run-isolated.py). But when I add sys.path.append(os.getcwd()) my tests passes individually.
Can someone shed some light if this is the same issue or different?
I take my words back. I looked again and indeed the cwd path was there and this script is removing it.
I am going to use a symlink and modify .pth and .egg-link files to workaround it for now. Hoping this will be fixed in future.
Activity
karthiknadig commentedon Oct 29, 2020
We have marked this issue as "needs decision" to make sure we have a conversation about your issue. We plan to leave this request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.
evilmav commentedon Oct 29, 2020
Same her: running tests from GUI is broken on a package installed using 'setup.py develop'. Likely related, pylint is also broken, marking same package imports as not found.
ryannk commentedon Oct 29, 2020
Sorry, I am still fairly new to python. What is the expected way for the target package to be installed locally when running pytest? From the pytest documentation it seems like installing
pip install -eis suggested.eric-mj commentedon Oct 29, 2020
Not sure if this is related, but the latest extension (v2020.10.33229234) also breaks my tests. When running via GUI I get "Cannot read property 'testsuites' of null". Running pytest from command line works fine. Downgrading to previous extension restores normal operation of my tests.
karthiknadig commentedon Oct 30, 2020
@emj1991 That is an unrelated issue. Please file a separate bug.
mrdavidlaing commentedon Oct 31, 2020
For me;
pytestandpylintwere finding finding modules using thePYTHONPATH=.setting in my${workspaceFolder}/.envfile. (as suggested here)The behaviour introduced in #14014 that removes $(cwd) from
sys.pathbreaks this setting; causing both to fail.21 remaining items
arnaudlimbourg commentedon Feb 2, 2021
fixed it for me too!
akukuq commentedon Feb 2, 2021
The insiders build
v2021.2.531887795-devworks for me too.mikofski commentedon Feb 23, 2021
Thanks for vscode+python! And thanks for your volunteer work on this open source project. ❤️
I tried the insiders build with the insiders version of python extensions, and turned off isolation, but I believe my editable pip install still was removed from python path when running tests from the GUI. because they still fail with the same message even tho they are discovered and work in debug mode:
I opened #15398 before I found this issue, but I don't know if they're duplicates or not. I apologize for creating redundancy, and I'm happy to close it if it is. Thanks!
falkben commentedon Mar 4, 2021
This error has returned for me on pylint 2.7.2, using the weekly dev extension, and turning off isolation. I'm getting the "no name in module" problem report on my imports for editable installs.
ashrauma commentedon Mar 31, 2021
TLDR my test passes collectively but fails when run individually
In my case there is no '' or cwd in sys.path to begin with when I run an individual test (pyvsc-run-isolated.py). But when I add
sys.path.append(os.getcwd())my tests passes individually.Can someone shed some light if this is the same issue or different?
brettcannon commentedon Mar 31, 2021
ashrauma it might be, but without more info it's hard to tell. Please open a new issue and fill out the bug report template.
mikofski commentedon Mar 31, 2021
RE: my comment above the issue was in pvlib-python,
testswas not a package and had aconftest.pyfile that used imported into tests relatively. Resolved in pvlib/pvlib-python#1204vscode: disable python isolation
schperplata commentedon Apr 20, 2021
What is the status with this issue? Use of a global user setting (
python.useIsolation) is quite unfortunate in this scenario - it should be a workspace setting since some other workspace might have a different requirements. ATM, I am the maintainer of a couple of projects that have VSC workspaces and they all have its own venv and are used as packages - what I assume is a correct approach, without any hacks. But yet, we still need to use exact very old extension version since otherwise running (not debugging) does not work. Seems to me like other use cases are covered, but this one is not.Brett Cannon (@brettcannon) I must confess I don't quite understand this. Can you please provide a bit more info?
Bottom line: are we stuck with this old version OR do I have to prepare instructions for everyone that use any of our VSC workspaces, to set theri
python.useIsolation? I must be missing something very obvious if I am the only one with this issue!brettcannon commentedon Apr 20, 2021
Domen Jurkovic (@schperplata) we're waiting on a feature from VS Code which we hope will become available in the next couple of releases/months, at which point we can drop the setting.
ashrauma commentedon Apr 21, 2021
I take my words back. I looked again and indeed the cwd path was there and this script is removing it.
I am going to use a symlink and modify .pth and .egg-link files to workaround it for now. Hoping this will be fixed in future.
karrtikr commentedon May 19, 2021
FYI we're planning to remove isolation script with #16274 so this can be closed.