%global         commit          395418359ddcb5b8014b857115f7f6b2f147033c
%global         shortcommit     %(c=%{commit}; echo ${c:0:8})
%global         commitdate      20250106
%global         reponame        extensions
%global         srcname         inkex
%global         forgeurl        https://gitlab.com/inkscape/extensions
Version:        1.4.0^%{commitdate}git%{shortcommit}
%global         tag             v%{version}
%forgemeta

Name:           python-%{srcname}
Release:        1%{?dist}
Summary:        Python extensions for Inkscape core

License:        GPL-2.0-or-later
URL:            %forgeurl
Source:         %{url}/-/archive/%{commit}/%{reponame}-%{shortcommit}.tar.gz
BuildRequires:  python3-devel
# Tests
BuildRequires:  gtk3-devel
BuildRequires:  gzip
BuildRequires:  python3dist(pytest)
BuildRequires:  python3-gobject
BuildRequires:  python3-gobject-base
BuildRequires:  python3-gobject-base-noarch
BuildRequires:  python3-gobject-devel
BuildRequires:  which
BuildArch: noarch

%global _description %{expand:
This package supports Inkscape extensions.

It provides
- a simplification layer for SVG manipulation through lxml
- base classes for common types of Inkscape extensions
- simplified testing of those extensions
- a user interface library based on GTK3

At its core, Inkscape extensions take in a file, and output a file.
- For effect extensions, those two files are SVG files.
- For input extensions, the input file may be any arbitrary
  file and the output is an SVG.
- For output extensions, the input is an SVG file while the
  output is an arbitrary file.
- Some extensions (e.g. the extensions manager) don't manipulate files.

This folder also contains the stock Inkscape extensions, i.e. the scripts
that implement some commands that you can use from within Inkscape.
Most of these commands are in the Extensions menu, or in the Open /
Save dialogs.}

%description %_description

%package -n python3-%{srcname}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname} %_description


%prep
%autosetup -p1 -n %{reponame}-%{commit}
# Remove unneeded files
rm *.lock

rm tests/test_w*
rm tests/test_v*
rm tests/test_t*
rm tests/test_s*
rm tests/test_r*
rm tests/test_p*
rm tests/test_o*
rm tests/test_n*
rm tests/test_m*
rm tests/test_l*
rm tests/test_j*
rm tests/test_int*
rm tests/test_ins*
rm tests/test_inks*
rm tests/test_inkw*
rm tests/test_ink2*
rm tests/test_im*
rm tests/test_h*
rm tests/test_g*
rm tests/test_f*
rm tests/test_e*
rm tests/test_d*
rm tests/test_c*
rm tests/test_a*
rm tests/test_u*
rm tests/add_pylint.py

# Remove version limit from lxml
sed -i "s/lxml = .*/lxml = '\*'/" pyproject.toml
# Relax version limit for scour
sed -i 's/scour = "^0.37"/scour = ">=0.37"/' pyproject.toml
# Update version in configuration files
sed -i 's/cssselect = "^1.2.0"/cssselect = ">=1.1.0,<2.0.0"/' pyproject.toml
# Update python command
sed -i 's/call("python"/call("python3"/' tests/test_inkex_command.py
			     
%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files %{srcname}
# Executable fix
sed -i /env\ python/d %{buildroot}%{python3_sitelib}/inkex/tester/inx.py

%check
%pyproject_check_import
%pytest -k "not test_inkex_gui"

%files -n python3-%{srcname} -f %{pyproject_files}
%doc package-readme.md
%license LICENSE.txt
 
%changelog
* Sun Jan 19 2025 Benson Muite <fed500@fedoraproject.org> - 1.4.0^20250106git39541835-1
- Update to pre-release to ensure builds on Python 3.14

* Sat Jan 18 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-3.20241202git13ebc1e9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild

* Mon Dec 16 2024 Orion Poplawski <orion@nwra.com> - 1.4.0-2
- Update to latest git for numpy 2.0 support

* Sat Nov 30 2024 Benson Muite <benson_muite@emailplus.org> - 1.4.0-1
- Update to commit corresponding to Inkscape 1.4

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 1.3.1-2
- Rebuilt for Python 3.13

* Wed Apr 10 2024 Benson Muite <benson_muite@emailplus.org> - 1.3.1-1
- Update to latest release on Pypi

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 15 2024 Lumír Balhar <lbalhar@redhat.com> - 1.3.0-3
- Remove version limit from lxml

* Sun Dec 24 2023 Benson Muite <benson_muite@emailplus.org> - 1.3.0-2
- Enable building with Python 3.13

* Fri Sep 08 2023 Benson Muite <benson_muite@emailplus.org> - 1.3.0-1
- Initial package