diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94127e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/hatch_vcs-0.2.0.tar.gz diff --git a/python-hatch-vcs.spec b/python-hatch-vcs.spec new file mode 100644 index 0000000..36d7b02 --- /dev/null +++ b/python-hatch-vcs.spec @@ -0,0 +1,99 @@ +# Let’s try to build this as early as we can, since it’s 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 + +# 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} +# The license file is installed in an unusual subdirectory. See +# https://bugzilla.redhat.com/show_bug.cgi?id=1985340. +%dir %{python3_sitelib}/hatch_vcs-%{version}.dist-info/license_files +%license %{python3_sitelib}/hatch_vcs-%{version}.dist-info/license_files/LICENSE.txt +%doc HISTORY.md +%doc README.md + + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..0338ba2 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (hatch_vcs-0.2.0.tar.gz) = 3eb0b04022d4801a982d90a3a0e34e59fcf7dd04c0c2db91c0306b4187ba466ac85ecbb80943a35f4a6a4912bc2ddf2633fab897e8820f5e1ee9d200147b5faf