# Circular dependency on pytest %bcond_without tests # 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_without doc_pdf Name: python-chardet Version: 4.0.0 Release: %autorelease Summary: Python character encoding detector # The entire source is LGPLv2+, except: # # - tests/ascii/howto.diveintomark.org.xml is CC-BY-SA (but is not installed) # # See also: # clarify Trove license classifier # https://github.com/chardet/chardet/issues/162 # Clarify LGPL version in License trove classifier # https://github.com/chardet/chardet/pull/255 License: LGPLv2+ URL: https://github.com/chardet/chardet Source0: %{pypi_source chardet} # Hand-written for Fedora in groff_man(7) format based on --help output Source1: chardetect.1 BuildArch: noarch BuildRequires: python3-devel %if %{with tests} BuildRequires: python3-pytest %endif %if %{with doc_pdf} BuildRequires: make BuildRequires: python3dist(sphinx) BuildRequires: python3dist(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 python3-chardet Summary: %{summary} %description -n python3-chardet %{common_description} %package doc Summary: Documentation for python-chardet %description doc %{common_description} %prep %autosetup -p1 -n chardet-%{version} # Remove useless shebangs # https://github.com/chardet/chardet/commit/1e94b33329 grep -lr "^#\!/usr/bin/env python" chardet/ | xargs sed -i "1d" # Since pdflatex cannot handle Unicode inputs in general: echo "latex_engine = 'xelatex'" >> docs/conf.py %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %if %{with doc_pdf} PYTHONPATH="${PWD}" %make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}' %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 '%{SOURCE1}' %if %{with tests} %check %pytest -v %endif %files -n python3-chardet -f %{pyproject_files} %{_bindir}/chardetect %{_mandir}/man1/chardetect.1* %files doc %license LICENSE %doc README.rst %if %{with doc_pdf} %doc docs/_build/latex/chardet.pdf %endif %changelog %autochangelog