File saltbundlepy-pyparsing.spec of Package saltbundlepy-pyparsing

#
# spec file for package saltbundlepy-pyparsing
#
# 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/
#


%{?!saltbundlepy_module:%define saltbundlepy_module() saltbundlepy-%{**}}
%define pythons saltbundlepy

# Disable python bytecompile for all distros
# It's called explicitly in the spec
%global __brp_python_bytecompile %{nil}

%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif

Name:           saltbundlepy-pyparsing%{psuffix}
Version:        3.0.9
Release:        0
Summary:        Grammar Parser Library for Python
License:        MIT AND GPL-2.0-or-later AND GPL-3.0-or-later
URL:            https://github.com/pyparsing/pyparsing/
Source:         https://files.pythonhosted.org/packages/source/p/pyparsing/pyparsing-%{version}.tar.gz
BuildRequires:  %{saltbundlepy_module base >= 3.10}
BuildRequires:  %{saltbundlepy_module flit-core}
BuildRequires:  fdupes
BuildRequires:  saltbundlepy-rpm-macros
BuildArch:      noarch
%if %{with test}
BuildRequires:  %{python_module pytest}
%endif
Requires:       saltbundlepy-base
%python_subpackages

%description
The pyparsing module is an alternative approach to creating and executing
simple grammars, vs. the traditional lex/yacc approach, or the use of regular
expressions. The pyparsing module provides a library of classes that client
code uses to construct the grammar directly in Python code.

%prep
%setup -q -n pyparsing-%{version}

%if !%{with test}
%build
%{python_expand # use pythonXX-base bundled pip as PEP517 frontend for flit-core for every flavor to install
mkdir -p build
$python -m venv build/buildenv --system-site-packages
}
# building pure wheel once is enough
export PATH=$PWD/build/buildenv/bin:$PATH
python -mpip wheel --verbose --progress-bar off \
  --disable-pip-version-check --use-pep517 --no-build-isolation \
  --no-deps --wheel-dir ./dist .

%install
export PATH=$PWD/build/buildenv/bin:$PATH
%{python_expand # install into every active flavored sitelib
python -mpip install \
  --verbose --progress-bar off --disable-pip-version-check \
  --root %{buildroot} \
  --ignore-installed --no-deps \
  --no-index --find-links ./dist pyparsing==%{version}
}
# fix venv install path
mv %{buildroot}/$PWD/build/buildenv %{buildroot}%{_prefix}
rm -r %{buildroot}/home
%{python_expand # Compile all explicitly
  find %{buildroot}%{$python_sitelib} -name '*.pyc' -delete
  $python -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}
  $python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}
  %fdupes %{buildroot}%{$python_sitelib}
}
%endif

%check
%if %{with test}
%pytest
%endif

%if ! %{with test}
%files %{python_files}
%license LICENSE
%doc CHANGES README.rst
%{python_sitelib}/pyparsing
%{python_sitelib}/pyparsing-%{version}*-info
%endif

%changelog
openSUSE Build Service is sponsored by