File python3-CommonMark.spec of Package python3-CommonMark
#
# spec file for package python3-CommonMark
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: python3-CommonMark
Version: 0.5.4
Release: 0
Summary: Python parser for the CommonMark Markdown spec
License: BSD-3-Clause
Group: Development/Languages/Python
Url: https://pypi.python.org/pypi/CommonMark
Source: https://files.pythonhosted.org/packages/source/C/CommonMark/CommonMark-%{version}.tar.gz
BuildRequires: fdupes
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Provides: python3-commonmark
%description
Pure Python port of jgm’s stmd.js, a Markdown parser and renderer for the
CommonMark specification, using only native modules. Once both this project and
the CommonMark specification are stable we will release the first 1.0 version
and attempt to keep up to date with changes in stmd.js.
We are currently at the same development stage (actually a bit ahead because we
have implemented HTML entity conversion and href URL escaping) as stmd.js. Since
Python versions pre-3.4 use outdated (i.e. not HTML5 spec) entity conversion,
I’ve converted the 3.4 implementation into a single file, entitytrans.py which
so far seems to work (all tests pass on 2.7, 3.3, and 3.4).
%package doc
Summary: Documentation for CommonMark
%description doc
Documentation for Pure Python port of jgm’s stmd.js, a Markdown parser and
renderer for the CommonMark specification, using only native modules.
%prep
%setup -q -n CommonMark-%{version}
chmod -x LICENSE
chmod -x README.md
sed -i "s/\r//g" LICENSE
# find and remove unneeded shebangs
find CommonMark -name "*.py" | xargs sed -i '1 {/^#!/ d}'
# correct shebang
sed -i 's@^#!/usr/bin/python2@#!/usr/bin/python3@' bin/cmark.py
%build
python3 setup.py build
%install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
%fdupes %{buildroot}%{_prefix}
# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
mv -v %{buildroot}%{_bindir}/cmark.py %{buildroot}%{_bindir}/cmark.py-%{py3_ver}
ln -s -f %{_sysconfdir}/alternatives/cmark.py %{buildroot}%{_bindir}/cmark.py
# create a dummy target for /etc/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/cmark.py
%check
PYTHONPATH=$(pwd) python3 CommonMark/test/test-CommonMark.py -np
%post
%_sbindir/update-alternatives \
--install %{_bindir}/cmark.py cmark.py %{_bindir}/cmark.py-%{py3_ver} 30
%postun
%_sbindir/update-alternatives \
--remove cmark.py %{_bindir}/cmark.py-%{py3_ver}
%files
%defattr(-,root,root,-)
%doc README.md LICENSE
%ghost %{_bindir}/cmark.py
%{_bindir}/cmark.py-%{py3_ver}
%ghost %{_sysconfdir}/alternatives/*
%{python3_sitelib}/CommonMark/
%{python3_sitelib}/CommonMark-%{version}-py*.egg-info
%files doc
%defattr(-,root,root,-)
%doc README.md LICENSE docs/CommonMark.py.html
%changelog