4627d04
# Sphinx-generated HTML documentation is not suitable for packaging; see
4627d04
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
4627d04
#
e4529f6
# We can generate PDF documentation as a substitute.
4627d04
%bcond_without doc_pdf
4627d04
4627d04
Name:           python-fastavro
ae9d147
Version:        1.6.1
0e8a4f9
Release:        %autorelease
4627d04
Summary:        Fast Avro for Python
4627d04
4627d04
# The fastavro project is licensed MIT, but is derived from Apache Avro which
4627d04
# is ASL 2.0; see LICENSE and also NOTICE.txt.
4627d04
#
4627d04
# The following source files are specifically known to include ASL 2.0 content:
4627d04
#
4627d04
#   • fastavro/_read_py.py
4627d04
#   • fastavro/_write_py.py
4627d04
#   • fastavro/_write.pyx
4627d04
#   • fastavro/_read.pyx
c182998
#
c182998
# SPDX:
c182998
License:        MIT AND Apache-2.0
4627d04
URL:            https://github.com/fastavro/fastavro
4627d04
Source0:        %{pypi_source fastavro}
0986900
7f95674
# Upstream does not test, nor support 32 bit systems
7f95674
# Issue: https://github.com/fastavro/fastavro/issues/526
7f95674
# Fedora bug: https://bugzilla.redhat.com/show_bug.cgi?id=1943932
4627d04
ExcludeArch:    %{arm32} %{ix86}
0986900
0986900
BuildRequires:  python3-devel
8f92897
BuildRequires:  %{py3_dist Cython}
4627d04
BuildRequires:  gcc
4627d04
4627d04
BuildRequires:  make
b4bc552
BuildRequires:  %{py3_dist sphinx}
a9e36db
BuildRequires:  %{py3_dist sphinx_rtd_theme}
4627d04
%if %{with doc_pdf}
4627d04
BuildRequires:  python3-sphinx-latex
4627d04
BuildRequires:  latexmk
4627d04
%endif
0986900
a6004ec
%global _description %{expand:
4627d04
Because the Apache Python avro package is written in pure Python, it is
4627d04
relatively slow. In one test case, it takes about 14 seconds to iterate through
4627d04
a file of 10,000 records. By comparison, the JAVA avro SDK reads the same file
4627d04
in 1.9 seconds.
4627d04
4627d04
The fastavro library was written to offer performance comparable to the Java
4627d04
library. With regular CPython, fastavro uses C extensions which allow it to
4627d04
iterate the same 10,000 record file in 1.7 seconds. With PyPy, this drops to
4627d04
1.5 seconds (to be fair, the JAVA benchmark is doing some extra JSON
4627d04
encoding/decoding).
4627d04
4627d04
Supported Features
4627d04
4627d04
  • File Writer
4627d04
  • File Reader (iterating via records or blocks)
4627d04
  • Schemaless Writer
4627d04
  • Schemaless Reader
4627d04
  • JSON Writer
4627d04
  • JSON Reader
4627d04
  • Codecs (Snappy, Deflate, Zstandard, Bzip2, LZ4, XZ)
4627d04
  • Schema resolution
4627d04
  • Aliases
4627d04
  • Logical Types
4627d04
  • Parsing schemas into the canonical form
4627d04
  • Schema fingerprinting
4627d04
4627d04
Missing Features
4627d04
4627d04
  • Anything involving Avro’s RPC features}
4627d04
a6004ec
%description %{_description}
0986900
4627d04
4627d04
%package -n python3-fastavro
4627d04
Summary:        %{summary}
4627d04
4627d04
%description -n python3-fastavro %{_description}
4627d04
4627d04
4627d04
%pyproject_extras_subpkg -n python3-fastavro codecs snappy zstandard lz4
4627d04
4627d04
0986900
%package doc
4627d04
Summary:        %{summary}
0986900
%description doc
4627d04
Documentation for python-fastavro.
4627d04
0986900
0986900
%prep
a24930c
%autosetup -n fastavro-%{version} -p1
0986900
b4bc552
# Remove the already generated C files so we generate them ourselves
4627d04
find fastavro/ -name '*.c' -print -delete
4627d04
e61df61
# Drop intersphinx mappings, since we can’t download remote inventories and
e61df61
# can’t easily produce working hyperlinks from inventories in local
e61df61
# documentation packages.
e61df61
echo 'intersphinx_mapping.clear()' >> docs/conf.py
e61df61
ddfd4dd
# Do not generate dependencies on linters, formatters, typecheckers, etc.:
ddfd4dd
sed -r -e '/^(black|check-manifest|flake8|mypy|twine)\b/d' \
ddfd4dd
    -e '/^(codecov|coverage|pytest-cov)\b/d' \
ddfd4dd
    developer_requirements.txt | tee developer_requirements-filtered.txt
ddfd4dd
4627d04
4627d04
%generate_buildrequires
4627d04
# codecs includes snappy, zstandard, and lz4
4627d04
%pyproject_buildrequires -x codecs
4627d04
# For some reason, combining this with the above does not work, even though it
4627d04
# should. It would be nice to investigate this.
ddfd4dd
%pyproject_buildrequires developer_requirements-filtered.txt
4627d04
b4bc552
0986900
%build
4627d04
%pyproject_wheel
4627d04
de19d2c
PYTHONPATH="%{pyproject_build_lib}" \
e61df61
    %make_build -C docs man SPHINXOPTS='-n %{?_smp_mflags}'
4627d04
%if %{with doc_pdf}
de19d2c
PYTHONPATH="%{pyproject_build_lib}" \
e61df61
    %make_build -C docs latex SPHINXOPTS='-n %{?_smp_mflags}'
4b2ecf5
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
4627d04
%endif
4627d04
0986900
0986900
%install
4627d04
%pyproject_install
4627d04
%pyproject_save_files fastavro
4627d04
4627d04
install -t '%{buildroot}%{_mandir}/man1' -p -m 0644 -D \
4627d04
    'docs/_build/man/fastavro.1'
0986900
0986900
b4bc552
%check
4627d04
# Avoid importing the “un-built” package. The tests really assume we have built
4627d04
# the extensions in-place, and occasionally use relative paths to the package
4627d04
# source directory. We would prefer to test the extensions as installed (and
4627d04
# avoid an extra build step), so we use a symbolic link to make the tests
4627d04
# appear alongside the built package.
4627d04
mkdir -p _empty
4627d04
cd _empty
4627d04
cp -rp ../tests/ .
4627d04
ln -s '%{buildroot}%{python3_sitearch}/fastavro' .
4627d04
4627d04
# These fail because there are no source lines in the tracebacks from Cython
4627d04
# modules, even though this works in the upstream CI. We haven’t figured out
4627d04
# the root cause, but it doesn’t seem to represent a real problem.
4627d04
k="${k-}${k+ and }not test_regular_vs_ordered_dict_map_typeerror"
4627d04
k="${k-}${k+ and }not test_regular_vs_ordered_dict_record_typeerror"
4627d04
4627d04
%pytest -k "${k-}"
4627d04
4627d04
4627d04
%files -n python3-fastavro -f %{pyproject_files}
4627d04
# pyproject-rpm-macros takes care of the license files—both LICENSE and
4627d04
# NOTICE.txt—verify with “rpm -qL -p …”
4627d04
%{_bindir}/fastavro
4627d04
%{_mandir}/man1/fastavro.*
0986900
0986900
0986900
%files doc
4627d04
%license LICENSE NOTICE.txt
4627d04
%doc ChangeLog
0986900
%doc README.md
4627d04
%if %{with doc_pdf}
4627d04
%doc docs/_build/latex/fastavro.pdf
4627d04
%endif
4627d04
0986900
0986900
%changelog
0e8a4f9
%autochangelog