#418 [F37] Add %_pyproject_check_import_allow_no_modules
Merged 8 months ago by churchyard. Opened 8 months ago by ksurma.
rpms/ ksurma/pyproject-rpm-macros allow-empty-macro  into  f37

file modified
+6
@@ -342,6 +342,12 @@ 

  additional qualified module names to check, useful for example if some modules are installed manually.

  Note that filtering by `-t`/`-e` also applies to the positional arguments.

  

+ Another macro, `%_pyproject_check_import_allow_no_modules` allows to pass the import check,

+ even if no Python modules are detected in the package.

+ This may be a valid case for packages containing e.g. typing stubs.

+ Don't use this macro in Fedora packages.

+ It's only intended to be used in automated build environments such as Copr.

+ 

  

  Generating Extras subpackages

  -----------------------------

file modified
+8
@@ -133,6 +133,14 @@ 

  }

  

  

+ %_pyproject_check_import_allow_no_modules(e:t) \

+ if [ -z "$(cat %{_pyproject_modules})" ]; then\

+   echo "No modules to check found, exiting check"\

+ else\

+   %pyproject_check_import %{?**}\

+ fi

+ 

+ 

  %default_toxenv py%{python3_version_nodots}

  %toxenv %{default_toxenv}

  

file modified
+6 -3
@@ -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.9.0

- Release:        2%{?dist}

+ Version:        1.10.0

+ Release:        1%{?dist}

  

  # Macro files

  Source001:      macros.pyproject
@@ -161,6 +161,9 @@ 

  

  

  %changelog

+ * Wed Sep 13 2023 Karolina Surma <ksurma@redhat.com> - 1.10.0-1

+ - Add %%_pyproject_check_import_allow_no_modules for automated environments

+ 

  * Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0-2

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

  
@@ -212,7 +215,7 @@ 

  - Use %%py3_test_envvars in %%tox when available

  

  * Mon Sep 19 2022 Python Maint <python-maint@redhat.com> - 1.4.0-1

- - %%pyproject_save_files: Support License-Files installed into the *Root License Directory* from PEP 369

+ - %%pyproject_save_files: Support License-Files installed into the *Root License Directory* from PEP 639

  - Fixes: rhbz#2127946

  - %%pyproject_check_import: Import only the modules whose top-level names

    match any of the globs provided to %%pyproject_save_files

file modified
+1 -1
@@ -345,7 +345,7 @@ 

      }

  

      license_files = metadata.get_all('License-File')

-     license_directory = distinfo / 'licenses'  # See PEP 369 "Root License Directory"

+     license_directory = distinfo / 'licenses'  # See PEP 639 "Root License Directory"

      # setuptools was the first known build backend to implement License-File.

      # Unfortunately they don't put licenses to the license directory (yet):

      #     https://github.com/pypa/setuptools/issues/3596

file modified
+31 -2
@@ -12,7 +12,10 @@ 

  

  

  %global _description %{expand:

- Test that manpages are correctly processed by %%pyproject_save_files '*' +auto.}

+ Test that manpages are correctly processed by %%%%%%%%pyproject_save_files '*' +auto.

+ Run %%%%%%%%_pyproject_check_import_allow_no_modules twice

+ - exclude all modules and test the check still passes thanks to -M option

+ - regression test: test that check imports all modules even if -M option is set}

  

  

  %description %_description
@@ -41,10 +44,36 @@ 

  

  

  %check

+ # Internal check for our macros, assert the behavior of the import check macros

+ # Both of the macros should succeed

  %pyproject_check_import

+ %_pyproject_check_import_allow_no_modules

+ (%{pyproject_check_import}) 2>pyproject_check_import.stderr

+ (%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr

+ 

+ # Modules were found, stderrs should include getmac.getmac

+ grep '^Check import: getmac\.getmac$' pyproject_check_import.stderr

+ grep '^Check import: getmac\.getmac$' _pyproject_check_import_allow_no_modules.stderr

+ 

+ # Now let's pretend no modules were found at all

+ echo -e '' > %{_pyproject_modules}

+ 

+ # This should fail

+ (%{pyproject_check_import}) && exit 1 || true

+ 

+ # This should succeed and say something about no modules found

+ %{_pyproject_check_import_allow_no_modules}

+ (%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr

+ grep '\bNo modules to check found\b' _pyproject_check_import_allow_no_modules.stderr

+ 

+ # We want to ensure the rest of the %%check section is still executed

+ # (To avoid a temptation to call `exit 0` from %%_pyproject_check_import_allow_no_modules)

+ # We'll touch a marker file here and assert its presence in %%files

+ touch %{buildroot}/check-completed-entirely

+ 

  # Internal check for our macros, assert there is a manpage:

  test -f %{buildroot}%{_mandir}/man1/getmac.1*

  

  

  %files -n python3-getmac -f %{pyproject_files}

- 

+ /check-completed-entirely

no initial comment

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

Pull-Request has been merged by churchyard

8 months ago