You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python-hatch-vcs/python-hatch-vcs.spec

99 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Lets try to build this as early as we can, since its a dependency for
# python-userpath.
%bcond_with bootstrap
%if %{without bootstrap}
%bcond_without tests
%else
%bcond_with tests
%endif
Name: python-hatch-vcs
Version: 0.2.0
Release: %autorelease
Summary: Hatch plugin for versioning with your preferred VCS
License: MIT
URL: https://github.com/ofek/hatch-vcs
Source0: %{pypi_source hatch_vcs}
BuildArch: noarch
BuildRequires: python3-devel
# RHBZ#1985340
BuildRequires: pyproject-rpm-macros >= 1.1.0
# For script in %%generate_buildrequires:
BuildRequires: python3dist(tomli)
%if %{with tests}
BuildRequires: python3dist(pytest)
BuildRequires: git-core
%endif
%global common_description %{expand: \
This provides a plugin for Hatch that uses your preferred version control
system (like Git) to determine project versions.}
%description
%{common_description}
%package -n python3-hatch-vcs
Summary: %{summary}
%description -n python3-hatch-vcs
%{common_description}
%prep
%autosetup -n hatch_vcs-%{version}
%generate_buildrequires
# Cannot use %%pyproject_buildrequires -r (the default) with hatchling:
# “ValueError: build backend cannot provide build metadata (incl. runtime
# requirements) before build”. See: https://github.com/ofek/hatch/issues/128
#
# We work around this by writing the dependencies from pyproject.toml into a
# text file. This may not be necessary in the future; see:
# https://bugzilla.redhat.com/show_bug.cgi?id=2076994
'%{python3}' <<'EOF'
from tomli import load
def emit(tomlbase, reqtag, getdeps):
with open(f'{tomlbase}.toml', 'rb') as cfgfile:
deps = getdeps(load(cfgfile))
with open(f'requirements.{reqtag}.txt', 'w') as reqfile:
reqfile.writelines(f'{dep}\n' for dep in deps)
emit('pyproject', 'pyproject', lambda cfg: cfg['project']['dependencies'])
EOF
%pyproject_buildrequires -R requirements.pyproject.txt
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files hatch_vcs
%check
%if %{with tests}
%pytest
%else
%pyproject_check_import
%endif
%files -n python3-hatch-vcs -f %{pyproject_files}
%license LICENSE.txt
%doc HISTORY.md
%doc README.md
%changelog
%autochangelog