-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Nushell activation scripts #2170
Conversation
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## main #2170 +/- ##
==========================================
- Coverage 93.55% 93.55% -0.01%
==========================================
Files 87 88 +1
Lines 4361 4373 +12
==========================================
+ Hits 4080 4091 +11
- Misses 281 282 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
For this to get accepted you'll need to setup the test suite for it, as per other shells do, see https://github.com/pypa/virtualenv/blob/main/tests/unit/activation/test_batch.py
thanks @gaborbernat for pointing me to that script. I see that I would need to set up in the CI an instance of nushell as well to test it. Is that correct? |
Yes, you're correct. I'd also like to mention that condition of accepting this PR is:
If either of those is true now or in the future we'll remove it from the core, and encourage you to instead provide it as a plugin. |
@gaborbernat I was wondering if you could help me understand something. When asserting this line I get this value I've looked everywhere but dont understand where that is specified in the unit tests. In the logs I see that the files are copied to the correct location. Can you help me out? |
Those match up with these https://github.com/pypa/virtualenv/blob/main/tests/unit/activation/conftest.py#L123-L135. So what you see there is that post-activation we still get the original path and not the virtual environment one. |
@gaborbernat thanks. That was useful. However, I'm having trouble understanding why the output from this line
has to be
|
To support paths with Unicode characters. What you see in the line above is a sign of garbled coding by the shell (meaning your activator might work for ASCII paths only), but will not for Unicode ones (notably when users have Unicode char in their name, and they work in their home folder). |
@gaborbernat sorry, I copied that string from the terminal and it got jumbled. That is not my problem now. It seems that because Im testing my changes in a virtual environment the test is not overriding the VIRTUAL_ENV from the test, that's why one file is pointing to the venv in my shell and the other is pointing to the venv from the test. Is it possible to monkeypatch the variable for the test? |
I don't think that's the case, because then why would this not happen for
the other shells 😬
…On Thu, 19 Aug 2021, 11:49 Fernando Herrera, ***@***.***> wrote:
@gaborbernat <https://github.com/gaborbernat> sorry, I copied that string
from the terminal and it got jumbled. That is not my problem now. It seems
that because Im testing my changes in a virtual environment the test is not
overriding the VIRTUAL_ENV from the test, that's why one file is pointing
to the venv in my shell and the other is pointing to the venv from the test.
Is it possible to monkeypatch the variable for the test?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2170 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFIQPUCUD5SQLGE3A2MO73T5TOUZANCNFSM5CHO26UQ>
.
|
you are right. I'm running the powershell test and I dont get that error. This is really weird. |
Ok. I think I found the issue. The problem is that when nushell sources that file, it changes the env variables (PATH) only for its scope and because the test is looking outside nushell's scope, then it finds the previous env variable. I need to figure out how to maintain nushell's scope during the test |
@gaborbernat again, more questions. I have been testing the script that is run in the test, which is
and it runs perfectly in nushell and even inside a python shell using Popen
which is what the test expect however, when running the test, in this line the result we get is this:
which obviously shows that the new env is not loaded. So, this leads me to the next question, do you remember if there is an special configuration that I need to set for the |
If they are environment variables at play that must be specific to nu, and those I'm not aware of. 😬 Perhaps - someone who knows in detail how nu operates can help 🤔 |
We are so close. I really want to have this in nushell to start using it as my main shell |
I'm on a holiday now so unavailable for looking into this myself. But if you can figure out the CI, we can push it ahead. |
the problem is that the mac tests always fail because of that assertion. I dont know what to do about it |
It passes on main, see https://github.com/pypa/virtualenv/actions/runs/1200507280, so the reason must be with the code you're adding here 😊 |
PYTHONEXECUTABLE is not used by any of the other shell activation scripts, setting it directly will require this script to walk the path and determine the OS. We should not be setting it. This resolves test failures on macOS, since the previous version added the windows-specific `.exe` suffix.
I believe I have resolved the macOS test failures in elferherrera#1 |
Remove the PYTHONEXECUTABLE variable from nushell scripts
@gaborbernat thanks to @lily-mara we are passing all virtualenv tests. Do you mind approving the workflow? |
"__VIRTUAL_NAME__": creator.env_name, | ||
"__BIN_NAME__": ensure_text(str(creator.bin_dir.relative_to(creator.dest))), | ||
"__PATH_SEP__": ensure_text(os.pathsep), | ||
"__DEACTIVATE_PATH__": ensure_text(str(Path(dest_folder) / Path("deactivate.nu"))), |
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 don't think you need to wrap the deactivate.nu
in path 👍
def test_nushell(activation_tester_class, activation_tester): | ||
class Nushell(activation_tester_class): | ||
def __init__(self, session): | ||
cmd = "c:\\program files\\nu\\bin\\nu.exe" if IS_WIN else "nu" |
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.
This might work in the CI but will not work locally as well 👍 Better to use shutil.which
here and only fallback to this hard coded path if that returns None and we're on windows.
for more information, see https://pre-commit.ci
@elferherrera seems Python 2 does not like it 😟 |
@gaborbernat let me have a look. I was checking that I was getting an error with the lints |
Python 2 doesn't support shutil.which so you'd need to add a small backwards compatible method 🤔 |
@gaborbernat I think this time everything passes |
We should only use deprected API if we must. Signed-off-by: Bernát Gábor <[email protected]>
Hi all,
I'm including a brand new activation script for nushell. I think I've got the base structure but I was wondering if someone could help me set up some things.
activate.nu
file?