File python-coconut.spec of Package python-coconut

#
# spec file for package python-coconut
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
# python36-ipython715 not compatible with jedi?
%define skip_python36 1
%define coconutcmd %{lua: local v=""
for part in rpm.expand("%{version}"):gmatch("%d+") do
  v = v .. part
  print("coconut-v" .. v .. " ")
  v = v .. "."
end}
%define coconutcmds() %{lua: for c in rpm.expand("%{**}"):gmatch("%S+") do
  print(c .. " " .. c .. "-run ")
end
}
%define coconutscripts %{coconutcmds %{coconutcmd} coconut-py3 coconut-release}
Name:           python-coconut
Version:        1.4.3
Release:        0
Summary:        A functional programming language that compiles to Python
License:        MIT
Group:          Development/Languages/Python
URL:            https://github.com/evhub/coconut
# Only the GitHub tarball contains the tests
Source:         https://github.com/evhub/coconut/archive/v%{version}.tar.gz#/coconut-%{version}-gh.tar.gz
BuildRequires:  %{python_module Pygments >= 2.3.1}
BuildRequires:  %{python_module dbm}
BuildRequires:  %{python_module prompt_toolkit >= 1}
BuildRequires:  %{python_module pyparsing >= 2.4.5}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module tk}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-Pygments >= 2.3.1
Requires:       python-dbm
Requires:       python-prompt_toolkit >= 1
Requires:       python-pyparsing >= 2.4.5
Requires:       python-tk
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     python-cPyparsing >= 2.4.5.0.1.1
Recommends:     python-ipykernel >= 5.1
Recommends:     python-ipython >= 6.5
Recommends:     python-jupyter >= 1
Recommends:     python-jupyter_console >= 5.2
Recommends:     python-mypy >= 0.761
Recommends:     python-psutil >= 5
Recommends:     python-requests >= 2
Recommends:     python-watchdog >= 0.9
Conflicts:      python2-coconut <= 1.4.0
BuildArch:      noarch
# SECTION test requirements
BuildRequires:  %{python_module cPyparsing >= 2.4.5.0.1.1}
BuildRequires:  %{python_module ipykernel >= 5.1}
BuildRequires:  %{python_module ipython >= 6.5}
BuildRequires:  %{python_module jupyter >= 1}
BuildRequires:  %{python_module jupyter_console >= 5.2}
BuildRequires:  %{python_module mypy >= 0.761}
BuildRequires:  %{python_module pexpect >= 4}
BuildRequires:  %{python_module psutil >= 5}
BuildRequires:  %{python_module pytest >= 3}
BuildRequires:  %{python_module requests >= 2}
BuildRequires:  %{python_module watchdog >= 0.9}
# /SECTION
%python_subpackages

%description
Coconut is a functional programming language that compiles to
Python. Since all valid Python is valid Coconut, using Coconut will
only extend and enhance what is already capable of in Python.

Coconut enhances the repertoire of Python programmers to include
tools for functional programming. Coconut code runs the same on any
Python version.

%prep
%setup -q -n coconut-%{version}
find . -type f -exec sed -i 's/\r$//' {} +
find . -name '*.py' -exec sed -i -e '/^#!\//, 1d' {} +

%build
%python_build

%install
%python_install
%{lua: for s in rpm.expand("%{coconutscripts}"):gmatch("%S+") do
print(rpm.expand("%python_clone -a %{buildroot}%{_bindir}/" .. s))
end}
%python_expand %fdupes %{buildroot}/%{$python_sitelib}/

%check
%{python_expand # link to correct flavor alternatives of own and installed commands
mkdir -p build/testbin
for c in %{buildroot}%{_bindir}/coconut*-%{$python_bin_suffix} %{_bindir}/*-%{$python_bin_suffix}; do
  cb=$(basename $c)
  ln -s $c build/testbin/${cb%%%%-%{$python_bin_suffix}}
done
}
export PATH=$PWD/build/testbin:%{buildroot}%{_bindir}:$PATH
%pytest -s -k "not (TestExternal)"

%post
%python_install_alternative %{coconutscripts}

%postun
%python_uninstall_alternative coconut

%files %{python_files}
%doc README.rst CONTRIBUTING.md DOCS.md FAQ.md HELP.md
%license LICENSE.txt
%{expand:%(for s in %{coconutscripts}; do echo %%python_alternative %%{_bindir}/$s; done)}
%{_bindir}/coconut-py%{python_bin_suffix}
%{_bindir}/coconut-py%{python_bin_suffix}-run
%{python_sitelib}/coconut/
%{python_sitelib}/coconut-%{version}-py*.egg-info

%changelog
openSUSE Build Service is sponsored by