Add %_pyproject_check_import_allow_no_modules
Macro which allows to pass the import check even if no Python modules are detected in the package. Only to be used in the automated environments. Co-authored-by: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
parent
a39d658f0f
commit
97a7574518
@ -342,6 +342,12 @@ The `%pyproject_check_import` macro also accepts positional arguments with
|
|||||||
additional qualified module names to check, useful for example if some modules are installed manually.
|
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.
|
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
|
Generating Extras subpackages
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
@ -133,6 +133,14 @@ fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%_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}
|
%default_toxenv py%{python3_version_nodots}
|
||||||
%toxenv %{default_toxenv}
|
%toxenv %{default_toxenv}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ License: MIT
|
|||||||
# Increment Y and reset Z when new macros or features are added
|
# Increment Y and reset Z when new macros or features are added
|
||||||
# Increment Z when this is a bugfix or a cosmetic change
|
# Increment Z when this is a bugfix or a cosmetic change
|
||||||
# Dropping support for EOL Fedoras is *not* considered a breaking change
|
# Dropping support for EOL Fedoras is *not* considered a breaking change
|
||||||
Version: 1.9.0
|
Version: 1.10.0
|
||||||
Release: 2%{?dist}
|
Release: 1%{?dist}
|
||||||
|
|
||||||
# Macro files
|
# Macro files
|
||||||
Source001: macros.pyproject
|
Source001: macros.pyproject
|
||||||
@ -161,6 +161,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%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
|
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.0-2
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||||
|
|
||||||
|
@ -12,7 +12,10 @@ BuildRequires: pyproject-rpm-macros
|
|||||||
|
|
||||||
|
|
||||||
%global _description %{expand:
|
%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
|
%description %_description
|
||||||
@ -41,10 +44,36 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%check
|
%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
|
||||||
|
%_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:
|
# Internal check for our macros, assert there is a manpage:
|
||||||
test -f %{buildroot}%{_mandir}/man1/getmac.1*
|
test -f %{buildroot}%{_mandir}/man1/getmac.1*
|
||||||
|
|
||||||
|
|
||||||
%files -n python3-getmac -f %{pyproject_files}
|
%files -n python3-getmac -f %{pyproject_files}
|
||||||
|
/check-completed-entirely
|
||||||
|
Loading…
Reference in New Issue
Block a user