Use base_prefix to detect virtual env#2566
Conversation
|
Is this not an issue with Spyder messing with the environment? |
|
IPython makes use of the VIRTUAL_ENV environment variable and Spyder wants to fool IPython. Maybe the fix should be at Spyder? |
@pijyoi Thanks for the pointer, that gives good information. I do not know whether we should fix this at the spyder or pyqtgraph side. I created spyder-ide/spyder#20273 to get input from the spyder devs. The PR here is simple, so if there are no downsides and there is no easy solution at the spyder side I would be in favor of this option. |
|
Hi @eendebakpt I'm ok merging this change, but I would request you add a comment with a link to the issue in spyder, so that future people maintaining the library don't have to scratch their heads as to why this change was made, and in turn can track if the other issue was ever fixed (and if it is fixed/addressed, when can this patch be removed from pyqtgraph). EDIT: btw thanks for creating the issue w/ the Spyder repo; hopefully there will be an explanation there, ccordoba12 (intentionally not tagging to minimize notification spam) is a friend of the project :) |
@j9ac9k No response on the spyder github issue yet, but I added links to the issues in the comments. |
Thanks, that's perfect! |
See the discussion in #1860.
Detect presence of a virtual enviroment using
sys.prefix != sys.base_prefix. This is more robust than a check on the environment variableVIRTUAL_ENV.Fixes #1052
@j9ac9k @pijyoi
A minimal example (using Windows):
python -c "import os; print(os.environ.get('VIRTUAL_ENV'))". The output shows the location of the virtualenvpip install spyder)spyder). In the Spyder console window runimport sys; print(sys.prefix). The output is the location of the virtual environment, which shows the console session in spyder is indeed running the virtual environment.import os; print(os.environ.get('VIRTUAL_ENV')). The output isNone. So the original check does not work in this caseimport sys; sys.prefix != sys.base_prefix. The output isTrueOther Tasks
Bump Dependency Versions
Files that need updates
Confirm the following files have been either updated or there has been a determination that no update is needed.
README.mdsetup.pytox.ini.github/workflows/main.ymland associatedrequirements.txtand condaenvironemt.ymlfilespyproject.tomlbinder/requirements.txtPre-Release Checklist
Pre Release Checklist
__init__.pyCHANGELOGprimarily using contents from automated changelog generation in GitHub release pagePost-Release Checklist
Steps To Complete
.dev0to__version__in__init__.py