%global _empty_manifest_terminate_build 0
%global pypi_name ipywidgets

Name:           python-%{pypi_name}
Version:        8.1.1
Release:        1
Summary:        IPython HTML widgets for Jupyter

License:        BSD-3-Clause
URL:            https://github.com/jupyter-widgets/ipywidgets
Source0:        %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
Source1:        lab-info
Patch1:         0001-modify-the-operator-of-version-required-to-gt.patch
BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-pbr
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
BuildRequires:  python3-hatchling

#for test
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-cov
BuildRequires:  python3-traitlets
BuildRequires:  python3-jsonschema
BuildRequires:  python3-ipython
BuildRequires:  python3-ipykernel
BuildRequires:  python3-comm
BuildRequires:  python3-pytz

%description
Interactive HTML widgets for Jupyter notebooks and the IPython kernel.

%package -n     python3-%{pypi_name}
Summary:        %{summary}

%description -n python3-%{pypi_name}
Interactive HTML widgets for Jupyter notebooks and the IPython kernel.

%package -n     python3-widgetsnbextension
Summary:        Jupyter interactive widgets for Jupyter Notebook.
BuildRequires:  python3-jupyter-packaging

%description -n python3-widgetsnbextension
This package makes Jupyter widgets available in the classic Jupyter Notebook. 

%package -n     python3-jupyterlab-widgets
Summary:        Jupyter interactive widgets for JupyterLab.
BuildRequires:  python3-tomlkit
BuildRequires:  python3-deprecation

%description -n python3-jupyterlab-widgets
A JupyterLab 3.0 extension for Jupyter/IPython widgets.

%prep
%autosetup -p1 -n %{pypi_name}-%{version}
tar xzvf %{SOURCE1} -C ./python/jupyterlab_widgets/

%build
mkdir build
cd %{_builddir}/ipywidgets-8.1.1/python/widgetsnbextension
%pyproject_build
cp ./build/*.whl %{_builddir}/ipywidgets-8.1.1/build/
cd %{_builddir}/ipywidgets-8.1.1/python/jupyterlab_widgets
%pyproject_build
cp ./build/*.whl %{_builddir}/ipywidgets-8.1.1/build/
cd %{_builddir}/ipywidgets-8.1.1/python/ipywidgets
%pyproject_build
cp ./build/*.whl %{_builddir}/ipywidgets-8.1.1/build/

%install
%pyproject_install

%check
cd %{_builddir}/ipywidgets-8.1.1/python/ipywidgets
%pytest

%files -n python3-%{pypi_name}
%license ./python/ipywidgets/LICENSE
%doc ./python/ipywidgets/README.md
%{python3_sitelib}/ipywidgets-*.dist-info/
%{python3_sitelib}/ipywidgets/

%files -n python3-widgetsnbextension
%license ./python/widgetsnbextension/LICENSE
%doc ./python/widgetsnbextension/README.md
%{python3_sitelib}/widgetsnbextension-*.dist-info/
%{python3_sitelib}/widgetsnbextension/
%{_usr}/etc/jupyter/nbconfig/notebook.d/widgetsnbextension.json

%files -n python3-jupyterlab-widgets
%license ./python/jupyterlab_widgets/LICENSE
%doc ./python/jupyterlab_widgets/README.md
%{python3_sitelib}/jupyterlab_widgets-*.dist-info/
%{python3_sitelib}/jupyterlab_widgets/
%{_datadir}/jupyter/labextensions/

%changelog
* Mon Sep 11 2023 Dongxing Wang <dxwangk@isoftstone.com> - 8.1.1-1
- Init pacakage.
