14
0
forked from pool/python-PyJWT

Accepting request 491801 from home:xenonpk:python

Proper fix for tests with different python versions

OBS-URL: https://build.opensuse.org/request/show/491801
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PyJWT?expand=0&rev=23
This commit is contained in:
2017-04-28 10:52:39 +00:00
committed by Git OBS Bridge
parent 540039ae0a
commit a0fb0b9056
3 changed files with 47 additions and 33 deletions

View File

@@ -16,11 +16,7 @@
#
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch: noarch
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-PyJWT
Version: 1.4.2
Release: 0
@@ -29,56 +25,60 @@ License: MIT
Group: Development/Languages/Python
Url: https://github.com/progrium/pyjwt
Source: https://files.pythonhosted.org/packages/source/P/PyJWT/PyJWT-%{version}.tar.gz
BuildRequires: dos2unix
BuildRequires: python-cryptography
BuildRequires: python-devel
BuildRequires: python-ecdsa
BuildRequires: python-pytest
BuildRequires: python-pytest-cov >= 1.7
BuildRequires: python-pytest-runner
BuildRequires: python-setuptools
Requires: python-cryptography
Requires: python-ecdsa
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: %{python_module cryptography}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pytest-cov >= 1.7}
BuildRequires: %{python_module pytest-runner}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-cryptography
Requires: python-setuptools
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
%python_subpackages
%description
A Python implementation of JSON Web Token draft 01.
%prep
%setup -q -n PyJWT-%{version}
dos2unix jwt/__main__.py
sed -i -e "s/jwt = jwt.__main__:main/jwt-%{py_ver} = jwt.__main__:main/" setup.py
%build
python setup.py build
%python_build
#remove shebang from all non executable files
find ./ -type f -name "*.py" -perm 644 -exec sed -i -e '1{\@^#!/usr/bin/env python@d}' {} \;
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%python_install
%python_clone -a %{buildroot}%{_bindir}/jwt
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/jwt
ln -sf %{_sysconfdir}/alternatives/jwt %{buildroot}/%{_bindir}/jwt
#hardlink duplicated files
%fdupes %{buildroot}
%post
update-alternatives \
--install %{_bindir}/jwt jwt %{_bindir}/jwt-%{py_ver} 30
%python_install_alternative jwt
%postun
if [ $1 -eq 0 ] ; then
update-alternatives --remove jwt %{_bindir}/jwt-%{py_ver}
fi
%python_uninstall_alternative jwt
%check
PYTHONPATH=%{buildroot}%{python_sitelib} py.test -k "not test_verify_false_deprecated"
%{python_expand PYTHONPATH=%{buildroot}%{python_sitelib} py.test-%{py_ver} -k "not test_verify_false_deprecated" }
%files
%files %python_files
%defattr(-,root,root,-)
%doc AUTHORS CHANGELOG.md LICENSE README.md
%{python_sitelib}/*
%{_bindir}/jwt
%{_bindir}/jwt-%{py_ver}
%ghost %{_sysconfdir}/alternatives/jwt
%python_alternative %{_bindir}/jwt
%changelog