Blame SOURCES/libbytesize-tests.patch

2704ea
From cae191ae459e046dc317b7bc57941e3f1cec910d Mon Sep 17 00:00:00 2001
2704ea
From: Vojtech Trefny <vtrefny@redhat.com>
2704ea
Date: Fri, 10 Aug 2018 08:35:51 +0200
2704ea
Subject: [PATCH 1/4] Run all libbytesize tests from one script
2704ea
2704ea
This also makes sure we run tests with all supported python versions.
2704ea
---
2704ea
 tests/Makefile.am                | 2 +-
2704ea
 tests/libbytesize_unittest.sh.in | 2 ++
2704ea
 tests/libbytesize_unittest.sh    | 2 ++
2704ea
 3 files changed, 5 insertions(+), 1 deletion(-)
2704ea
2704ea
diff --git a/tests/Makefile.am b/tests/Makefile.am
2704ea
index 1f59f64..1e51834 100644
2704ea
--- a/tests/Makefile.am
2704ea
+++ b/tests/Makefile.am
2704ea
@@ -2,7 +2,7 @@ AM_TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)" top_builddir="$(top_builddir)"
2704ea
2704ea
 dist_noinst_SCRIPTS = libbytesize_unittest.sh libbytesize_unittest.py lbs_py_override_unittest.py locale_utils.py testenv.sh canary_tests.sh
2704ea
2704ea
-TESTS = libbytesize_unittest.sh lbs_py_override_unittest.py canary_tests.sh
2704ea
+TESTS = libbytesize_unittest.sh canary_tests.sh
2704ea
2704ea
 # Add the translation-canary source files to the tarball
2704ea
 EXTRA_DIST = $(top_srcdir)/translation-canary/translation_canary/*.py \
2704ea
diff --git a/tests/libbytesize_unittest.sh.in b/tests/libbytesize_unittest.sh.in
2704ea
index 7896675..e5ca56d 100644
2704ea
--- a/tests/libbytesize_unittest.sh.in
2704ea
+++ b/tests/libbytesize_unittest.sh.in
2704ea
@@ -9,10 +9,12 @@ fi
2704ea
2704ea
 if [ @WITH_PYTHON2@ = 1 ]; then
2704ea
     python2 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
+    python2 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
 if [ @WITH_PYTHON3@ = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
+    python3 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
 if [ @WITH_PYTHON2@ = 1 ]; then
2704ea
diff --git a/tests/libbytesize_unittest.sh b/tests/libbytesize_unittest.sh
2704ea
index 7896675..e5ca56d 100644
2704ea
--- a/tests/libbytesize_unittest.sh
2704ea
+++ b/tests/libbytesize_unittest.sh
2704ea
@@ -9,10 +9,12 @@ fi
2704ea
2704ea
 if [ 1 = 1 ]; then
2704ea
     python2 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
+    python2 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
 if [ 1 = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
+    python3 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
 if [ 1 = 1 ]; then
2704ea
--
2704ea
2.20.1
2704ea
2704ea
2704ea
From 2c376a25813bf6966ec9c6da5a558dd5f4edc423 Mon Sep 17 00:00:00 2001
2704ea
From: Vojtech Trefny <vtrefny@redhat.com>
2704ea
Date: Tue, 5 Mar 2019 14:20:14 +0100
2704ea
Subject: [PATCH 2/4] Add all "public" python API  symbols to __init__.py
2704ea
2704ea
So it can be imported as "from bytesize import xyz" instead of
2704ea
"from bytesize.bytesize import xyz".
2704ea
---
2704ea
 src/python/__init__.py | 3 +++
2704ea
 1 file changed, 3 insertions(+)
2704ea
2704ea
diff --git a/src/python/__init__.py b/src/python/__init__.py
2704ea
index 6ab80dc..57403d5 100644
2704ea
--- a/src/python/__init__.py
2704ea
+++ b/src/python/__init__.py
2704ea
@@ -1 +1,4 @@
2704ea
 from .bytesize import Size
2704ea
+from .bytesize import B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB, KB, MB, GB, TB, PB, EB, ZB, YB
2704ea
+from .bytesize import ROUND_UP, ROUND_DOWN, ROUND_HALF_UP
2704ea
+from .bytesize import SizeError, InvalidSpecError, OverflowError, ZeroDivisionError
2704ea
--
2704ea
2.20.1
2704ea
2704ea
2704ea
From f07701b397907cefd7e43063b76277cc991f5339 Mon Sep 17 00:00:00 2001
2704ea
From: Vojtech Trefny <vtrefny@redhat.com>
2704ea
Date: Tue, 5 Mar 2019 14:55:20 +0100
2704ea
Subject: [PATCH 3/4] Allow running tests using installed library
2704ea
2704ea
We need to be able to import the SizeStruct object from installed
2704ea
python-bytesize.
2704ea
---
2704ea
 tests/libbytesize_unittest.py | 10 ++++++++--
2704ea
 1 file changed, 8 insertions(+), 2 deletions(-)
2704ea
2704ea
diff --git a/tests/libbytesize_unittest.py b/tests/libbytesize_unittest.py
2704ea
index 5e63778..d7400be 100755
2704ea
--- a/tests/libbytesize_unittest.py
2704ea
+++ b/tests/libbytesize_unittest.py
2704ea
@@ -8,7 +8,14 @@ import ctypes
2704ea
2704ea
 from locale_utils import get_avail_locales, requires_locales
2704ea
2704ea
-from bytesize import SizeStruct, KiB, GiB, ROUND_UP, ROUND_DOWN, ROUND_HALF_UP, OverflowError
2704ea
+from bytesize import KiB, GiB, ROUND_UP, ROUND_DOWN, ROUND_HALF_UP, OverflowError
2704ea
+
2704ea
+# SizeStruct is part of the 'private' API and needs to be imported differently
2704ea
+# when running from locally build tree and when using installed library
2704ea
+try:
2704ea
+    from bytesize import SizeStruct
2704ea
+except ImportError:
2704ea
+    from bytesize.bytesize import SizeStruct
2704ea
2704ea
 DEFAULT_LOCALE = "en_US.utf8"
2704ea
2704ea
@@ -759,4 +766,3 @@ if __name__=='__main__':
2704ea
         sys.argv = [sys.argv[0]]
2704ea
     unittest.main()
2704ea
 #endif
2704ea
-
2704ea
--
2704ea
2.20.1
2704ea
2704ea
2704ea
From 4d692ac4eb178121c4e91ab881645aef94d65ed4 Mon Sep 17 00:00:00 2001
2704ea
From: Vojtech Trefny <vtrefny@redhat.com>
2704ea
Date: Wed, 6 Mar 2019 09:27:41 +0100
2704ea
Subject: [PATCH 4/4] Remove Python 2 support
2704ea
2704ea
Python 2 EOL is close and we are no longer shipping python2
2704ea
package in newest distributions, so it makes sense to remove
2704ea
Python 2 support entirely.
2704ea
---
2704ea
 Makefile.am                       |  2 +-
2704ea
 configure.ac                      | 16 ----------------
2704ea
 dist/libbytesize.spec.in          | 31 +------------------------------
2704ea
 src/python/Makefile.am            |  9 +--------
2704ea
 tests/lbs_py_override_unittest.py |  4 +---
2704ea
 tests/libbytesize_unittest.py     |  2 +-
2704ea
 tests/libbytesize_unittest.sh.in  |  9 ---------
2704ea
 tests/libbytesize_unittest.sh     |  9 ---------
2704ea
 8 files changed, 5 insertions(+), 77 deletions(-)
2704ea
2704ea
diff --git a/Makefile.am b/Makefile.am
2704ea
index 93279f2..1ac10bd 100644
2704ea
--- a/Makefile.am
2704ea
+++ b/Makefile.am
2704ea
@@ -38,7 +38,7 @@ dist-hook:
2704ea
 	done
2704ea
2704ea
 run-ipython: all
2704ea
-	LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=$(PYTHONDIR) ipython
2704ea
+	LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=$(PYTHONDIR) ipython3
2704ea
2704ea
 check-requires:
2704ea
 	@echo "*** Checking if the dependencies required for testing and analysis are available ***"
2704ea
diff --git a/configure.ac b/configure.ac
2704ea
index 749d929..c2306dc 100644
2704ea
--- a/configure.ac
2704ea
+++ b/configure.ac
2704ea
@@ -50,22 +50,6 @@ AC_CHECK_HEADERS([langinfo.h gmp.h mpfr.h stdint.h stdbool.h stdarg.h string.h s
2704ea
                  [LIBBYTESIZE_SOFT_FAILURE([Header file $ac_header not found.])],
2704ea
                  [])
2704ea
2704ea
-AC_ARG_WITH([python2],
2704ea
-    AS_HELP_STRING([--with-python2], [support python2 @<:@default=check@:>@]),
2704ea
-    [],
2704ea
-    [with_python2=check])
2704ea
-
2704ea
-AC_SUBST(WITH_PYTHON2, 0)
2704ea
-if test "x$with_python2" != "xno"; then
2704ea
-    AC_PATH_PROG([python2], [python2], [no])
2704ea
-    AS_IF([test "x$python2" == "xno"],
2704ea
-    [if test "x$with_python2" = "xyes"; then
2704ea
-      LIBBYTESIZE_SOFT_FAILURE([Python2 support requested, but python2 is not available])
2704ea
-      fi],
2704ea
-    [AC_SUBST(WITH_PYTHON2, 1)])
2704ea
-fi
2704ea
-AM_CONDITIONAL(WITH_PYTHON2, test "x$with_python2" != "xno" -a "x$python2" != "xno")
2704ea
-
2704ea
 AC_ARG_WITH([python3],
2704ea
     AS_HELP_STRING([--with-python3], [support python3 @<:@default=check@:>@]),
2704ea
     [],
2704ea
diff --git a/dist/libbytesize.spec.in b/dist/libbytesize.spec.in
2704ea
index 3f306f9..9658a7c 100644
2704ea
--- a/dist/libbytesize.spec.in
2704ea
+++ b/dist/libbytesize.spec.in
2704ea
@@ -1,5 +1,4 @@
2704ea
 %define realname bytesize
2704ea
-%define with_python2 @WITH_PYTHON2@
2704ea
 %define with_python3 @WITH_PYTHON3@
2704ea
 %define with_gtk_doc @WITH_GTK_DOC@
2704ea
2704ea
@@ -8,13 +7,7 @@
2704ea
 %define python3_opts --without-python3
2704ea
 %endif
2704ea
2704ea
-# python2 is not available on RHEL > 7 and not needed on Fedora > 28
2704ea
-%if 0%{?rhel} > 7 || 0%{?fedora} > 28 || %{with_python2} == 0
2704ea
-%define with_python2 0
2704ea
-%define python2_opts --without-python2
2704ea
-%endif
2704ea
-
2704ea
-%define configure_opts %{?python3_opts} %{?python2_opts}
2704ea
+%define configure_opts %{?python3_opts}
2704ea
2704ea
 Name:        libbytesize
2704ea
 Version:     1.4
2704ea
@@ -29,9 +22,6 @@ BuildRequires: gmp-devel
2704ea
 BuildRequires: mpfr-devel
2704ea
 BuildRequires: pcre-devel
2704ea
 BuildRequires: gettext-devel
2704ea
-%if %{with_python2}
2704ea
-BuildRequires: python2-devel
2704ea
-%endif
2704ea
 %if %{with_python3}
2704ea
 BuildRequires: python3-devel
2704ea
 %endif
2704ea
@@ -53,19 +43,6 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
2704ea
 This package contains header files and pkg-config files needed for development
2704ea
 with the libbytesize library.
2704ea
2704ea
-%if %{with_python2}
2704ea
-%package -n python2-%{realname}
2704ea
-Summary: Python 2 bindings for libbytesize
2704ea
-%{?python_provide:%python_provide python2-%{realname}}
2704ea
-%{?python_provide:%python_provide python2-libbytesize}
2704ea
-Requires: %{name}%{?_isa} = %{version}-%{release}
2704ea
-Requires: python2-six
2704ea
-
2704ea
-%description -n python2-%{realname}
2704ea
-This package contains Python 2 bindings for libbytesize making the use of
2704ea
-the library from Python 2 easier and more convenient.
2704ea
-%endif
2704ea
-
2704ea
 %if %{with_python3}
2704ea
 %package -n python3-%{realname}
2704ea
 Summary: Python 3 bindings for libbytesize
2704ea
@@ -108,12 +85,6 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
2704ea
 %{_datadir}/gtk-doc/html/libbytesize
2704ea
 %endif
2704ea
2704ea
-%if %{with_python2}
2704ea
-%files -n python2-%{realname}
2704ea
-%dir %{python2_sitearch}/bytesize
2704ea
-%{python2_sitearch}/bytesize/*
2704ea
-%endif
2704ea
-
2704ea
 %if %{with_python3}
2704ea
 %files -n python3-%{realname}
2704ea
 %dir %{python3_sitearch}/bytesize
2704ea
diff --git a/src/python/Makefile.am b/src/python/Makefile.am
2704ea
index e0261a6..cb2b197 100644
2704ea
--- a/src/python/Makefile.am
2704ea
+++ b/src/python/Makefile.am
2704ea
@@ -1,14 +1,7 @@
2704ea
-if WITH_PYTHON2
2704ea
-pylibdir = $(shell python -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(1,0,prefix='${exec_prefix}'))")
2704ea
-
2704ea
-pybytesizedir     = $(pylibdir)/bytesize
2704ea
-dist_pybytesize_DATA = bytesize.py __init__.py
2704ea
-endif
2704ea
-
2704ea
 if WITH_PYTHON3
2704ea
 py3libdir = $(shell python3 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(1,0,prefix='${exec_prefix}'))")
2704ea
 py3bytesizedir    = $(py3libdir)/bytesize
2704ea
-nodist_py3bytesize_DATA = bytesize.py __init__.py
2704ea
+dist_py3bytesize_DATA = bytesize.py __init__.py
2704ea
 endif
2704ea
2704ea
 MAINTAINERCLEANFILES = Makefile.in
2704ea
diff --git a/tests/lbs_py_override_unittest.py b/tests/lbs_py_override_unittest.py
2704ea
index c5f3cb2..9a219f2 100755
2704ea
--- a/tests/lbs_py_override_unittest.py
2704ea
+++ b/tests/lbs_py_override_unittest.py
2704ea
@@ -1,4 +1,4 @@
2704ea
-#!/usr/bin/env python
2704ea
+#!/usr/bin/python3
2704ea
 # -*- coding: utf-8 -*-
2704ea
2704ea
 import unittest
2704ea
@@ -306,5 +306,3 @@ class SizeTestCase(unittest.TestCase):
2704ea
 if __name__=='__main__':
2704ea
     unittest.main()
2704ea
 #endif
2704ea
-
2704ea
-
2704ea
diff --git a/tests/libbytesize_unittest.py b/tests/libbytesize_unittest.py
2704ea
index d7400be..1c57d2a 100755
2704ea
--- a/tests/libbytesize_unittest.py
2704ea
+++ b/tests/libbytesize_unittest.py
2704ea
@@ -1,4 +1,4 @@
2704ea
-#!/usr/bin/env python2
2704ea
+#!/usr/bin/python3
2704ea
 # -*- coding: utf-8 -*-
2704ea
2704ea
 import locale
2704ea
diff --git a/tests/libbytesize_unittest.sh.in b/tests/libbytesize_unittest.sh.in
2704ea
index e5ca56d..816bc28 100644
2704ea
--- a/tests/libbytesize_unittest.sh.in
2704ea
+++ b/tests/libbytesize_unittest.sh.in
2704ea
@@ -7,20 +7,11 @@ if [ -z "$srcdir" ]; then
2704ea
     srcdir="$(dirname "$0")"
2704ea
 fi
2704ea
2704ea
-if [ @WITH_PYTHON2@ = 1 ]; then
2704ea
-    python2 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
-    python2 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
-fi
2704ea
-
2704ea
 if [ @WITH_PYTHON3@ = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
     python3 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
-if [ @WITH_PYTHON2@ = 1 ]; then
2704ea
-    python2 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1
2704ea
-fi
2704ea
-
2704ea
 if [ @WITH_PYTHON3@ = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1
2704ea
 fi
2704ea
diff --git a/tests/libbytesize_unittest.sh b/tests/libbytesize_unittest.sh
2704ea
index e5ca56d..816bc28 100644
2704ea
--- a/tests/libbytesize_unittest.sh
2704ea
+++ b/tests/libbytesize_unittest.sh
2704ea
@@ -7,20 +7,11 @@ if [ -z "$srcdir" ]; then
2704ea
     srcdir="$(dirname "$0")"
2704ea
 fi
2704ea
2704ea
-if [ 1 = 1 ]; then
2704ea
-    python2 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
-    python2 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
-fi
2704ea
-
2704ea
 if [ 1 = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py || status=1
2704ea
     python3 ${srcdir}/lbs_py_override_unittest.py || status=1
2704ea
 fi
2704ea
2704ea
-if [ 1 = 1 ]; then
2704ea
-    python2 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1
2704ea
-fi
2704ea
-
2704ea
 if [ 1 = 1 ]; then
2704ea
     python3 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1
2704ea
 fi
2704ea
--
2704ea
2.20.1