%define oname Markdown
%global pkgname markdown

Summary: Python implementation of the markdown text-to-HTML conversion tool
Name: python-markdown
Version:	3.5.1
Release:	1%{dist}
Source:  https://files.pythonhosted.org/packages/source/M/Markdown/%oname-%version.tar.gz
License: BSD
Group: Development/Python
BuildRequires: python%{python3_pkgversion}-devel
#BuildRequires: python-pkg-resources
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-wheel
BuildRequires: python%{python3_pkgversion}-nose
BuildRequires: python%{python3_pkgversion}-yaml
BuildRequires: pyproject-rpm-macros
Url: http://www.freewisdom.org/projects/python-markdown/ 


%global _description %{expand:
This is a Python implementation of John Gruber's Markdown. It is almost 
completely compliant with the reference implementation, though there 
are a few known issues

Markdown  is a text-to-HTML conversion tool for web writers. Markdown 
allows you to write using an easy-to-read, easy-to-write plain text format, 
then convert it to structurally valid XHTML (or HTML).}

%description
%_description

%package -n python%{python3_pkgversion}-%{pkgname}
Summary:   %{summary}
BuildArch: noarch
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pkgname}}

%description -n python%{python3_pkgversion}-%{pkgname} %_description

%prep
%setup -q -n %oname-%version 
# remove shebangs
find markdown -type f -name '*.py' \
  -exec sed -i -e '/^#!/{1D}' {} \;

# fix line-ending
find docs -type f \
  -exec sed -i 's/\r//' {} \;

sed -i '/importlib-metadata>=4.4/d' pyproject.toml
sed -i '/importlib-metadata>=4.4/d' Markdown.egg-info/requires.txt

%build
%pyproject_wheel

%install
%pyproject_install

# rename binary
mv %{buildroot}%{_bindir}/markdown_py{,-%{python3_version}}

%files -n python%{python3_pkgversion}-%{pkgname}
%{python3_sitelib}/*
%{_bindir}/markdown_py-%{python3_version}

