diff --git a/python-rpmautospec.spec b/python-rpmautospec.spec index 7c18f93..a0ed880 100644 --- a/python-rpmautospec.spec +++ b/python-rpmautospec.spec @@ -1,8 +1,8 @@ ## START: Set by rpmautospec -## (rpmautospec version 0.7.2) +## (rpmautospec version 0.7.3) ## RPMAUTOSPEC: autorelease, autochangelog %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: - release_number = 1; + release_number = 11; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}.alma.1 @@ -20,13 +20,22 @@ %bcond bootstrap 0 %bcond tests 1 - -# While bootstrapping, ignore manpages -%bcond manpages %{without bootstrap} +# Which packages to mask and which tests to do with native wrappers +%global wrapped_pkgs pygit2 rpm +%global wrappers_relevant_tests tests/rpmautospec/test_pkg_history.py tests/rpmautospec/subcommands/ # The pytest-xdist package is not available when bootstrapping or on RHEL %bcond xdist %[%{without bootstrap} && %{undefined rhel}] +# Whether to build only the minimal package for RHEL buildroot +%bcond minimal %[%{defined rhel} && %{undefined epel}] + +# While bootstrapping or building the minimal package, ignore manpages +%bcond manpages %[%{without bootstrap} && %{without minimal}] + +# While building the minimal package, ignore shell completions +%bcond completions %{without minimal} + # Package the placeholder rpm-macros (moved to redhat-rpm-config in F40) %if ! (0%{?fedora} >= 40 || 0%{?rhel} >= 10) %bcond rpmmacropkg 1 @@ -34,26 +43,25 @@ %bcond rpmmacropkg 0 %endif -%if %{with bootstrap} -%bcond poetry 0 +# Appease old versions of hatchling +%if ! 0%{?fedora}%{?rhel} || 0%{?fedora} >= 41 || 0%{?rhel} >= 10 +%bcond old_hatchling 0 %else -%if ! 0%{?fedora}%{?rhel} || 0%{?fedora} || 0%{?epel} >= 9 -%bcond poetry 1 -# Appease old Poetry versions (<1.2.0a2) -%if ! 0%{?fedora}%{?rhel} || 0%{?fedora} >= 38 || 0%{?rhel} >= 10 -%bcond old_poetry 0 -%else -%bcond old_poetry 1 -%endif -%else -%bcond poetry 0 -%endif +%bcond old_hatchling 1 %endif +# Although this supports a range of libgit2 and librpm versions upstream, +# we want to ensure newer versions don’t accidentally break all packages using this. +# Hence we artificially restrict the Required version to what was tested during the build. +# When libgit2/librpm soname is bumped, this package needs to be rebuilt (and tested). +%define libgit2_lower_bound 1.7 +%define libgit2_upper_bound 1.10 +%define libgit2_requires %(rpm -q --provides libgit2 | grep '^libgit2\.so\.' | sed 's/()(64bit)$//' | head -n 1) + %global srcname rpmautospec Name: python-%{srcname} -Version: 0.7.3 +Version: 0.8.1 %if %{with bootstrap} Release: 0%{?dist} @@ -61,9 +69,10 @@ Release: 0%{?dist} Release: %autorelease %endif Summary: Package and CLI tool to generate release fields and changelogs -License: MIT +License: MIT AND GPL-2.0-only WITH GCC-exception-2.0 AND (MIT OR GPL-2.0-or-later WITH GCC-exception-2.0) URL: https://github.com/fedora-infra/%{srcname} -Source0: https://github.com/fedora-infra/%{srcname}/releases/download/%{version}/%{srcname}-%{version}.tar.gz +Source0: %{pypi_source %{srcname}} +Source1: rpmautospec.in Patch1: 0001-Added-AlmaLinux-change-identifier-0.7.3.patch @@ -72,10 +81,12 @@ Patch1: 0001-Added-AlmaLinux-change-identifier-0.7.3.patch %endif BuildArch: noarch +BuildRequires: findutils BuildRequires: git # the langpacks are needed for tests BuildRequires: glibc-langpack-de BuildRequires: glibc-langpack-en + BuildRequires: python3-devel >= 3.9.0 # Needed to build man pages %if %{with manpages} @@ -85,39 +96,57 @@ BuildRequires: python3dist(click-man) %if %{with tests} # The dependencies needed for testing don’t get auto-generated. BuildRequires: python3dist(pytest) +BuildRequires: python3dist(pyyaml) %if %{with xdist} BuildRequires: python3dist(pytest-xdist) %endif %endif -BuildRequires: python3dist(pyyaml) BuildRequires: sed -%if %{without poetry} -BuildRequires: python3dist(babel) -BuildRequires: python3dist(click) -BuildRequires: python3dist(click-plugins) -BuildRequires: python3dist(pygit2) -BuildRequires: python3dist(rpm) -BuildRequires: python3dist(rpmautospec-core) -BuildRequires: python3dist(setuptools) -%{?python_provide:%python_provide python3-%{srcname}} -%endif +BuildRequires: (libgit2 >= %libgit2_lower_bound with libgit2 < %libgit2_upper_bound) +BuildRequires: rpm-libs +BuildRequires: rpm-build-libs %global _description %{expand: A package and CLI tool to generate RPM release fields and changelogs.} %description %_description +%if %{without minimal} %package -n python3-%{srcname} Summary: %{summary} %{?python_provide:%python_provide python3-%{srcname}} %description -n python3-%{srcname} %_description +%pyproject_extras_subpkg -n python3-%{srcname} click +%pyproject_extras_subpkg -n python3-%{srcname} pygit2 +%pyproject_extras_subpkg -n python3-%{srcname} rpm +%pyproject_extras_subpkg -n python3-%{srcname} all +%endif + %package -n %{srcname} -Summary: CLI tool for generating RPM releases and changelogs -Requires: python3-%{srcname} = %{version}-%{release} +Summary: CLI tool for generating RPM releases and changelogs + +Provides: bundled(python3dist(rpmautospec)) = %{version} +Provides: bundled(python3dist(rpmautospec-core)) = %((rpm -q python3-rpmautospec-core --qf '%%{version}\n' || echo 0) | tail -n1) + +%if "%libgit2_requires" != "" +Requires: (%{libgit2_requires}()(64bit) or %{libgit2_requires}) +Suggests: %{libgit2_requires}()(64bit) +%else +Requires: this-is-broken-libgit2-missing-during-build +%endif +Requires: rpm-libs +Requires: rpm-build-libs + +%if %{without minimal} +Recommends: python3-%{srcname} = %{version}-%{release} +Recommends: python3-%{srcname}+click = %{version}-%{release} +Recommends: python3-%{srcname}+pygit2 = %{version}-%{release} +Recommends: python3-%{srcname}+rpm = %{version}-%{release} +%endif %description -n %{srcname} CLI tool for generating RPM releases and changelogs @@ -133,44 +162,23 @@ enabled packages locally. %endif %generate_buildrequires -%if %{with poetry} -%pyproject_buildrequires -%endif +%pyproject_buildrequires %{!?with_minimal:-x all} %prep %autosetup -n %{srcname}-%{version} -p1 -%if %{without poetry} -sed -i -e 's/\[project\]/#\&/g' pyproject.toml -%endif -%if %{with old_poetry} -sed -i \ - -e 's/\[tool\.poetry\.group\.dev\.dependencies\]/[tool.poetry.dev-dependencies]/g' \ - pyproject.toml +%if %{with old_hatchling} +sed -i -e 's/license-files = \(\[.*\]\)/license-files = {globs = \1}/' pyproject.toml %endif # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters sed -i -e '/pytest-cov/d; /addopts.*--cov/d' pyproject.toml %build -%if %{with poetry} %pyproject_wheel -%else -%py3_build -%endif %install -%if %{with poetry} %pyproject_install %pyproject_save_files %{srcname} -# Work around poetry not listing license files as such in package metadata. -sed -i -e 's|^\(.*/LICENSE\)|%%license \1|g' %{pyproject_files} -%else -%py3_install -cat << EOF > %{pyproject_files} -%{python3_sitelib}/%{srcname}/ -%{python3_sitelib}/*.egg-info/ -EOF -%endif %if %{with manpages} # Man pages @@ -182,9 +190,10 @@ install -m644 man/*.1 %{buildroot}%{_mandir}/man1 # RPM macros %if %{with rpmmacropkg} mkdir -p %{buildroot}%{rpmmacrodir} -install -m 644 rpm/macros.d/macros.rpmautospec %{buildroot}%{rpmmacrodir}/ +install -m 644 rpm_macros.d/macros.rpmautospec %{buildroot}%{rpmmacrodir}/ %endif +%if %{with completions} # Shell completion for shell_path in \ bash:%{bash_completions_dir}/rpmautospec \ @@ -202,36 +211,88 @@ for shell_path in \ "import sys; sys.argv[0] = 'rpmautospec'; from rpmautospec.cli import cli; sys.exit(cli())" \ > "%{buildroot}${path}" done +%endif + +# Fill in the real version for the fallback method +touch -r %{buildroot}%{python3_sitelib}/rpmautospec/version.py timestamp +sed -i -e 's|0\.0\.0|%{version}|g' %{buildroot}%{python3_sitelib}/rpmautospec/version.py +touch -r timestamp %{buildroot}%{python3_sitelib}/rpmautospec/version.py + +# Install bootstrapping copies of rpmautospec, rpmautospec_core packages +mkdir -p %{buildroot}%{_datadir}/rpmautospec-fallback +cp -r %{python3_sitelib}/rpmautospec_core %{buildroot}%{_datadir}/rpmautospec-fallback/ +cp -r %{buildroot}%{python3_sitelib}/rpmautospec %{buildroot}%{_datadir}/rpmautospec-fallback/ +find %{buildroot}%{_datadir}/rpmautospec-fallback \ + -depth -type d -a -name __pycache__ -exec rm -r {} \; + +# Override the standard executable with a custom one that knows how to fall back +sed -e 's|@PYTHON3@|%{python3} -%{py3_shebang_flags}|g; s|@DATADIR@|%{_datadir}|g' \ + < %{S:1} \ + > %{buildroot}%{_bindir}/rpmautospec +chmod 755 %{buildroot}%{_bindir}/rpmautospec +touch -r %{S:1} %{buildroot}%{_bindir}/rpmautospec %check # Always run the import checks, even when other tests are disabled -%if %{with poetry} -%pyproject_check_import -%else -%py3_check_import rpmautospec rpmautospec.cli -%endif +%pyproject_check_import %{?with_minimal:-e '*click*'} %if %{with tests} -%pytest -v \ +%if %{without minimal} +%pytest \ %if %{with xdist} --numprocesses=auto %endif %endif +%if ! 0%{?rhel} || 0%{?rhel} >= 10 +# And redo tests that are relevant for native bindings, but with the direct native wrappers, but not +# on EL <= 9 because the tests somehow run out of file descriptors. + +# Poison the official package names… +mkdir -p poison-pill +for mod in %wrapped_pkgs; do + echo "raise ImportError" > "poison-pill/${mod}.py" + if PYTHONPATH="$PWD/poison-pill:$PYTHONPATH" %__python3 -c "import ${mod}" 2>/dev/null; then + echo "Failed to poison-pill ${mod}!" >&2 + exit 1 + fi +done + +%py3_test_envvars \ +PYTHONPATH="$PWD/poison-pill:$PYTHONPATH" \ +%__pytest \ +%if %{with xdist} +--numprocesses=auto \ +%endif +%wrappers_relevant_tests + +%endif +%endif + +%if %{without minimal} %files -n python3-%{srcname} -f %{pyproject_files} %doc README.rst +%endif %files -n %{srcname} %{_bindir}/rpmautospec +%{_datadir}/rpmautospec-fallback + %if %{with manpages} %{_mandir}/man1/rpmautospec*.1* %endif +%if %{with completions} %dir %{bash_completions_dir} %{bash_completions_dir}/rpmautospec %dir %{fish_completions_dir} %{fish_completions_dir}/rpmautospec.fish %dir %{zsh_completions_dir} %{zsh_completions_dir}/_rpmautospec +%endif +%if %{with minimal} +%license licenses/* +%exclude %{python3_sitelib} +%endif %if %{with rpmmacropkg} %files -n rpmautospec-rpm-macros @@ -240,9 +301,45 @@ done %changelog ## START: Generated by rpmautospec -* Thu Apr 17 2025 Eduard Abdullin - 0.7.3-1 +* Mon Jun 16 2025 Eduard Abdullin - 0.8.1-8.alma.1 - AlmaLinux change: Add AlmaLinux OS change identifier +* Wed Apr 16 2025 Miro Hrončok - 0.8.1-8 +- Generate BuildRequires for extras, drop unused click-plugins dependency + +* Wed Apr 16 2025 Miro Hrončok - 0.8.1-7 +- On RHEL, only build the minimal package + +* Wed Apr 16 2025 Miro Hrončok - 0.8.1-6 +- Make sure only one libgit2 package is BuildRequired during the build + +* Tue Apr 15 2025 Miro Hrončok - 0.8.1-5 +- Add bundled() provides for bundled self and rpmautospec-core + +* Tue Apr 15 2025 Yaakov Selkowitz - 0.8.1-4 +- Drop pyproject_macros conditional + +* Mon Apr 14 2025 Nils Philippsen - 0.8.1-2 +- Pin libgit2 to soname version tested during build + +* Tue Apr 08 2025 Nils Philippsen - 0.8.1-1 +- Update to 0.8.1 + +* Tue Apr 08 2025 Miro Hrončok - 0.8.0-4 +- Stop trying to Require libraries with %%_isa + +* Tue Apr 08 2025 Miro Hrončok - 0.8.0-3 +- Add missing flags to /usr/bin/rpmautospec shebang + +* Tue Apr 08 2025 Nils Philippsen - 0.8.0-1 +- Update to 0.8.0 +- Update license +- Make using click, pygit2, rpm Python packages optional and enable + fallbacks + +* Sat Jan 18 2025 Fedora Release Engineering - 0.7.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + * Fri Oct 11 2024 Nils Philippsen - 0.7.3-1 - Update to 0.7.3 diff --git a/rpmautospec.in b/rpmautospec.in new file mode 100755 index 0000000..bd44bc3 --- /dev/null +++ b/rpmautospec.in @@ -0,0 +1,12 @@ +#!@PYTHON3@ + +import sys + +try: + from rpmautospec import cli +except ImportError: + sys.path.insert(0, "@DATADIR@/rpmautospec-fallback") + sys.dont_write_bytecode = True + from rpmautospec import cli + +sys.exit(cli.cli()) diff --git a/sources b/sources index cf7db6c..d37e8d2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e1d88a616228dad805b1bdec5a74d3287057b997 rpmautospec-0.7.3.tar.gz +6734e148a6eb2b18742570a008e13a2eb70df976 rpmautospec-0.8.1.tar.gz