-
-
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: Fix issue getting user environment variables on Posix systems and pass them to the IPython console #21065
Conversation
… and interactive starup files. I think that proc.communicate is the only real source for errors, so I eliminated the outer-most try block. Added a timeout to proc.communicate to handle possible hangs (interactive input requests in startup files?)
Interactive startup files, e.g. ~/.bashrc, will not be sourced.
6a65f83
to
9c58cc6
Compare
…ython consoles). Do not need to get user variables for macOS app startup.
Create shell script on module import based on user's shell
9c58cc6
to
a7449d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mrclary for your work on this!
Note: This doesn't completely solve issue #3891 because that would require adding a tab to the IPython console preferences so that users can add env vars without editing their |
I suppose this is a UX issue and maybe we could discuss it more at one of our dev meetings. I see a few additional ideas:
|
Agreed. We need to solve that in another PR.
I like this idea. That way the env vars managed by us would be propagated to the LSP, IPython console and all other things we run in external processes. |
a986d6c
to
28bd07b
Compare
Co-authored-by: Carlos Cordoba <[email protected]>
28bd07b
to
5f0cec7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here @mrclary! I tested this locally and it's working as expected.
Description of Changes
To get user environment variables from login and interactive startup files on posix, both
-l
and-i
flags must be used. Parsing the environment list is problematic if the variable has a newline character, but Python'sos.environ
can do this for us. However, executing Python in an interactive shell in a subprocess causes Spyder to hang on Linux. Using a shell script resolves the issue. Note that-i
must be in the sha-bang line; if-i
and-l
are swapped, Spyder will hang.Also note that for environment variables for
KernelSpec
objects are first set to the user's environment variables, then updated withos.environ
. Thus user login and interactive variables are ensured to be present, but values inos.environ
may override user variable values.Issue(s) Resolved
Part of #3891
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: