Blob Blame History Raw
# needed for epel6
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

# enable python3 on fedora and epel7
%if 0%{?fedora} || 0%{?rhel} == 7
%bcond_without python3
%else
%bcond_with python3
%endif

%global srcname tzlocal

Name:           python-tzlocal
Version:        1.2
Release:        3%{?dist}
Summary:        A Python module that tries to figure out what your local timezone is

License:        CC0
URL:            https://github.com/regebro/tzlocal
Source0:        https://pypi.python.org/packages/source/t/%{srcname}/%{srcname}-%{version}.tar.gz

BuildArch:      noarch

Requires:       pytz
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  pytz


%description
This Python module returns a tzinfo object with the local timezone information. 
It requires pytz, and returns pytz 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.


%if %{with python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary:        A Python module that tries to figure out what your local timezone is

License:        CC0

Requires:       python%{python3_pkgversion}-pytz
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-pytz
BuildRequires:  python%{python3_pkgversion}-setuptools

%description -n python%{python3_pkgversion}-%{srcname}
This Python module returns a tzinfo object with the local timezone information. 
It requires pytz, and returns pytz 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.

%endif


%prep
%setup -q -n %{srcname}-%{version}

rm -rf *.egg-info

%if %{with python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif


%build
%{__python2} setup.py build

%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif


%install
%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}

# Don't install unit tests and test_data
rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/test_data
rm %{buildroot}%{python3_sitelib}/%{srcname}/tests.py
rm %{buildroot}%{python3_sitelib}/%{srcname}/__pycache__/tests.cpython*
popd
%endif

%{__python2} setup.py install -O1 --skip-build --root %{buildroot}

# Don't install unit tests and test_data
rm -rf %{buildroot}%{python2_sitelib}/%{srcname}/test_data
rm %{buildroot}%{python2_sitelib}/%{srcname}/tests.py*


%check
%{__python2} setup.py test

%if %{with python3}
%{__python3} setup.py test
%endif


%files
%doc PKG-INFO README.rst CHANGES.txt
%license LICENSE.txt
%{python2_sitelib}/%{srcname}
%{python2_sitelib}/%{srcname}-%{version}-py2.?.egg-info

%if %{with python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc PKG-INFO README.rst CHANGES.txt
%license LICENSE.txt
%{python3_sitelib}/%{srcname}
%{python3_sitelib}/%{srcname}-%{version}-py3.?.egg-info
%endif


%changelog
* Thu Apr 16 2020 Robert Scheck <robert@fedoraproject.org> - 1.2-3
- Build python3 support for RHEL/CentOS 7

* Fri Nov 06 2015 Piotr Popieluch <piotr1212@gmail.com> - 1.2-2
- Rebuilt for python 3.5

* Fri Jul 03 2015 Piotr Popieluch <piotr1212@gmail.com> - 1.2-1
- Update to 1.2

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat Nov 22 2014 Piotr Popieluch <piotr1212@gmail.com> - 1.1.2-4
- added epel support

* Tue Oct 28 2014 Piotr Popieluch <piotr1212@gmail.com> - 1.1.2-3
- fixed python3-tzlocal %%summary to match python-tzlocal

* Sat Oct 25 2014 Piotr Popieluch <piotr1212@gmail.com> - 1.1.2-2
- deleted group tag
- added license to python3 module
- rewritten summary
- wrapped description
- added rm -rf *.egg-info to %%prep
- added comments to the rm commands in %%install section

* Fri Oct 24 2014 Piotr Popieluch <piotr1212@gmail.com> - 1.1.2-1
- Initial package