562c04c
# Sphinx-generated HTML documentation is not suitable for packaging; see
562c04c
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
562c04c
#
562c04c
# We can generate PDF documentation as a lesser substitute.
4aa1dcb
%bcond doc_pdf 1
562c04c
562c04c
Name:           python-hdfs
e1cc8d6
Version:        2.7.2
bf8a5c8
Release:        %autorelease
562c04c
Summary:        API and command line interface for HDFS
562c04c
72cd750
# SPDX
562c04c
License:        MIT
562c04c
URL:            https://github.com/mtth/hdfs
ff8fc03
Source0:        %{url}/archive/v%{version}/hdfs-%{version}.tar.gz
a338ec3
# Downstream man pages in groff_man(7) format. These were written for Fedora
a338ec3
# based on the tools’ --help output and should be updated if the command-line
a338ec3
# interface changes.
562c04c
Source1:        hdfscli.1
562c04c
Source2:        hdfscli-avro.1
562c04c
562c04c
# The base package is arched because extras metapackages requiring fastavro are
562c04c
# not available on 32-bit architectures
562c04c
# (https://bugzilla.redhat.com/show_bug.cgi?id=1943932).
562c04c
%ifnarch %{arm32} %{ix86}
562c04c
%global fastavro_arch 1
43c4c13
%endif
562c04c
# Of the binary RPMs, only the conditionally-enabled extras metapackages
5a3ce06
# python3-hdfs+avro and python3-hdfs+dataframe are arched.
562c04c
#
562c04c
# Since there is no compiled code, there are no debugging symbols.
562c04c
%global debug_package %{nil}
b74379c
562c04c
BuildRequires:  python3-devel
562c04c
562c04c
# Extra dependencies for documentation
562c04c
%if %{with doc_pdf}
562c04c
BuildRequires:  make
562c04c
BuildRequires:  %{py3_dist sphinx}
562c04c
BuildRequires:  python3-sphinx-latex
562c04c
BuildRequires:  latexmk
562c04c
%endif
562c04c
562c04c
%global _description %{expand:
562c04c
%{summary}.
562c04c
562c04c
Features:
562c04c
562c04c
• Python bindings for the WebHDFS (and HttpFS) API, supporting both secure and
562c04c
  insecure clusters.
562c04c
• Command line interface to transfer files and start an interactive client
562c04c
  shell, with aliases for convenient namenode URL caching.
562c04c
• Additional functionality through optional extensions:
562c04c
  ○ avro, to read and write Avro files directly from HDFS.
562c04c
  ○ dataframe, to load and save Pandas dataframes.
562c04c
  ○ kerberos, to support Kerberos authenticated clusters.}
b74379c
562c04c
%description %{_description}
562c04c
562c04c
562c04c
%package -n python3-hdfs
562c04c
Summary:        %{summary}
b74379c
b74379c
BuildArch:      noarch
b74379c
562c04c
%description -n python3-hdfs %{_description}
b74379c
b74379c
b74379c
%package doc
562c04c
Summary:    Documentation and examples for %{name}
562c04c
562c04c
BuildArch:      noarch
562c04c
562c04c
%description doc %{_description}
b74379c
b74379c
b74379c
%prep
562c04c
%autosetup -n hdfs-%{version} -p1
b74379c
562c04c
# Remove shebangs from non-script sources. The find-then-modify pattern keeps
562c04c
# us from discarding mtimes on sources that do not need modification.
562c04c
find . -type f ! -perm /0111 \
562c04c
    -exec gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
562c04c
  xargs -r -t sed -r -i '1{/^#!/d}'
b74379c
b74379c
562c04c
%generate_buildrequires
562c04c
%pyproject_buildrequires -x kerberos%{?fastavro_arch:,avro,dataframe}
562c04c
562c04c
562c04c
# We manually write out the python3-hdfs+kerberos metapackage so that it (like
562c04c
# python3-hdfs) can be noarch even though the base package is arched. The
562c04c
# definition is based on:
562c04c
#
562c04c
#   rpm -E '%%pyproject_extras_subpkg -n python3-hdfs kerberos
562c04c
%package -n python3-hdfs+kerberos
562c04c
Summary:        Metapackage for python3-hdfs: kerberos extras
562c04c
562c04c
BuildArch:      noarch
562c04c
562c04c
Requires:       python3-hdfs = %{version}-%{release}
562c04c
562c04c
%description -n python3-hdfs+kerberos
562c04c
This is a metapackage bringing in kerberos extras requires for python3-hdfs.
562c04c
It makes sure the dependencies are installed.
562c04c
07ac7fa
%files -n python3-hdfs+kerberos
07ac7fa
%ghost %{python3_sitelib}/*.dist-info
562c04c
562c04c
562c04c
%if 0%{?fastavro_arch}
562c04c
562c04c
# Note that this subpackage is arched because it is not available on 32-bit
562c04c
# architectures.
562c04c
#
562c04c
# We manually write out the python3-hdfs+avro subpackage so that it can contain
562c04c
# the hdfscli-avro CLI entry point, and so that its summary and description can
562c04c
# be tweaked to reflect this.  The definition is based on:
562c04c
#
562c04c
#   rpm -E '%%pyproject_extras_subpkg -n python3-hdfs avro
562c04c
%package -n python3-hdfs+avro
562c04c
Summary:        Package for python3-hdfs: avro extras
562c04c
562c04c
Requires:       python3-hdfs = %{version}-%{release}
562c04c
562c04c
%description -n python3-hdfs+avro
562c04c
This is a package bringing in avro extras requires for python3-hdfs.
562c04c
It makes sure the dependencies are installed.
562c04c
562c04c
It also includes the avro-specific command-line tool, hdfscli-avro.
562c04c
07ac7fa
%files -n python3-hdfs+avro
07ac7fa
%ghost %{python3_sitelib}/*.dist-info
07ac7fa
562c04c
%{_bindir}/hdfscli-avro
562c04c
%{_mandir}/man1/hdfscli-avro.1*
562c04c
562c04c
562c04c
# Note that this metapackage is arched because it is not available on 32-bit
562c04c
# architectures.
562c04c
%pyproject_extras_subpkg -n python3-hdfs dataframe
562c04c
43c4c13
%endif
562c04c
562c04c
562c04c
%build
562c04c
%pyproject_wheel
562c04c
562c04c
%if %{with doc_pdf}
15d9ac6
PYTHONPATH="${PWD}" sphinx-build -b latex doc _latex -j%{?_smp_build_ncpus}
1fbf211
%make_build -C _latex LATEXMKOPTS='-quiet'
43c4c13
%endif
b74379c
b74379c
562c04c
%install
562c04c
%pyproject_install
562c04c
%pyproject_save_files hdfs
562c04c
install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 \
fd4fd1c
    %{SOURCE1} %{?fastavro_arch:%{SOURCE2}}
562c04c
562c04c
562c04c
%check
562c04c
# Ignore upstream tests - require a hadoop cluster setup
b74379c
# https://github.com/mtth/hdfs/blob/master/.travis.yml#L10
7fad7b7
%{pyproject_check_import \
7fad7b7
    %{?!fastavro_arch:-e hdfs.ext.avro -e hdfs.ext.dataframe}}
b74379c
562c04c
562c04c
%files -n python3-hdfs -f %{pyproject_files}
562c04c
# pyproject-rpm-macros handles the license file; verify with rpm -qL -p …
562c04c
%{_bindir}/hdfscli
562c04c
%{_mandir}/man1/hdfscli.1*
562c04c
# This is packaged in python3-hdfs+avro on 64-bit architectures; it is not
562c04c
# packaged at all on 32-bit architectures.
562c04c
%exclude %{_bindir}/hdfscli-avro
562c04c
b74379c
b74379c
%files doc
b74379c
%license LICENSE
562c04c
%doc AUTHORS
562c04c
%doc CHANGES
562c04c
%doc README.md
562c04c
%if %{with doc_pdf}
562c04c
%doc _latex/hdfs.pdf
562c04c
%endif
562c04c
%doc examples
562c04c
b74379c
b74379c
%changelog
bf8a5c8
%autochangelog