1
0

Accepting request 931041 from home:schubi2

- 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
This commit is contained in:
Benjamin Greiner 2021-11-12 18:08:29 +00:00 committed by Git OBS Bridge
parent 6c1894ce91
commit 7d38550062
3 changed files with 56 additions and 3 deletions

43
argv0_subcommand.patch Normal file
View File

@ -0,0 +1,43 @@
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

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Nov 12 08:25:01 UTC 2021 - Stefan Schubert <schubi@suse.de>
- 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.
-------------------------------------------------------------------
Thu Oct 28 19:16:16 UTC 2021 - Ben Greiner <code@bnavigator.de>

View File

@ -1,5 +1,5 @@
#
# spec file
# spec file for package python-jupyter-core
#
# Copyright (c) 2021 SUSE LLC
#
@ -17,8 +17,7 @@
#
%bcond_with libalternatives_issue_11_fixed
%if 0%{?suse_version} > 1500 && %{with libalternatives_issue_11_fixed}
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
@ -43,6 +42,8 @@ URL: https://github.com/jupyter/jupyter_core
Source0: https://files.pythonhosted.org/packages/source/j/jupyter_core/jupyter_core-%{version}.tar.gz
# PATCH-FIX-OPENSUSE -- use_rpms_paths.patch -- change paths so they are easy to replace at build time
Patch0: use_rpms_paths.patch
# argv0_subcommand.patch can be removed with releasing version > 4.9.1
Patch1: argv0_subcommand.patch
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module traitlets}
BuildRequires: fdupes
@ -86,6 +87,7 @@ as a dependency by packages that require it.
%prep
%setup -q -n jupyter_core-%{version}
%patch0 -p1
%patch1 -p1
# Set the appropriate hardcoded paths dynamically
sed -i "s|\"_datadir_jupyter_\"|\"%{_datadir}/jupyter\"|" jupyter_core/paths.py
sed -i "s|\"_sysconfdir_jupyter_\"|\"%{_sysconfdir}/jupyter\"|" jupyter_core/paths.py