%global commit 66b1338ccd0f1b6e50711e86a22718c7c8474516 %global snapdate 20221026 # Match the results of running python3 -m build in a git checkout: %global dev_n 27 Name: python-flexparser # Pre-release snapshot: see https://pagure.io/packaging-committee/issue/1210 # # Plans for releasing 0.2? # https://github.com/hgrecco/flexparser/issues/5 Version: 0.2~%{snapdate}git%(c="%{commit}"; echo "${c:0:7}") Release: %autorelease Summary: Parsing made fun … using typing %global baseversion %(echo '%{version}' | cut -d '~' -f 1) %global py_version_suffix .dev%{dev_n}+g%(c="%{commit}"; echo "${c:0:7}") %global py_version %{baseversion}%{py_version_suffix} License: BSD-3-Clause URL: https://github.com/hgrecco/flexparser Source: %{url}/archive/%{commit}/flexparser-%{commit}.tar.gz BuildArch: noarch BuildRequires: python3-devel %global common_description %{expand: The idea is quite simple. You write a class for every type of content (called here ParsedStatement) you need to parse. Each class should have a from_string constructor. We used extensively the typing module to make the output structure easy to use and less error prone.} %description %{common_description} %package -n python3-flexparser Summary: %{summary} %description -n python3-flexparser %{common_description} %package doc Summary: Documentation and examples for %{name} %description doc %{summary}. %prep %autosetup -n flexparser-%{commit} # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters sed -r -i 's/^([[:blank:]]*)("pytest-cov")/\1# \2/' pyproject.toml %generate_buildrequires export SETUPTOOLS_SCM_PRETEND_VERSION='%{py_version}' %pyproject_buildrequires -x test %build export SETUPTOOLS_SCM_PRETEND_VERSION='%{py_version}' %pyproject_wheel %install %pyproject_install %pyproject_save_files flexparser # Upstream probably doesn’t want to install flexparser.testsuite, but we don’t # know how to suggest a fix given “[BUG] options.packages.find.exclude not # taking effect when include_package_data = True”, # https://github.com/pypa/setuptools/issues/3260. # # Still, we don’t want to install the test suite, so we just remove the files # manually for now. rm -rvf '%{buildroot}%{python3_sitelib}/flexparser/testsuite' sed -r -i '/\/flexparser\/testsuite/d' %{pyproject_files} %check %pytest %files -n python3-flexparser -f %{pyproject_files} # pyproject_files handles AUTHORS and LICENSE; verify with “rpm -qL -p …” %files doc %doc README.rst %doc CHANGES %doc examples/ %changelog %autochangelog