#35 Add -f, -t, -e options to %%py_check_import macros
Merged 2 years ago by churchyard. Opened 2 years ago by ksurma.
rpms/ ksurma/epel-rpm-macros check-import  into  epel8

file modified
+4 -1
@@ -1,6 +1,6 @@ 

  Name:           epel-rpm-macros

  Version:        8

- Release:        25

+ Release:        26

  Summary:        Extra Packages for Enterprise Linux RPM macros

  

  Group:          System Environment/Base
@@ -72,6 +72,9 @@ 

  

  

  %changelog

+ * Wed Oct 27 2021 Karolina Surma <ksurma@redhat.com> - 8-26

+ - Add -t, -f, -e options to %%py_check_import which emit warning when used

+ 

  * Tue Oct 26 2021 Tomas Orsava <torsava@redhat.com> - 8-25

  - Define a new macros %%python_wheel_dir and %%python_wheel_pkg_prefix

  

file modified
+12 -3
@@ -86,7 +86,10 @@ 

  # try to import the given Python module(s).

  # Useful as a smoke test in %%check when running tests is not feasible.

  # Use spaces or commas as separators.

- %py_check_import() %{expand:\\\

+ %py_check_import(e:tf:) %{expand:\\\

+   %{-e:echo 'WARNING: The -e option of %%%%py_check_import is not currently supported on EPEL.' >&2}

+   %{-t:echo 'WARNING: The -t option of %%%%py_check_import is not currently supported on EPEL.' >&2}

+   %{-f:echo 'WARNING: The -f option of %%%%py_check_import is not currently supported on EPEL.' >&2}

    (cd %{_topdir} &&\\\

    PATH="%{buildroot}%{_bindir}:$PATH"\\\

    PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
@@ -94,7 +97,10 @@ 

    %{__python} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}"

    )

  }

- %py2_check_import() %{expand:\\\

+ %py2_check_import(e:tf:) %{expand:\\\

+   %{-e:echo 'WARNING: The -e option of %%%%py2_check_import is not currently supported on EPEL.' >&2}

+   %{-t:echo 'WARNING: The -t option of %%%%py2_check_import is not currently supported on EPEL.' >&2}

+   %{-f:echo 'WARNING: The -f option of %%%%py2_check_import is not currently supported on EPEL.' >&2}

    (cd %{_topdir} &&\\\

    PATH="%{buildroot}%{_bindir}:$PATH"\\\

    PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python2_sitearch}:%{buildroot}%{python2_sitelib}}"\\\
@@ -102,7 +108,10 @@ 

    %{__python2} -c "import %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)}"

    )

  }

- %py3_check_import() %{expand:\\\

+ %py3_check_import(e:tf:) %{expand:\\\

+   %{-e:echo 'WARNING: The -e option of %%%%py3_check_import is not currently supported on EPEL.' >&2}

+   %{-t:echo 'WARNING: The -t option of %%%%py3_check_import is not currently supported on EPEL.' >&2}

+   %{-f:echo 'WARNING: The -f option of %%%%py3_check_import is not currently supported on EPEL.' >&2}

    (cd %{_topdir} &&\\\

    PATH="%{buildroot}%{_bindir}:$PATH"\\\

    PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\

The options were introduced to python-rpm-macros in Fedora.
Adding them to EPEL prevents failures when processing Fedora specfiles.
The actual functionality was not backported to EPEL.
When used, the options emit warning.


I checked that macros build and ran rpm --eval on all options of changed macros in EPEL mock, it looks like it evaluates just right, eg.:

<mock-chroot> sh-4.4# rpm --eval '%py3_check_import -t'
\
  \
  echo 'WARNING: The -t option of %py3_check_import currently is not supported on EPEL.' >&2\
  \
  (cd /builddir/build &&\
  PATH="/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr/bin:$PATH"\
  PYTHONPATH="${PYTHONPATH:-/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr/lib64/python3.6/site-packages:/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr/lib/python3.6/site-packages}"\
  PYTHONDONTWRITEBYTECODE=1\
  /usr/libexec/platform-python -c "import "
  )
<mock-chroot> sh-4.4# rpm --eval '%py2_check_import -f foo'
sh: /usr/bin/python2: No such file or directory
sh: /usr/bin/python2: No such file or directory
\
  \
  \
  echo 'WARNING: The -f option of %py2_check_import currently is not supported on EPEL.' >&2\
  (cd /builddir/build &&\
  PATH="/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr/bin:$PATH"\
  PYTHONPATH="${PYTHONPATH:-/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64:/builddir/build/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64}"\
  PYTHONDONTWRITEBYTECODE=1\
  /usr/bin/python2 -c "import "
  )

Build succeeded.

rebased onto d67cedfa793ee2119aa341b473a8122c06781990

2 years ago

Build succeeded.

Build succeeded.

%check
%py3_check_import packaging

Runs as:

Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.dhvmuw
+ umask 022
+ cd /builddir/build/BUILD
+ cd packaging-16.8
+ cd /builddir/build
+ PATH=/builddir/build/BUILDROOT/python-packaging-16.8-9.el8.x86_64/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
+ PYTHONPATH=/builddir/build/BUILDROOT/python-packaging-16.8-9.el8.x86_64/usr/lib64/python3.6/site-packages:/builddir/build/BUILDROOT/python-packaging-16.8-9.el8.x86_64/usr/lib/python3.6/site-packages
+ PYTHONDONTWRITEBYTECODE=1
+ /usr/bin/python3.6 -c 'import packaging'
+ exit 0

%check
%py3_check_import packaging -e 'p*'

Runs as:

Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.O4V6Gw
+ umask 022
+ cd /builddir/build/BUILD
+ cd packaging-16.8


RPM build errors:
/var/tmp/rpm-tmp.O4V6Gw: line 38: syntax error near unexpected token `('

I believe that the warnings must not have the backslashes after them, or the command is evaluated by Shell as if on one line:

$ echo WARNING >&2 (cd ~; echo THIS_DOESNT_WORK)
bash: syntax error near unexpected token `('

rebased onto ef8d241f487b89e6cd2ae5733746859a7a2fbc7d

2 years ago

Build succeeded.

This works now. We are discussing the best language for the warning...

rebased onto 4ce1a69

2 years ago

Pull-Request has been merged by churchyard

2 years ago

Build succeeded.