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 doc 1

Name:           python-libsass
Version:        0.23.0
Release:        %autorelease
Summary:        Sass for Python: A straightforward binding of libsass for Python

License:        MIT
Source:         %{url}/archive/%{version}/libsass-python-%{version}.tar.gz

# 0.22.0: documentation seems is not ready for sphinx 6.1.3
# doc: support sphinx 6.0 ext.extlinks
Patch:          %{url}/pull/433.patch

BuildRequires:  python3-devel

# Selected test dependencies from requirements-dev.txt; most entries in that
# file are for linters, code coverage, etc.
BuildRequires:  %{py3_dist pytest}
BuildRequires:  (%{py3_dist werkzeug} with %{py3_dist werkzeug} >= 0.9)

BuildRequires:  make
BuildRequires:  gcc-c++

BuildRequires:  libsass-devel >= 3.6.6

BuildRequires:  help2man
%if %{with doc}
BuildRequires:  %{py3_dist sphinx}
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk

%global common_description %{expand:
This package provides a simple Python extension module sass which is binding
LibSass (written in C/C++ by Hampton Catlin and Aaron Leung). It’s very
straightforward and there isn’t any headache related to Python
distribution/deployment. That means you can add just libsass into your’s install_requires list or requirements.txt file. No need for Ruby nor

%description %{common_description}

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

#   #_provides_for_importable_modules
# This package is messy; it occupies quite a few top-level names.
%py_provides python3-sass
%py_provides python3-pysassc
%py_provides python3-sasstests
%py_provides python3-sassutils

%description -n python3-libsass %{common_description}

%if %{with doc}
%package        doc
Summary:        Documentation for python-libsass

%description    doc %{common_description}

%autosetup -n libsass-python-%{version} -p1

# While upstream has the executable bit set, we will install this in
# site-packages without executable permissions; therefore, the shebang becomes
# useless, and we should remove it downstream.
sed -r -i '1{/^#!/d}'

export SYSTEM_SASS='1'

export SYSTEM_SASS='1'

%if %{with doc}
PYTHONPATH="${PWD}/build/${LIB}" %make_build -C docs latex \
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'

export SYSTEM_SASS='1'
%pyproject_save_files -l sass pysassc sasstests sassutils _sass

# We build the man page in %%install rather than %%build because we need to use
# the entry point in %%{buildroot}/%%{_bindir}.
install -d '%{buildroot}%{_mandir}/man1'
PYTHONPATH='%{buildroot}%{python3_sitearch}' \
    help2man --no-info --output='%{buildroot}%{_mandir}/man1/pysassc.1' \

%pytest -v

%files -n python3-libsass -f %{pyproject_files}
%if %{without doc}
%doc README.rst
%doc docs/changes.rst

%if %{with doc_pdf}
%files doc
%license LICENSE
%doc README.rst
%doc docs/changes.rst
%doc docs/_build/latex/libsass.pdf