Blob Blame History Raw
%global git_sha a6ce774d
%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif

Name:           python-dpath
Version:        1.2
Release:        0.1.52.20140319git%{git_sha}%{?dist}
Summary:        A library for searching dictionaries using XPath-like expressions
License:        MIT
URL:            https://github.com/akesterson/dpath-python
BuildArch:      noarch

# we'll be able to use pypi if this gets pulled
# https://github.com/akesterson/dpath-python/pull/19
Source0:        %{name}-%{version}-%{git_sha}.tar.xz
Source1:        generate-tarball.sh

BuildRequires:  python2-devel
BuildRequires:  python-setuptools
%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
%endif # if with_python3


%description
A python library for accessing and searching dictionaries via /slashed/paths ala
xpath

Basically it lets you glob over a dictionary as if it were a filesystem. It
allows you to specify globs (ala the bash eglob syntax, through some advanced
fnmatch.fnmatch magic) to access dictionary elements, and provides some facility
for filtering those results.

%package -n python3-dpath
Summary:        A python3 library for searching dictionaries using XPath-like expressions

%description -n python3-dpath
A python library for accessing and searching dictionaries via /slashed/paths ala
xpath

Basically it lets you glob over a dictionary as if it were a filesystem. It
allows you to specify globs (ala the bash eglob syntax, through some advanced
fnmatch.fnmatch magic) to access dictionary elements, and provides some facility
for filtering those results.


%prep
%setup -q -n dpath-%{version}-%{git_sha}


%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif # with_python3

find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'

%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build

%if 0%{?with_python3}
pushd %{py3dir}
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
popd
%endif # with_python3

%install
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2 version
# to be the default for now).
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
popd
%endif # with_python3

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

%files
%doc LICENSE.txt README.md
%{python_sitelib}/dpath*

%if 0%{?with_python3}
%files -n python3-dpath
%doc LICENSE.txt README.md
%{python3_sitelib}/dpath*
%endif # with_python3


%changelog
* Wed Mar 19 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 1.2-0.1.52.20140319gita6ce774d
- Initial packaging