File python-jupyterlab.spec of Package python-jupyterlab.18615

#
# spec file for package python-jupyterlab
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define         skip_python2 1
Name:           python-jupyterlab
Version:        2.2.10
Release:        0
Summary:        Environment for interactive and reproducible computing
License:        BSD-3-Clause
Group:          Development/Languages/Python
URL:            https://github.com/jupyterlab/jupyterlab
Source0:        https://github.com/jupyterlab/jupyterlab/archive/refs/tags/v%{version}.tar.gz#/jupyterlab-%{version}.tar.gz
# node_modules generated using yarn install locally. Last built in Leap 15.5
# zypper in python3-setuptools npm tar gzip
# npm install -g yarn
# cd jupyterlab-2.2.10
# yarn install
# python3 setup.py jsdeps
# tar czvf vendor.tar.gz node_modules/ jupyterlab/schemas jupyterlab/themes jupyterlab/static
Source1:        vendor.tar.gz
# PATCH-FIX-UPSTREAM CVE-2024-43805.patch gh#jupyterlab/jupyterlab@88e24baac551
Patch0:         CVE-2024-43805.patch
Source99:       python-jupyterlab-rpmlintrc
BuildRequires:  %{python_module base >= 3.5}
BuildRequires:  %{python_module jupyterlab-server >= 1.1.5}
BuildRequires:  %{python_module notebook >= 4.3.1}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module tornado}
BuildRequires:  fdupes
BuildRequires:  jupyter-jupyterlab-filesystem
BuildRequires:  nodejs >= 10
BuildRequires:  npm >= 10
BuildRequires:  python-rpm-macros
Requires:       jupyter-jupyterlab = %{version}
Requires:       python-Jinja2 >= 2.10
Requires:       python-base >= 3.5
Requires:       python-jupyter-core
Requires:       python-jupyterlab-server >= 1.1.5
Requires:       python-notebook >= 4.3.1
Requires:       python-tornado
Provides:       python-jupyter_jupyterlab = %{version}
Obsoletes:      python-jupyter_jupyterlab < %{version}
BuildArch:      noarch
# SECTION test requirements
BuildRequires:  %{python_module Jinja2 >= 2.10}
BuildRequires:  %{python_module pytest-check-links}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module requests}
# /SECTION
%python_subpackages

%description
An extensible environment for interactive and reproducible computing,
based on the Jupyter Notebook and Architecture.

JupyterLab is the next-generation user interface for Project Jupyter
offering all the familiar building blocks of the classic Jupyter
Notebook (notebook, terminal, text editor, file browser, rich outputs,
etc.). 

%package     -n jupyter-jupyterlab
Summary:        Environment for interactive and reproducible computing
Group:          Development/Languages/Python
Requires:       jupyter-jupyter-core
Requires:       jupyter-jupyterlab-filesystem
Requires:       jupyter-jupyterlab-server >= 1.0.0
Requires:       jupyter-notebook >= 4.3.1
Requires:       nodejs >= 10
Requires:       npm >= 10
Requires:       python3-jupyterlab = %{version}
Provides:       jupyter-jupyterlab-discovery = 6
Obsoletes:      jupyter-jupyterlab-discovery < 6

%description -n jupyter-jupyterlab
An extensible environment for interactive and reproducible computing,
based on the Jupyter Notebook and Architecture.

JupyterLab is the next-generation user interface for Project Jupyter
offering all the familiar building blocks of the classic Jupyter
Notebook (notebook, terminal, text editor, file browser, rich outputs,
etc.).

%prep
%autosetup -p1 -n jupyterlab-%{version} -a1
sed -i -e 's|^#!%{_bindir}/env node|#!%{_bindir}/node|' jupyterlab/staging/yarn.js
chmod a+x jupyterlab/staging/yarn.js

# find jupyterlab -name yarn.lock -delete
# find jupyterlab -name .yarnrc.yml -delete

%build
%python_build

%install
%python_install

mkdir -p %{buildroot}%{_jupyter_servextension_confdir}
mkdir -p %{buildroot}%{_jupyter_lab_dir}
cp -rf jupyter-config/jupyter_notebook_config.d/jupyterlab.json %{buildroot}%{_jupyter_servextension_confdir}

for i in themes static schemas
do
    cp -rf jupyterlab/$i %{buildroot}%{_jupyter_lab_dir}
    %python_expand cp -rf jupyterlab/$i %{buildroot}%{$python_sitelib}/jupyterlab/
done
%python_expand cp -rf jupyterlab/tests/mock_packages %{buildroot}%{$python_sitelib}/jupyterlab/tests/

%python_expand sed -i -e 's|^#!/usr/bin/env node|#!%{_bindir}/node|' %{buildroot}%{$python_sitelib}/jupyterlab/node-version-check.js
%python_expand sed -i -e 's|^#!/usr/bin/env node|#!%{_bindir}/node|' %{buildroot}%{$python_sitelib}/jupyterlab/staging/yarn.js
%python_expand chmod a+x %{buildroot}%{$python_sitelib}/jupyterlab/node-version-check.js
%python_expand chmod a+x %{buildroot}%{$python_sitelib}/jupyterlab/staging/yarn.js

%python_expand %fdupes %{buildroot}%{$python_sitelib}
%fdupes %{buildroot}%{_jupyter_prefix}

%check
export PYTHONDONTWRITEBYTECODE=1
# Disable build checks that pull in remote resources with npm
%{pytest jupyterlab -k \
    'not (test_build or test_clear or test_build_check or test_build_custom or test_uninstall_core_extension or test_install_and_uninstall_pinned or test_install_and_uninstall_pinned_folder or test_install_extension)'
}

%files %{python_files}
%{python_sitelib}/jupyterlab/
%{python_sitelib}/jupyterlab-%{version}*-info/

%files -n jupyter-jupyterlab
%license LICENSE
%{_bindir}/jlpm
%{_bindir}/jupyter-lab
%{_bindir}/jupyter-labextension
%{_bindir}/jupyter-labhub
%config %{_jupyter_servextension_confdir}/jupyterlab.json
%{_jupyter_lab_dir}

%changelog
openSUSE Build Service is sponsored by