-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
env.unset method #12357
env.unset method #12357
Conversation
Is there any existing tests for environment objects? |
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.
I'd really like to see a unittest for this (the new "testcase" clause should be pretty helpful).
I'm wondering what happens in this case:
env = EnvironmentVariables()
env.set('foo', 'bar')
env.unset('foo')
env.set('foo', 'foo')
Which I would expect to be set foo="foo"
, but looking at your implementation I think would make foo
unset.
I would expect either for foo="foo"
or for an error to be raised about trying to modify an env variable that is unset.
Not sure how I could use
I think my implementation is ok. Whether you modify a variable with |
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.
Dang, I didn't realize that they couldn't be inspected like a dict or configuration_data
. This looks like a good solution though, thanks!
I agree with the original concern that this seems weird. In fact, it generally seems weird, though I could see someone wanting to set a variable and then append additional contents to it. But I don't see any use case for unsetting a variable and then appending to it causing meson to revert to the original value of the variable plus whatever you append. It feels very much like mutually contradictory high-level goals. |
I changed that usecase for an error.
|
rebased, and retargeted for 1.4.0 |
@eli-schwartz Was there anything missing? I think I addressed your comments. |
@eli-schwartz @dcbaker I think all concerns were addressed. Is there anything missing for merging this? |
In my mind setting and unsetting the same variable is a logical error or at least problematic. It is confusing to have I'd personally make this a hard error, but other people might have different opinions. |
Well, it's already a hard error since the function doesn't exist. :) Adding the ability to unset a variable does indeed result in the confusing situation you pointed out. I noted above that it "feels weird" to me. |
I appreciate you addressing my concerns. Well, most of them. ;) I still feel somewhat uncomfortable about the whole feature. If others believe this is worth having I don't feel so uncomfortable about it that I'm going to stand in their way if they want to merge it, but I'd rather not make the decision to merge it myself. The important thing to me is that you've addressed my concerns about:
Which as you said above has been addressed. |
@jpakkane I modified it to prevent setting an unset variable, and vice-versa. |
This PR broke SciPy's dev builds on Windows. It appears that:
A
I think, but am not 100% sure, that this is a regression. Please let me know if you consider this a regression, and I can open a new bug report with more details and hopefully a clean/simple reproducer. |
self.unset_vars is created inside |
Agreed, it's not obvious to me either.
Looks like it. This is the only command that has is described with COMMAND = env PYTHONPATH=/Users/rgommers/code/bldscipy/scipy/_build_utils /Users/rgommers/mambaforge/envs/scipy-dev-newcompilers/bin/python3.11 ../scipy/linalg/_generate_pyx.py -o scipy/linalg
description = Generating$ scipy/linalg/cython_linalg$ with$ a$ custom$ command$ (wrapped$ by$ meson$ to$ set$ env) I don't actually see how |
On Linux, Windows doesn't support POSIX and therefore doesn't have |
Ah of course, thank you. It seems like the original bug report isn't cleanly reproducible after a
that's needed to trigger this. Or somehow mixing two build environments that ended up picking up the wrong |
Right, we don't support that. Only bugfix releases are binary-compatible. However often we can detect this and bail out, whereas the exe pickler uses a very minimal set of imports to ensure that builds are fast. |
That last sentence was very helpful context, thanks @eli-schwartz. Now I understand why we never hit this kind of issue before - we only recently started using |
My usecase is that I'm running from an active Python venv, and I need to perform some function calls inside different python venv, but the
VIRTUAL_ENV
environment variable interferes. Therefore, I need to unset it in the environment I use to perform the function call.