#433 Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
Merged 5 months ago by churchyard. Opened 5 months ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros namespace_directories  into  rawhide

file modified
+7 -3
@@ -1,5 +1,9 @@ 

+ # This is a backward-compatible suffix used in all pyproject-rpm-macros directories

+ # For the main Python it's empty, for all others it's "-3.X"

+ %_pyproject_files_pkgversion %{expr:"%{python3_pkgversion}" != "3" ? "-%{python3_pkgversion}" : ""}

+ 

  # This is a directory where wheels are stored and installed from, absolute

- %_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir

+ %_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir%{_pyproject_files_pkgversion}

  

  # This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD

  # For proper debugsource packages, we create TMPDIR within PWD
@@ -8,12 +12,12 @@ 

  # This will be used in debugsource package paths (applies to extension modules only)

  # NB: pytest collects tests from here if not hidden

  #     https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs

- %_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir

+ %_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir%{_pyproject_files_pkgversion}

  

  # We prefix all created files with this value to make them unique

  # Ideally, we would put them into %%{buildsubdir}, but that value changes during the spec

  # The used value is similar to the one used to define the default %%buildroot

- %_pyproject_files_prefix %{name}-%{version}-%{release}.%{_arch}

+ %_pyproject_files_prefix %{name}-%{version}-%{release}.%{_arch}%{_pyproject_files_pkgversion}

  

  %pyproject_files %{_builddir}/%{_pyproject_files_prefix}-pyproject-files

  %_pyproject_modules %{_builddir}/%{_pyproject_files_prefix}-pyproject-modules

file modified
+7 -2
@@ -13,8 +13,8 @@ 

  #   Increment Y and reset Z when new macros or features are added

  #   Increment Z when this is a bugfix or a cosmetic change

  # Dropping support for EOL Fedoras is *not* considered a breaking change

- Version:        1.11.0

- Release:        3%{?dist}

+ Version:        1.12.0

+ Release:        1%{?dist}

  

  # Macro files

  Source001:      macros.pyproject
@@ -171,6 +171,11 @@ 

  

  

  %changelog

+ * Fri Jan 26 2024 Miro Hrončok <miro@hroncok.cz> - 1.12.0-1

+ - Namespace pyproject-rpm-macros generated text files with %%{python3_pkgversion}

+ - That way, a single-spec can be used to build packages for multiple Python versions

+ - Fixes: rhbz#2209055

+ 

  * Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.11.0-3

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

  

file modified
+3 -1
@@ -1,5 +1,7 @@ 

  #!/usr/bin/bash -eux

- . /etc/os-release

+ if [ -z "${VERSION_ID-}" ] && [ -z "${NAME-}" ]; then

+   . /etc/os-release

+ fi

  

  version=$(echo "${VERSION_ID}" | cut -d. -f1)

  arch="x86_64"

@@ -61,7 +61,10 @@ 

  

  %if %{with tests}

  %check

+ %if 0%{?fedora} < 40 && 0%{?rhel} < 10

+ # this version of httpbin is not compatible with werkzeug 3+

  %tox

+ %endif

  

  # Internal check for our macros

  # The runtime dependencies contain raven[flask], we assert we got them.

file modified
+69 -2
@@ -9,7 +9,6 @@ 

  URL:                https://github.com/timothycrosley/%{modname}

  Source0:            %{url}/archive/%{version}-2/%{modname}-%{version}-2.tar.gz

  BuildArch:          noarch

- BuildRequires:      python%{python3_pkgversion}-devel

  BuildRequires:      pyproject-rpm-macros

  

  %description
@@ -18,7 +17,7 @@ 

  with %%pyproject_save_files.

  

  This package also uses %%{python3_pkgversion} in name and has a very limited

- set of dependencies -- allows to set a different value for it in the CI.

+ set of dependencies -- allows to set a different value for it repeatedly.

  

  %package -n python%{python3_pkgversion}-%{modname}

  Summary:            %{summary}
@@ -26,6 +25,24 @@ 

  %description -n python%{python3_pkgversion}-%{modname}

  %{summary}.

  

+ %if 0%{?rhel} == 9

+ %global python3_pkgversion 3.11

+ %package -n python%{python3_pkgversion}-%{modname}

+ Summary:            %{summary}

+ 

+ %description -n python%{python3_pkgversion}-%{modname}

+ %{summary}.

+ 

+ %global python3_pkgversion 3.12

+ %package -n python%{python3_pkgversion}-%{modname}

+ Summary:            %{summary}

+ 

+ %description -n python%{python3_pkgversion}-%{modname}

+ %{summary}.

+ 

+ %global python3_pkgversion 3

+ %endif

+ 

  

  %prep

  %autosetup -n %{modname}-%{version}-2
@@ -33,13 +50,38 @@ 

  

  %generate_buildrequires

  %pyproject_buildrequires

+ %if 0%{?rhel} == 9

+ %global python3_pkgversion 3.11

+ %pyproject_buildrequires

+ %global python3_pkgversion 3.12

+ %pyproject_buildrequires

+ %global python3_pkgversion 3

+ %endif

+ 

  

  

  %build

  %pyproject_wheel

+ %if 0%{?rhel} == 9

+ %global python3_pkgversion 3.11

+ %pyproject_wheel

+ %global python3_pkgversion 3.12

+ %pyproject_wheel

+ %global python3_pkgversion 3

+ %endif

  

  

  %install

+ %if 0%{?rhel} == 9

+ %global python3_pkgversion 3.11

+ %pyproject_install

+ %pyproject_save_files -l isort

+ %global python3_pkgversion 3.12

+ %pyproject_install

+ %pyproject_save_files -l isort

+ %global python3_pkgversion 3

+ %endif

+ # we keep this one last so /usr/bin/isort is installed with python3 shebang

  %pyproject_install

  %pyproject_save_files -l isort

  
@@ -52,7 +94,32 @@ 

  # Internal check that executables are not present when +auto was not used with %%pyproject_save_files

  grep -F %{_bindir}/%{modname} %{pyproject_files} && exit 1 || true

  

+ %if 0%{?rhel} == 9

+ # Internal check that correct versions are in correct %%{pyproject_files}s

+ diff %{pyproject_files} <(grep -F python3.9/site-packages %{pyproject_files})

+ 

+ %global python3_pkgversion 3.11

+ test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}/

+ test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}-%{version}.dist-info/

+ diff %{pyproject_files} <(grep -F python3.11/site-packages %{pyproject_files})

+ 

+ %global python3_pkgversion 3.12

+ test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}/

+ test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}-%{version}.dist-info/

+ diff %{pyproject_files} <(grep -F python3.12/site-packages %{pyproject_files})

+ %global python3_pkgversion 3

+ %endif

+ 

  

  %files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}

  %doc README.rst *.md

  %{_bindir}/%{modname}

+ %if 0%{?rhel} == 9

+ %global python3_pkgversion 3.11

+ %files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}

+ %doc README.rst *.md

+ %global python3_pkgversion 3.12

+ %files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}

+ %doc README.rst *.md

+ %global python3_pkgversion 3

+ %endif

file modified
+3
@@ -97,6 +97,9 @@ 

      - config-settings-test:

          dir: .

          run: ./mocktest.sh config-settings-test

+     - isort_c9s:

+         dir: .

+         run: NAME="CentOS Stream" VERSION_ID=9 ./mocktest.sh python-isort

      required_packages:

      - mock

      - rpmdevtools

no initial comment

@orion, this is definitely something we'll want to backport to the epel8 branch

rebased onto ef19364

5 months ago

rebased onto 0e7ed50

5 months ago

rebased onto 9f3323b

5 months ago

rebased onto c62b472

5 months ago

Ready for review.

@gotmax23 Will you checkout the changes, or shall I ask somebody from @python-maint?

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/f510020ae113473c9c115a68ea540322

Sure, I can take a look at it.


%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
test -d %{buildroot}%{python3_sitelib}/%{modname}/
test -d %{buildroot}%{python3_sitelib}/%{modname}-%{version}.dist-info/
grep -F %{_bindir}/%{modname} %{pyproject_files} && exit 1 || true
[...]

I would also add tests to make sure that %{python3_sitelib} is set to the expected value after each %python3_pkgversion change, e.g.

%global python3_pkversion 3.11
test  "%{python3_sitelib}" "%{_usr}/lib/python3.11/site-packages"
[...]

We test that switching the values works properly in the python-rpm-macros test suite but probably a good idea to also check that here.

. /etc/os-release

You introduced trailing spaces here.


Other than that, this looks good to me. The changes include tests, a proper changelog entry and commit message, and are otherwise justified.

The trailing whitespace was supposed to be indentation but somehow ended up wrong. I added a fixup commit for both things.

1 new commit added

  • fixup! Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
5 months ago

That looks good. Thanks! I guess I'm still a bit hung up on that there's no tests checking that each instance of %pyproject_files expands to the proper thing or at least grepping the different %{pyproject_files} lists for the proper site-packages directories. Would you consider adding a test to the isort specfile that checks that?

Well, I guess the package build would fail with unpackaged files errors if all of the files weren't included in one of the subpackages, so maybe it's fine as it is.

1 new commit added

  • fixup! fixup! Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
5 months ago

4 new commits added

  • fixup! fixup! Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
  • fixup! Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
  • Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
  • CI: Skip httpbin %tox on F40+
5 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/ffd34b4e4855405c8e0cf6741b9ce3ec

This looks good to me now. Thanks! Would you like to open backport PRs or leave this just on rawhide and CentOS Stream for now?

2 new commits added

  • Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion}
  • CI: Skip httpbin %tox on F40+
5 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/bc2aa77ad06d43a4ae87abfcb9268dcf

I was about to merge when a second mass rebuild commit hit this repo. Will rebase.

rebased onto f987ccf

5 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/0c083e81d6a240fe9afc1e9aaaabfa22

Pull-Request has been merged by churchyard

5 months ago