File python-pyOpenSSL.spec of Package python-pyOpenSSL

%define realname pyopenssl
%define srcext   tar.bz2

%if ! 0%{?py_ver:1}
%define py_ver %(python -c "import sys; v=sys.version_info[:2]; print '%%d.%%d'%%v" 2>/dev/null || echo PYTHON-NOT-FOUND)
%endif

# Common info
Name:          %{?suse_version:python-}pyOpenSSL
Version:       16.2.0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         Development/Languages/Python
URL:           https://pyopenssl.readthedocs.io/
Summary:       A Python wrapper around the OpenSSL library

# Install-time parameters
Requires:      python(abi) = %{py_ver}
Requires:      python-cryptography >= 1.7
Requires:      python-six >= 1.5.2
Provides:      %{!?suse_version:python-}pyOpenSSL

# Build-time parameters
%if ! 0%{?sles_version}
BuildArch:     noarch
%endif
BuildRequires: python-setuptools
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}%{?extraver}.%{srcext}

%description
High-level wrapper around a subset of the OpenSSL library. Includes

  * SSL.Connection objects, wrapping the methods of Python's portable sockets
  * Callbacks written in Python
  * Extensive error-handling mechanism, mirroring OpenSSL's error codes

... and much more.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}

%build
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2
[ "%{buildroot}" != "/" ] && find %{buildroot}%{python_sitelib}/OpenSSL/ -name "*.pyo" -delete

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc CHANGELOG.rst LICENSE README.rst
%{python_sitelib}/OpenSSL/
%{python_sitelib}/pyOpenSSL-%{version}-py%{py_ver}.egg-info/

%changelog