Blob Blame History Raw
# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

# The tests are stored in a separate repository, which is normally accessed
# as a git submodule.
%global tests_commit e407c1592df0f8e91664835324dea85146f20189

Name:           python-editorconfig
Version:        0.12.3
Release:        %autorelease
Summary:        EditorConfig File Locator and Interpreter for Python

# See COPYING: the overall license is BSD, but the following files are derived
# from the Python standard library under the Python license:
#   - editorconfig/fnmatch.py
#   - editorconfig/ini.py
License:        Python and BSD
URL:            https://github.com/editorconfig/editorconfig-core-py
Source0:        %{url}/archive/v%{version}/editorconfig-core-py-%{version}.tar.gz
%global tests_url https://github.com/editorconfig/editorconfig-core-test
Source1:        %{tests_url}/archive/%{tests_commit}/editorconfig-core-test-%{tests_commit}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3dist(setuptools)

# For tests:
BuildRequires:  cmake

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
%endif

%global common_description %{expand: \
EditorConfig Python Core provides the same functionality as the EditorConfig C
Core.}

%description
%{common_description}


%package     -n python3-editorconfig
Summary:        %{summary}

%description -n python3-editorconfig
%{common_description}


%package        doc
Summary:        Documentation for python-editorconfig

%description    doc %{common_description}


%prep
%setup -q -n editorconfig-core-py-%{version}

rm -vrf tests
%setup -q -n editorconfig-core-py-%{version} -T -D -b 1
mv ../editorconfig-core-test-%{tests_commit}/ tests/


%build
%{py3_build}

%make_build -C docs text SPHINXOPTS='%{?_smp_mflags}'
%if %{with doc_pdf}
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif

%cmake -DPYTHON_EXECUTABLE='%{python3}'

%install
%{py3_install}

# The command-line tool would conflict with the one from the C version of
# EditorConfig. It could be installed under a different name, if any one ever
# reports a need for it.
rm -vf '%{buildroot}%{_bindir}/editorconfig'


%check
export PYTHONPATH='%{buildroot}%{python3_sitelib}'
%ctest


%files -n python3-editorconfig
%license COPYING LICENSE.BSD LICENSE.PSF
%doc README.rst
%{python3_sitelib}/editorconfig
%{python3_sitelib}/EditorConfig-%{version}-py%{python3_version}.egg-info


%files doc
%license COPYING LICENSE.BSD LICENSE.PSF
%doc README.rst
%doc docs/_build/text
%if %{with doc_pdf}
%doc docs/_build/latex/EditorConfigPythonCore.pdf
%endif


%changelog
%autochangelog