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)

# 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
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
BuildRequires: python-setuptools
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}%{?extraver}.%{srcext}

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)
%setup -q -n %{realname}-%{version}%{?extraver}

python build

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

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