Blob Blame History Raw
# Upstream name
%global srcname Flask-Migrate

%bcond_without tests

# Name used in egg-info
%global eggname %(\
  awk -vn='%{srcname}' 'BEGIN { gsub(/-/, "_", n); print n }')
# Name of importable Python package
%global modname %(\
  awk -vn='%{srcname}' 'BEGIN { gsub(/-/, "_", n); print tolower(n) }')
# Name used in RPM package names
%global rpmname %{py_dist_name %{srcname}}

%global forgeurl    https://github.com/miguelgrinberg/%{srcname}/

Name:               python-%{rpmname}
Version:            3.0.1
%forgemeta
Release:            %autorelease
Summary:            SQLAlchemy database migrations for Flask applications using Alembic

License:            MIT
URL:                %{forgeurl}
Source0:            %{forgesource}
BuildArch:          noarch

BuildRequires:      python3-devel
BuildRequires:      pyproject-rpm-macros

# Documentation
BuildRequires:      python3dist(sphinx)
BuildRequires:      make

%global common_description %{expand:
SQLAlchemy database migrations for Flask applications using Alembic.}

%description %{common_description}


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

%description -n python3-%{rpmname} %{common_description}


%package doc
Summary:            Documentation for %{srcname}

%description doc
Documentation for %{srcname}.


%prep
%forgeautosetup
# Fix unversioned Python command
sed -r -i 's/(python)( |$)/\13\2/g' tests/*.py


%generate_buildrequires
%pyproject_buildrequires -t


%build
%pyproject_wheel
%make_build -C docs SPHINXOPTS='%{?_smp_mflags}' html
rm -vf docs/_build/html/.buildinfo


%install
%pyproject_install
%pyproject_save_files %{modname}


%check
%if %{with tests}
env PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitelib}}" \
    PYTHONDONTWRITEBYTECODE=1 \
    %{python3} -m unittest discover -v
%else
echo 'Tests are disabled'
%endif


%files -n python3-%{rpmname} -f %{pyproject_files}
%license LICENSE


%files doc
%license LICENSE
%doc README.md
%doc docs/_build/html


%changelog
%autochangelog