## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    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

# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond_with doc

Name:           python-chardet
Version:        5.2.0
Release:        %autorelease
Summary:        Python character encoding detector

# The entire source, after tests/ are filtered, is LGPL-2.0-or-later. See the
# comment above Source0 for more details on tests/.
License:        LGPL-2.0-or-later
URL:            https://github.com/chardet/chardet
# A filtered source tarball, obtained by (see Source1):
#
#   ./get_source %%{version}
#
# is required because the contents of tests/ are under various undocumented
# licenses and are, for the most part, not freely redistributable. See:
#
#   problematic licensing of /tests?
#   https://github.com/chardet/chardet/issues/231
Source0:        chardet-%{version}-filtered.tar.xz
Source1:        get_source
# Hand-written for Fedora in groff_man(7) format based on --help output
Source2:        chardetect.1

BuildArch:      noarch

BuildRequires:  python%{python3_pkgversion}-devel

%if %{with doc}
BuildRequires:  make
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx-rtd-theme
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
BuildRequires:  tex-xetex-bin
BuildRequires:  /usr/bin/xindy
%endif

%global common_description %{expand:
Chardet: The Universal Character Encoding Detector

Detects:

  • ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
  • Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified
    Chinese)
  • EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP (Japanese)
  • EUC-KR, ISO-2022-KR, Johab (Korean)
  • KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
  • ISO-8859-5, windows-1251 (Bulgarian)
  • ISO-8859-1, windows-1252 (Western European languages)
  • ISO-8859-7, windows-1253 (Greek)
  • ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
  • TIS-620 (Thai)

ISO-8859-2 and windows-1250 (Hungarian) probers have been temporarily
disabled.}

%description
%{common_description}


%package -n python%{python3_pkgversion}-chardet
Summary:        %{summary}

%description -n python%{python3_pkgversion}-chardet
%{common_description}


%package        doc
Summary:        Documentation for python-chardet

%description    doc
%{common_description}


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

# Since pdflatex cannot handle Unicode inputs in general:
echo "latex_engine = 'xelatex'" >> docs/conf.py

%if 0%{?rhel} >= 9
%generate_buildrequires
%pyproject_buildrequires
%endif

%build
%pyproject_wheel

%if %{with doc}
PYTHONPATH="${PWD}" %make_build -C docs latex \
    SPHINXOPTS='-j%{?_smp_build_ncpus}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif


%install
%pyproject_install
%pyproject_save_files chardet
install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 '%{SOURCE2}'
mv %{buildroot}%{_bindir}/chardetect %{buildroot}%{_bindir}/chardetect-%{python3_pkgversion}
mv %{buildroot}%{_mandir}/man1/chardetect.1 %{buildroot}%{_mandir}/man1/chardetect-%{python3_pkgversion}.1


%check
# We cannot run the upstream tests because they would require data files with
# problematic license status.
%pyproject_check_import


%files -n python%{python3_pkgversion}-chardet -f %{pyproject_files}
%if %{without doc}
%doc README.rst
%endif
%{_bindir}/chardetect-%{python3_pkgversion}
%{_mandir}/man1/chardetect-%{python3_pkgversion}.1*


%if %{with doc}
%files doc
%license LICENSE
%doc README.rst
%doc docs/_build/latex/chardet.pdf
%endif


%changelog
* Wed Aug 02 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 5.2.0-1
- Update to 5.2.0 (close RHBZ#2228250)

* Wed Aug 02 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 5.1.0-5
- When PDF docs are disabled, omit the -doc subpackage

* Wed Aug 02 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 5.1.0-4
- Use new (rpm 4.17.1+) bcond style

* Wed Aug 02 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 5.1.0-3
- Don’t assume %%_smp_mflags is -j%%_smp_build_ncpus

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Dec 01 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 5.1.0-1
- Update to 5.1.0 (close RHBZ#2150154)

* Fri Oct 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 5.0.0-3
- Update License to SPDX

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 5.0.0-1
- Update to 5.0.0 (close RHBZ#2101067)

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-19
- Fix get_source_script

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-18
- Drop test data with problematic license status

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-17
- BR python3dist(hypothesis) to enable more tests

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-16
- Package Sphinx-generated PDF in a -doc subpackage

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-15
- Drop explicit pyproject-rpm-macros BR

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-14
- Update summary and description from upstream

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-13
- Add a man page for the chardetect command

* Sat Jun 25 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-12
- Correct License from LGPLv2 to LGPLv2+

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 4.0.0-7
- Rebuilt for Python 3.11

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 4.0.0-6
- Bootstrap for Python 3.11

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed Jun 02 2021 Python Maint <python-maint@redhat.com> - 4.0.0-3
- Rebuilt for Python 3.10

* Wed Jun 02 2021 Python Maint <python-maint@redhat.com> - 4.0.0-2
- Bootstrap for Python 3.10

* Fri Feb 05 2021 Miro Hrončok <mhroncok@redhat.com> - 4.0.0-1
- Update to 4.0.0
- Fixes: rhbz#1906585
- Fixes: rhbz#1923076

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Fri May 22 2020 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-17
- Rebuilt for Python 3.9

* Fri May 22 2020 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-16
- Bootstrap for Python 3.9

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Nov 14 2019 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-14
- Subpackage python2-chardet has been removed
  See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-13
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Thu Aug 15 2019 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-12
- Rebuilt for Python 3.8

* Wed Aug 14 2019 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-11
- Bootstrap for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Aug 17 2018 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-8
- Only have one /usr/bin/chardetect

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Jun 13 2018 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-6
- Rebuilt for Python 3.7

* Sun Feb 11 2018 Iryna Shcherbina <ishcherb@redhat.com> - 3.0.4-5
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 3.0.4-3
- Python 2 binary package renamed to python2-chardet
  See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Tue Jun 20 2017 Jeremy Cline <jeremy@jcline.org> - 3.0.4-1
- Update to 3.0.4 (#1441436)

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Dec 09 2016 Charalampos Stratakis <cstratak@redhat.com> - 2.3.0-2
- Rebuild for Python 3.6

* Wed Jul 27 2016 Miro Hrončok <mhroncok@redhat.com> - 2.3.0-1
- Update to 2.3.0 (#1150536)

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-6
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Oct 14 2015 Robert Kuska <rkuska@redhat.com> - 2.2.1-4
- Rebuilt for Python3.5 rebuild

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Thu Jul 31 2014 Tom Callaway <spot@fedoraproject.org> - 2.2.1-2
- fix license handling

* Wed Jul 02 2014 Miro Hrončok <mhroncok@redhat.com> - 2.2.1-1
- Updated to 2.2.1
- Introduced Python 3 subpackage (upstream has merged the codebase)
- Removed BuildRoot and python_sitelib definition
- Use python2 macros instead of just python

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 2.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Wed Jan 13 2010 Kushal Das <kushal@fedoraproject.org> 2.0.1-1
- New release

* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Mon Aug 04 2008 Kushal Das <kushal@fedoraproject.org> 1.0.1-1
- Initial release


