Skip to content

Fix last one hardcoded unversioned python command #98

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

Merged
merged 3 commits into from
Jul 30, 2021

Conversation

frenzymadness
Copy link
Contributor

I'm sorry, it seems that I missed this one. I've prepared this PR in a browser so please test it before merging.

@frenzymadness
Copy link
Contributor Author

I'd like to debug the issue but I don't have an access to a machine with windows. But it seems that it cannot handle the full path to executable. It might make sense to omit the call to which if the first part of the command is an absolute path.

@afshin
Copy link
Member

afshin commented Jun 28, 2021

It might make sense to omit the call to which if the first part of the command is an absolute path.

This sounds reasonable 👍

@frenzymadness
Copy link
Contributor Author

I might try to implement it but I don't have a windows machine to test it.

@frenzymadness
Copy link
Contributor Author

Implemented in the last commit.

@afshin
Copy link
Member

afshin commented Jul 20, 2021

It looks like the path fix needs to be on sys.executable itself. You shouldn't need any changes to setupbase.py if you make only these changes:

diff --git a/tests/test_utility_functions.py b/tests/test_utility_functions.py
index 334c085..ea8127e 100644
--- a/tests/test_utility_functions.py
+++ b/tests/test_utility_functions.py
@@ -1,4 +1,5 @@
-
+import os
+import sys
 from unittest.mock import patch
 import pytest

@@ -28,7 +29,8 @@ def test_combine_commands():


 def test_run():
-    assert pkg.run('python --version') == 0
+    python = sys.executable.replace(os.sep, '/')
+    assert pkg.run(f'{python} --version') == 0

     with pytest.raises(ValueError):
         pkg.run('foobarbaz')

@frenzymadness
Copy link
Contributor Author

It looks like the path fix needs to be on sys.executable itself. You shouldn't need any changes to setupbase.py if you make only these changes:

But I still don't know why should I change the path separators from Windows to Linux. I'd say that windows paths should work on windows.

@afshin
Copy link
Member

afshin commented Jul 21, 2021

In this case the limitation is shutil.which not handling the Windows path, part of the standard library. Windows support is best-effort, since none of the core devs are Windows users.

@vidartf
Copy link
Collaborator

vidartf commented Jul 30, 2021

Windows support is best-effort, since none of the core devs are Windows users.

👋

I added a commit to the PR to resolve the issue: It was using shlex.split which seems to need a posix=False on Windows to not bork windows paths.

NB: Another solution would have been to pass [sys.executable, "--version"] instead of passing a string.

@blink1073 blink1073 added the bug label Jul 30, 2021
@blink1073 blink1073 merged commit 7433827 into jupyter:master Jul 30, 2021
@blink1073
Copy link
Contributor

Thanks @frenzymadness and @vidartf!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants