[packages/python-tzlocal] - added pl and tests

qboosh qboosh at pld-linux.org
Mon Jul 14 06:36:37 CEST 2025


commit 39000d5dead1a425d7025c632079ba535212c620
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Mon Jul 14 06:38:12 2025 +0200

    - added pl and tests

 python-tzlocal.spec | 62 ++++++++++++++++++++++++++++++++++++++++++++++-------
 tzlocal-mock.patch  | 11 ++++++++++
 2 files changed, 65 insertions(+), 8 deletions(-)
---
diff --git a/python-tzlocal.spec b/python-tzlocal.spec
index b4cd576..c824c4b 100644
--- a/python-tzlocal.spec
+++ b/python-tzlocal.spec
@@ -1,30 +1,41 @@
 #
 # Conditional build:
+%bcond_without	tests	# unit tests
 %bcond_without	python2 # CPython 2.x module
 %bcond_without	python3 # CPython 3.x module
 
 %define 	module	tzlocal
 Summary:	tzinfo object for the local timezone
+Summary(pl.UTF-8):	Obiekt tzinfo dla lokalnej strefy czasowej
 Name:		python-%{module}
+# keep 2.x here for python2 support
 Version:	2.1
 Release:	7
 License:	MIT
 Group:		Development/Languages/Python
-Source0:	https://pypi.python.org/packages/source/t/tzlocal/%{module}-%{version}.tar.gz
+#Source0Download: https://pypi.org/simple/tzlocal/
+Source0:	https://files.pythonhosted.org/packages/source/t/tzlocal/%{module}-%{version}.tar.gz
 # Source0-md5:	c0877603ff9de71cd8ca6ee2b50d2ebd
+Patch0:		tzlocal-mock.patch
 URL:		https://github.com/regebro/tzlocal
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.714
 %if %{with python2}
 BuildRequires:	python >= 1:2.7
 BuildRequires:	python-setuptools
+%if %{with tests}
+BuildRequires:	python-mock
+BuildRequires:	python-pytz
+%endif
 %endif
 %if %{with python3}
 BuildRequires:	python3 >= 1:3.6
 BuildRequires:	python3-setuptools
+%if %{with tests}
+BuildRequires:	python3-pytz
+%endif
 %endif
 Requires:	python-modules >= 1:2.7
-Requires:	python-pytz
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -35,14 +46,24 @@ tzinfo objects.
 
 This module attempts to fix a glaring hole in pytz, that there is no
 way to get the local timezone information, unless you know the
-zoneinfo name, and under several Linux distros that’s hard or
+zoneinfo name, and under several Linux distros that's hard or
 impossible to figure out.
 
+%description -l pl.UTF-8
+Ten moduł Pythona zwraca obiekt tzinfo z informacjami o lokalnej
+strefie czasowej pod Uniksem i Win-32. Wymaga pytz i zwraca obiekty
+tzinfo z pytz.
+
+Moduł próbuje naprawić dziurę świecącą w pytz, że nie ma sposobu
+uzyskania informacji o lokalnej strefie czasowej, chyba że znamy jej
+nazwą, a w niektórych dystrybucjach Linuksa jest to trudne lub
+niemożliwe do uzyskania.
+
 %package -n python3-%{module}
-Summary:	tzinfo object for the local timezone for Python 3
+Summary:	tzinfo object for the local timezone
+Summary(pl.UTF-8):	Obiekt tzinfo dla lokalnej strefy czasowej
 Group:		Development/Languages/Python
 Requires:	python3-modules >= 1:3.6
-Requires:	python3-pytz
 
 %description -n python3-%{module}
 This Python module returns a tzinfo object with the local timezone
@@ -51,19 +72,44 @@ tzinfo objects.
 
 This module attempts to fix a glaring hole in pytz, that there is no
 way to get the local timezone information, unless you know the
-zoneinfo name, and under several Linux distros that’s hard or
+zoneinfo name, and under several Linux distros that's hard or
 impossible to figure out.
 
+%description -n python3-%{module} -l pl.UTF-8
+Ten moduł Pythona zwraca obiekt tzinfo z informacjami o lokalnej
+strefie czasowej pod Uniksem i Win-32. Wymaga pytz i zwraca obiekty
+tzinfo z pytz.
+
+Moduł próbuje naprawić dziurę świecącą w pytz, że nie ma sposobu
+uzyskania informacji o lokalnej strefie czasowej, chyba że znamy jej
+nazwą, a w niektórych dystrybucjach Linuksa jest to trudne lub
+niemożliwe do uzyskania.
+
 %prep
 %setup -q -n %{module}-%{version}
+%patch -P0 -p1
+
+# it was meant to be a symlink
+ln -snf ../usr/share/zoneinfo/Africa/Harare tests/test_data/symlink_localtime/etc/localtime
 
 %build
 %if %{with python2}
 %py_build
+
+%if %{with tests}
+# tz_from_env test expects absolute path to executable
+PYTHONPATH=$(pwd) \
+%{__python} $(pwd)/tests/tests.py
+%endif
 %endif
 
 %if %{with python3}
 %py3_build
+
+%if %{with tests}
+PYTHONPATH=$(pwd) \
+%{__python3} $(pwd)/tests/tests.py
+%endif
 %endif
 
 %install
@@ -85,7 +131,7 @@ rm -rf $RPM_BUILD_ROOT
 %if %{with python2}
 %files
 %defattr(644,root,root,755)
-%doc CHANGES.txt README.rst
+%doc CHANGES.txt LICENSE.txt README.rst
 %dir %{py_sitescriptdir}/%{module}
 %{py_sitescriptdir}/%{module}/*.py[co]
 %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
@@ -94,7 +140,7 @@ rm -rf $RPM_BUILD_ROOT
 %if %{with python3}
 %files -n python3-%{module}
 %defattr(644,root,root,755)
-%doc CHANGES.txt README.rst
+%doc CHANGES.txt LICENSE.txt README.rst
 %dir %{py3_sitescriptdir}/%{module}
 %{py3_sitescriptdir}/%{module}/*.py
 %{py3_sitescriptdir}/%{module}/__pycache__
diff --git a/tzlocal-mock.patch b/tzlocal-mock.patch
new file mode 100644
index 0000000..25343c8
--- /dev/null
+++ b/tzlocal-mock.patch
@@ -0,0 +1,11 @@
+--- tzlocal-2.1/tests/tests.py.orig	2020-05-08 08:02:55.000000000 +0200
++++ tzlocal-2.1/tests/tests.py	2025-07-13 22:33:31.736345578 +0200
+@@ -1,4 +1,7 @@
+-import mock
++try:
++    from unittest import mock
++except ImportError:
++    import mock
+ import os
+ import pytz
+ import sys
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-tzlocal.git/commitdiff/39000d5dead1a425d7025c632079ba535212c620



More information about the pld-cvs-commit mailing list