File python-playwright.spec of Package python-playwright

#
# spec file for package python-playwright
#
# Copyright (c) 2024 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/
#


Name:           python-playwright
Version:        1.51.0
Release:        0
Summary:        A high-level API to automate web browsers
License:        Apache-2.0
URL:            https://github.com/Microsoft/playwright-python
Source0:        https://github.com/microsoft/playwright-python/archive/refs/tags/v%{version}.tar.gz
Source1:        https://playwright.azureedge.net/builds/driver/playwright-1.51.1-linux.zip
Source2:        playwright.target
BuildRequires:  %{python_module base >= 3.8}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module greenlet}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module pyee}
BuildRequires:  %{python_module setuptools_scm}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module wheel}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-greenlet
Requires:       python-pyee
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages

%description
A Python library to automate Chromium, Firefox and WebKit browsers with
a single API. Playwright is built to enable cross-browser web automation
that is ever-green, capable, reliable and fast.

%package -n %{name}-target
Summary:        Systemd target for %{name}

%description -n %{name}-target
Systemd target for services using playwright.

%pre -n %{name}-target
%service_add_pre playwright.target

%post -n %{name}-target
%service_add_post playwright.target

%preun -n %{name}-target
%service_del_preun playwright.target

%postun -n %{name}-target
%service_del_postun playwright.target


%prep
%autosetup -n playwright-python-%{version} -p1
mkdir driver
cp %{SOURCE1} driver/

%build
# needed to generate the correct package version
export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PLAYWRIGHT=%{version}
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%python_clone -a %{buildroot}%{_bindir}/playwright
install -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/playwright.target

%post
%python_install_alternative playwright

%postun
%python_uninstall_alternative playwright

%check
# basic check to verify that playwright is starting
%python_exec -m playwright -V

%files %{python_files}
%license LICENSE
%doc README.md
%python_alternative %{_bindir}/playwright
%{python_sitelib}/playwright*

%files -n %{name}-target
%{_unitdir}/playwright.target

%changelog
openSUSE Build Service is sponsored by