Blob Blame History Raw
%{?python_enable_dependency_generator}

%global modname ssh-python

Name:           python-%{modname}
Version:        0.9.0
Release:        1%{?dist}
Summary:        Bindings for libssh C library

License:        LGPLv2+
URL:            https://github.com/ParallelSSH/ssh-python
Source0:        %{url}/archive/%{version}/%{modname}-%{version}.tar.gz

Patch0001:      0001-Set-master_doc-to-index-in-conf.py-for-sphinx.patch

BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  libssh-devel

BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-Cython
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme

# test dependencies
BuildRequires:  python3-pytest
BuildRequires:  %{_sbindir}/sshd %{_bindir}/ssh-agent

Recommends: python3-%{modname}-doc

%description
%{summary}.

%package -n python3-%{modname}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{modname}}

%description -n python3-%{modname}
%{summary}.

Python 3 version.


%prep
%setup -n %{modname}-%{version}
%patch1 -p1
# No bundled libs
rm -vrf libssh
sed -i -r 's:build_ssh[(].*:pass:' setup.py
# Remove pre-generated sources
rm $(grep -rl '/\* Generated by Cython')

%build
%py3_build
export HAVE_AGENT_FWD=0
# use build_ext to completely instruct cythonize options
export CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}"
export LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"
export CXXFLAGS="${CXXFLAGS:-${RPM_OPT_FLAGS}}"
%{python3} setup.py build_ext --inplace
%{python3} -msphinx -M html doc _build

%install
%py3_install
# remove 0 length files
rm -f %{buildroot}/%{python3_sitearch}/ssh/__init__.pxd
chmod 0755 %{buildroot}/%{python3_sitearch}/ssh/*.so


%check
# disable some options for sshd running inside mock
echo UsePrivilegeSeparation no >> tests/embedded_server/sshd_config.tmpl
echo StrictModes no >> tests/embedded_server/sshd_config.tmpl
# test_statvfs/test_fstatvfs do not seem to work in mock
rm -f tests/test_sftp.py
%pytest -v tests

%files -n python3-%{modname}
%license COPYING LICENSE
%doc README.rst Changelog.rst
%{python3_sitearch}/ssh_python-*.egg-info/
%{python3_sitearch}/ssh/

%package -n python3-%{modname}-doc
Summary:        %{summary} documentation

%description -n python3-%{modname}-doc
%{summary} documentation.

%files -n python3-%{modname}-doc
%doc examples/ _build/html/

%changelog
* Wed Dec 8 2021 James Slagle <jslagle@redhat.com> - 0.9.0-1
- Initial package