From 5c9dec329ed9c8b6dcec9f4fc158789711f40561f5769d102f085f3fe1345a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Fri, 5 Feb 2021 09:21:35 +0000 Subject: [PATCH] Accepting request 869049 from home:bnavigator:branches:devel:languages:python:jupyter - Fix wheel install path for new python-rpm-macros - pyproject_install already recompiles, no need for second time - Support testing (if you have MATLAB) OBS-URL: https://build.opensuse.org/request/show/869049 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:jupyter/jupyter-imatlab?expand=0&rev=11 --- jupyter-imatlab.changes | 7 +++++ jupyter-imatlab.spec | 26 +++++++++++++----- test_imatlab.py | 61 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 test_imatlab.py diff --git a/jupyter-imatlab.changes b/jupyter-imatlab.changes index bb2ee01..452dbd8 100644 --- a/jupyter-imatlab.changes +++ b/jupyter-imatlab.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Feb 3 23:26:54 UTC 2021 - Ben Greiner + +- 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 diff --git a/jupyter-imatlab.spec b/jupyter-imatlab.spec index 70b2207..b47e974 100644 --- a/jupyter-imatlab.spec +++ b/jupyter-imatlab.spec @@ -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/ diff --git a/test_imatlab.py b/test_imatlab.py new file mode 100644 index 0000000..34757ed --- /dev/null +++ b/test_imatlab.py @@ -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