forked from pool/python-jupyter-core
- Patch for solving gh#openSUSE/libalternatives#11: argv0_subcommand.patch This patch can be removed while releasing version >4.9.1. - Enabled using libalternatives again. OBS-URL: https://build.opensuse.org/request/show/931041 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:jupyter/python-jupyter-core?expand=0&rev=20
44 lines
1.6 KiB
Diff
44 lines
1.6 KiB
Diff
diff -Naur org/jupyter_core/command.py patch/jupyter_core/command.py
|
|
--- org/jupyter_core/command.py 2021-11-12 09:01:30.121064192 +0100
|
|
+++ patch/jupyter_core/command.py 2021-11-12 09:07:57.943564964 +0100
|
|
@@ -297,7 +297,7 @@
|
|
sys.exit(e)
|
|
|
|
try:
|
|
- _execvp(command, sys.argv[1:])
|
|
+ _execvp(command, [command] + sys.argv[2:])
|
|
except OSError as e:
|
|
sys.exit("Error executing Jupyter command %r: %s" % (subcommand, e))
|
|
|
|
diff -Naur org/jupyter_core/tests/test_command.py patch/jupyter_core/tests/test_command.py
|
|
--- org/jupyter_core/tests/test_command.py 2021-11-12 09:01:59.721265505 +0100
|
|
+++ patch/jupyter_core/tests/test_command.py 2021-11-12 09:09:21.832084810 +0100
|
|
@@ -192,3 +192,27 @@
|
|
env[str('PATHEXT')] = '.EXE'
|
|
out = check_output([sys.executable, str(jupyter), 'witness'], env=env)
|
|
assert b'WITNESS A' in out
|
|
+
|
|
+def test_argv0(tmpdir):
|
|
+ a = tmpdir.mkdir("a")
|
|
+ jupyter = a.join('jupyter')
|
|
+ jupyter.write(
|
|
+ 'from jupyter_core import command; command.main()'
|
|
+ )
|
|
+ jupyter.chmod(0o700)
|
|
+ witness_a = a.join('jupyter-witness')
|
|
+ witness_a_src = f'''#!{sys.executable}
|
|
+import sys
|
|
+print(sys.argv[0])
|
|
+'''
|
|
+ write_executable(witness_a, witness_a_src)
|
|
+
|
|
+ env = {}
|
|
+ if 'SYSTEMROOT' in os.environ: # Windows http://bugs.python.org/issue20614
|
|
+ env[str('SYSTEMROOT')] = os.environ['SYSTEMROOT']
|
|
+ if sys.platform == 'win32':
|
|
+ env[str('PATHEXT')] = '.EXE'
|
|
+ out = check_output([sys.executable, str(jupyter), 'witness'], env=env)
|
|
+
|
|
+ # Make sure the first argv is the full path to the executing script
|
|
+ assert f'{jupyter}-witness'.encode() in out
|