-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Use local environment variables and Add option to import PYTHONPATH #16429
Conversation
86a7e4e
to
e249c8c
Compare
d0ce19c
to
605a990
Compare
3c2f8c0
to
3b94bfb
Compare
Hello @mrclary! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-02-20 02:43:07 UTC |
I need to check the behavior of running scripts in external terminals; see #16200 |
13aebe1
to
0f86dd5
Compare
@mrclary, I disagree with most on this PR. Unless you revert almost all changes and focus on the ones related to our PYTHNONPATH manager, I won't accept it, sorry
I didn't understand how this is achieved very well. But if it involves grabbing We need to add a way for users to be aware we're doing that, so they can enable/disable it if they want. Also, this could introduce odd crashes, so it should be opt-in, not opt-out.
We absolutely don't want that. Passing
That's already working fine: So, in my opinion, the only thing that's necessary is adding the
We don't want and don't need that. Each of those external processes works differently and there's no need to uniformize things for the sake of correctness. |
Of course, these additions are nice and I agree with including them. |
This is already done for Spyder launched from the command line but not done for macOS standalone application. This PR only makes the standalone application behave the same as launching from commandline, i.e. Spyder's internal spyder/plugins/ipythonconsole/utils/kernelspec.py (126-130) def env(self):
"""Env vars for kernels"""
default_interpreter = self.get_conf(
'default', section='main_interpreter')
env_vars = os.environ.copy() If you want this to be an opt in option, then we would have to change the existing behavior.
I agree that we do not want to pass
For launching from conda, yes, the IPython console had both the user's system
I don't understand your objection here. Of course we want them to be the same. We want the completion paths in the Editor (via I actually think this PR does exactly what you would like, but maybe there is some confusion as to what was happening before and what I'm proposing to change. We should chat over zoom if we need to have a deeper conversation. |
6367399
to
e218610
Compare
WarningThe following comments are extensive; if you are looking for tl;dr, this isn't it 😁 . Because the issues are quite tedious to describe, and there has already been some misunderstanding, I make no apology for the verbosity. My goal is to explain as clearly as possible what this PR actually does and why. I've tried to be concise but thorough. Clarifying the IssuesThere are four main issues addressed by this PR
Note that there is also an inconsistency in completions behavior between the bootstrap and traditional conda launching methods. The following table summarizes the issues described by 2 - 4 above.
Analyzing CompletionsLet's analyze the behavior of the completions search paths. First note that completions search paths are controlled via different mechanisms for the IPython console and the Editor.
The Editor's Completion Paths
IPython Console's Completion Paths
Proposed SolutionIssue 1 above does not present any controversy and is resolved by a single commit in this PR. Issue 2 above does not present any controversy and is resolved by a single commit in this PR. Note that this is resolved by a change in the macOS app installer's Now, regarding issues 3 and 4 above. I don't think it is controversial to say that the search paths for completions should:
These can be accomplished by the following changes:
With the above changes, however, now that PPP is no longer (inadvertently) passed to Jedi, completions for the Editor and IPython console will be different. We must now exercise control over PPP being passed to IPython console.
However, there is the possible exception for "bootstrap + external". I believe the intention was to inject the local spyder-kernels path so that, under
Now that we've removed all the inadvertent injections of PPP, we need to address how to use PPP conveniently and transparently. Adding the "import" mechanism to the PYTHONPATH Manager does just that.
|
e218610
to
7a129aa
Compare
92c1619
to
8e79fc5
Compare
8e79fc5
to
c363b5f
Compare
c15ab9a
to
070016b
Compare
070016b
to
675eeb5
Compare
* Ensure that subprocess environments have minimum required environment variables
…ce, and can be removed.
… ('') * PyLS environment cannot contain PYTHONPATH for python language; this will produce incorrect completions. If env is empty, then PyLS will use os.environ by default, so we must assign it and remove PYTHONPATH. * For Windows, USERPROFILE will be included in os.environ, so no need to enforce it here.
* Fix typo for PYTHONHOME * Add PYTHONPATH to macOS external terminal execution
675eeb5
to
896a970
Compare
@ccordoba12 @andfoy any chance of moving forward on this soon? |
I'm demoting this PR in favor of #17502 and #17503. These two PRs should be uncontroversial. |
Ok, thanks for submitting those other PRs @mrclary! |
Description of Changes
The macOS application now imports the user's system environment variables into its
os.environ
so that they are passed to IPython consoles.The PYTHONPATH Manager now has a a button to import the PYTHONPATH from the user's system environment (
os.environ['PYTHONPATH']
). This is useful for all platforms that havePYTHONPATH
defined outside Spyder: either the Windows registry (Windows), or in the bash profile stack (Linux and macOS). This does not replace the functionality to export the PYTHONPATH Manager list to the Windows registry.The PYTHONPATH Manager widget is now enforced to be a single instance.
Completions through PyLS now honor the path list in PYTHONPATH Manager, which is what should be expected.
With this PR, the user now has complete control over the
PYTHONPATH
used for IPython consoles via the PYTHONPATH Manager with the convenience of importingPYTHONPATH
from the user's system environment variable. This PR harmonizes completions between the Editor and IPython console and across all launch mechanisms and platforms.Issue(s) Resolved
Fixes #14843
Fixes #14809
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct:
@mrclary
Comments
This is a better implementation of the basic idea in #14918. In the discussion of that PR, I had proposed the idea of creating an Environment Variables plugin. While this is still a good idea, I think that creating a new plugin will take more time and effort than I currently have and the basic functionality introduced in this PR is highly valuable to myself and colleagues. Therefore, I think this intermediate implementation is prudent.