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
%if 0%{?fedora}
%bcond_without python3
%else
%bcond_with python3
%endif

%global srcname tzlocal

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

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

BuildArch:      noarch

Requires:       pytz
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  pytz
%if %{with python3}
Requires:       python3-pytz
BuildRequires:  python3-devel
BuildRequires:  python3-pytz
BuildRequires:  python3-setuptools
%endif


%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 python3-%{srcname}
Summary:        A Python module that tries to figure out what your local timezone is

License:        CC0

%description -n python3-%{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 LICENSE.txt CHANGES.txt
%{python2_sitelib}/%{srcname}
%{python2_sitelib}/%{srcname}-%{version}-py2.?.egg-info

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


%changelog
* 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