## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

Name:           python-openstep-plist
Version:        0.4.0
Release:        %autorelease
Summary:        ASCII plist parser written in Cython

# The entire source is MIT, except vendor/msinttypes/stdint.h, which is
# BSD-3-Clause, but which is removed in %%prep and does not contribute to the
# licenses of the binary RPMs.
License:        MIT
SourceLicense:  %{license} AND BSD-3-Clause
URL:            https://github.com/fonttools/openstep-plist
Source:         %{pypi_source openstep_plist}

# Add an empty [tool.setuptools_scm] section to pyproject.toml
# https://github.com/fonttools/openstep-plist/pull/30
#
# Fixes:
#
# KeyError: 'setuptools_scm' when building the package
# https://github.com/fonttools/openstep-plist/issues/29
#
# (Note that this was just a warning; the package builds without the patch.)
Patch:          %{url}/pull/30.patch

# Do not distribute Cython-generated C++ sources in binary wheels
# https://github.com/fonttools/openstep-plist/pull/31
Patch:          %{url}/pull/31.patch

# Remove unused pytest-cython test dependency
# https://github.com/fonttools/openstep-plist/pull/32
Patch:          %{url}/pull/32.patch

BuildSystem:            pyproject
BuildOption(install):   -l openstep_plist
BuildOption(generate_buildrequires): -t

BuildRequires:  python3-devel
BuildRequires:  gcc-c++

%global common_description %{expand:
A parser for the "old style" OpenStep property list format (also known as ASCII
plist), written in Cython.}

%description %{common_description}


%package -n python3-openstep-plist
Summary:        %{summary}

%description -n python3-openstep-plist %{common_description}


%prep
%autosetup -n openstep_plist-%{version}

# Remove Cythonized C++ sources:
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_using_cython
find . -type f -exec grep -FrinIl 'Generated by Cython' '{}' '+' |
  xargs -r -t rm -v

# This is not executable when installed in site-packages, so we remove the
# unnecessary shebang; python3 -m openstep_plist still works.
sed -r -i '1{/^#!/d}' src/openstep_plist/__main__.py

# Vendored header vendor/msinttypes/stdint.h has an allowed license but is only
# needed on Windows: prove that we do not use it by removing it.
rm -rv vendor/


%check -a
%tox -e %{default_toxenv}-nocov -- -- -v


%files -n python3-openstep-plist -f %{pyproject_files}
%doc README.md


%changelog
## START: Generated by rpmautospec
* Sat Dec 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.4.0-4
- Add a SourceLicense field

* Tue Dec 10 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.4.0-3
- F41+: Use the provisional pyproject declarative buildsystem

* Tue Dec 10 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.4.0-2
- Upstreamed pytest-cython test dependency removal

* Tue Dec 10 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.4.0-1
- Initial package (close RHBZ#2330988)
## END: Generated by rpmautospec