Blob Blame History Raw
# Sphinx-generated HTML documentation is not suitable for packaging; see
# 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-2-Clause, but the following files are derived
# from the Python standard library under the PSF-2.0 license:
#   - editorconfig/
#   - editorconfig/
License:        BSD-2-Clause AND PSF-2.0
Source0:        %{url}/archive/v%{version}/editorconfig-core-py-%{version}.tar.gz
%global tests_url
Source1:        %{tests_url}/archive/%{tests_commit}/editorconfig-core-test-%{tests_commit}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel

# For tests:
BuildRequires:  cmake

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

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

%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}

%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/



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

%cmake -DPYTHON_EXECUTABLE='%{python3}'

%pyproject_save_files editorconfig

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

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

%files -n python3-editorconfig -f %{pyproject_files}
# pyproject_files handles COPYING and LICENSE.*; verify with “rpm -qL -p …”
%doc README.rst

%files doc
%doc README.rst
%doc docs/_build/text/
%if %{with doc_pdf}
%doc docs/_build/latex/EditorConfigPythonCore.pdf