1
0

Accepting request 869694 from devel:languages:python:jupyter

OBS-URL: https://build.opensuse.org/request/show/869694
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/jupyter-imatlab?expand=0&rev=5
This commit is contained in:
Richard Brown 2021-03-30 18:59:05 +00:00 committed by Git OBS Bridge
commit 9f13af9a60
3 changed files with 87 additions and 7 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 3 23:26:54 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Fix wheel install path for new python-rpm-macros
- pyproject_install already recompiles, no need for second time
- Support testing (if you have MATLAB)
-------------------------------------------------------------------
Sat Dec 21 19:07:20 UTC 2019 - Bernhard Wiedemann <bwiedemann@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package jupyter-imatlab
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,7 +17,8 @@
%define pythons python3
%bcond_without test
# We can only test if the commercial MATLAB Engine API for Python is installed
%bcond_with test
Name: jupyter-imatlab
Version: 0.4
Release: 0
@ -26,6 +27,7 @@ License: MIT
Group: Development/Languages/Python
URL: https://github.com/imatlab/imatlab
Source0: https://files.pythonhosted.org/packages/py3/i/imatlab/imatlab-%{version}-py3-none-any.whl
Source1: https://raw.githubusercontent.com/imatlab/imatlab/master/test_imatlab.py
BuildRequires: fdupes
BuildRequires: jupyter-ipykernel >= 4.1
BuildRequires: jupyter-ipython >= 6
@ -34,6 +36,10 @@ BuildRequires: python-rpm-macros
BuildRequires: python3-pip
BuildRequires: python3-plotly
BuildRequires: unzip
%if %{with test}
BuildRequires: python3-curses
BuildRequires: python3-jupyter-kernel-test
%endif
Requires: jupyter-ipykernel >= 4.1
Requires: jupyter-ipython >= 6
Requires: jupyter-widgetsnbextension >= 1.0
@ -53,6 +59,7 @@ needs to be installed first.
%prep
%setup -q -T -c
cp %{SOURCE1} .
%build
# Make mock MATLAB engine to allow kernel installation.
@ -61,16 +68,21 @@ mkdir matlab
echo 'EngineError = MatlabExecutionError = Exception' > matlab/engine.py
%install
cp -a %{SOURCE0} .
%{python_expand mkdir build; cp -a %{SOURCE0} build/}
%pyproject_install
# avoid time-based .pyc files for reproducibility:
%py3_compile %{buildroot}%{python3_sitelib}
PYTHONPATH=%{buildroot}%{python3_sitelib} python3 -m imatlab install --prefix %{buildroot}%{_prefix}
cp %{buildroot}%{python3_sitelib}/imatlab-%{version}.dist-info/LICENSE.txt .
%fdupes %{buildroot}%{python3_sitelib}
%check
%if %{with test}
export JUPYTER_PATH=%{buildroot}%{_jupyter_prefix}
%pyunittest -v test_imatlab.py
%endif
%files
%license LICENSE.txt
%{python3_sitelib}/imatlab-%{version}.dist-info
%license %{python3_sitelib}/imatlab-%{version}.dist-info/LICENSE.txt
%{python3_sitelib}/imatlab/
%{_jupyter_kernel_dir}/imatlab/

61
test_imatlab.py Normal file
View File

@ -0,0 +1,61 @@
# import re
import jupyter_kernel_test as jkt
class IMatlabTests(jkt.KernelTests):
kernel_name = "imatlab"
language_name = "matlab"
file_extension = ".m"
code_hello_world = "fprintf('hello, world') % some comment"
code_stderr = "fprintf(2, 'oops')"
completion_samples = [
{"text": "matlabroo", "matches": ["matlabroot"]},
# Not including prefix (only `cursor_start:cursor_end`).
{"text": "ls setup.", "matches": ["setup.cfg", "setup.py"]},
]
complete_code_samples = [
"1+1",
"for i=1:3\ni\nend",
# FIXME The following should be considered "invalid", but really all
# that matters is that they are not "incomplete".
"function test_complete",
"function test_complete, end",
"classdef test_complete, end",
]
incomplete_code_samples = [
"for i=1:3",
# FIXME We'd rather consider this as "invalid".
"classdef test_complete",
]
invalid_code_samples = [
"for end",
]
code_display_data = [
{"code": "set(0, 'defaultfigurevisible', 'off'); "
"imatlab_export_fig('print-png'); "
"plot([1, 2]);",
"mime": "image/png"},
]
code_inspect_sample = "help"
# FIXME We actually never send "data" back -- only print it.
# code_generate_error = "[1, 2] + [3, 4, 5];"
# code_execute_result = [
# {"code": "1+1;", "result": ""},
# ]
# FIXME History operations are not tested as (as mentioned in the docs)
# they are unnecessary (re-implemented by the frontends, overly complex).
# supported_history_operations = ["tail", "range", "search"]
# code_history_pattern = [
# re.escape("1+1"),
# ]
# FIXME Not available.
# code_page_something = None
# code_clear_output = None