python3.12/tests/pythontest.spec
Miro Hrončok dbde5b7165 CI: Install python3-devel specially to avoid a failure
The available python3-devel version is lower than what we already have as platform-python.

We are testing Python 3.12 here, so the exact version of Python 3.6 does not matter to us.

We also avoid a dependency on python3 and let the magic happen.

This avoids:

    Error:
     Problem 1: package python3-devel-3.6.8-59.el8.x86_64 from @System requires platform-python = 3.6.8-59.el8, but none of the providers can be installed
      - cannot install both platform-python-3.6.8-71.el8_10.x86_64 from rhel-BaseOS and platform-python-3.6.8-59.el8.x86_64 from @System
      - cannot install both platform-python-3.6.8-59.el8.x86_64 from rhel-buildroot and platform-python-3.6.8-71.el8_10.x86_64 from rhel-BaseOS
      - cannot install both platform-python-3.6.8-59.el8.x86_64 from testing-farm-tag-repository-mainline and platform-python-3.6.8-71.el8_10.x86_64 from rhel-BaseOS
      - cannot install the best update candidate for package python3-devel-3.6.8-59.el8.x86_64
      - cannot install the best update candidate for package platform-python-3.6.8-59.el8.x86_64
     Problem 2: problem with installed package python3-devel-3.6.8-59.el8.x86_64
      - package python3-devel-3.6.8-59.el8.x86_64 from @System requires platform-python-devel(x86-64) = 3.6.8-59.el8, but none of the providers can be installed
      - package python3-devel-3.6.8-59.el8.x86_64 from rhel-buildroot requires platform-python-devel(x86-64) = 3.6.8-59.el8, but none of the providers can be installed
      - package python3-devel-3.6.8-59.el8.x86_64 from testing-farm-tag-repository-mainline requires platform-python-devel(x86-64) = 3.6.8-59.el8, but none of the providers can be installed
      - package python3-devel-3.6.8-72.el8_10.x86_64 from testing-farm-tag-repository-z-stream requires platform-python-devel(x86-64) = 3.6.8-72.el8_10, but none of the providers can be installed
      - cannot install both platform-python-devel-3.6.8-71.el8_10.x86_64 from rhel-AppStream and platform-python-devel-3.6.8-59.el8.x86_64 from @System
      - cannot install both platform-python-devel-3.6.8-59.el8.x86_64 from rhel-buildroot and platform-python-devel-3.6.8-71.el8_10.x86_64 from rhel-AppStream
      - cannot install both platform-python-devel-3.6.8-59.el8.x86_64 from testing-farm-tag-repository-mainline and platform-python-devel-3.6.8-71.el8_10.x86_64 from rhel-AppStream
      - cannot install both platform-python-devel-3.6.8-72.el8_10.x86_64 from testing-farm-tag-repository-z-stream and platform-python-devel-3.6.8-71.el8_10.x86_64 from rhel-AppStream
      - cannot install the best update candidate for package platform-python-devel-3.6.8-59.el8.x86_64
2026-03-31 14:25:08 +02:00

88 lines
2.9 KiB
RPMSpec

%global __python3 /usr/bin/python3.12
%global basedir /opt/test/byte_compilation
# We have 3 different ways of bytecompiling: for 3.9+, 3.4-3.8, and 2.7
# Test with a representative of each.
%global python36_sitelib /usr/lib/python3.6/site-packages
%global python27_sitelib /usr/lib/python2.7/site-packages
Name: pythontest
Version: 0
Release: 0%{?dist}
Summary: ...
License: MIT
BuildRequires: python3-devel
BuildRequires: python2
BuildRequires: python3.12-devel
BuildRequires: python3.12-rpm-macros
%description
...
%install
mkdir -p %{buildroot}%{basedir}/directory/to/test/recursion
echo "print()" > %{buildroot}%{basedir}/file.py
echo "print()" > %{buildroot}%{basedir}/directory/to/test/recursion/file_in_dir.py
%py_byte_compile %{python3} %{buildroot}%{basedir}/file.py
%py_byte_compile %{python3} %{buildroot}%{basedir}/directory
# Files in sitelib are compiled automatically by brp-python-bytecompile
mkdir -p %{buildroot}%{python3_sitelib}/directory/
echo "print()" > %{buildroot}%{python3_sitelib}/directory/file.py
mkdir -p %{buildroot}%{python36_sitelib}/directory/
echo "print()" > %{buildroot}%{python36_sitelib}/directory/file.py
mkdir -p %{buildroot}%{python27_sitelib}/directory/
echo "print()" > %{buildroot}%{python27_sitelib}/directory/file.py
%check
LOCATIONS="
%{buildroot}%{basedir}
%{buildroot}%{python3_sitelib}/directory/
%{buildroot}%{python36_sitelib}/directory/
%{buildroot}%{python27_sitelib}/directory/
"
echo "============== Print .py files found in LOCATIONS =================="
find $LOCATIONS -name "*.py"
echo "============== Print .pyc files found in LOCATIONS =================="
find $LOCATIONS -name "*.py[co]"
echo "============== End of print =================="
# Count .py and .pyc files
PY=$(find $LOCATIONS -name "*.py" | wc -l)
PYC=$(find $LOCATIONS -name "*.py[co]" | wc -l)
# We should have 5 .py files (3 for python3, one each for 3.6 & 2.7)
test $PY -eq 5
# Every .py file should be byte-compiled to two .pyc files (optimization level 0 and 1)
# so we should have two times more .pyc files than .py files
test $(expr $PY \* 2) -eq $PYC
# In this case the .pyc files should be identical across omtimization levels
# (they don't use docstrings and assert staements)
# So they should be hardlinked; the number of distinct inodes should match the
# number of source files. (Or be smaller, if the dupe detection is done
# across all files.)
INODES=$(stat --format %i $(find $LOCATIONS -name "*.py[co]") | sort -u | wc -l)
test $PY -ge $INODES
%files
%pycached %{basedir}/file.py
%pycached %{basedir}/directory/to/test/recursion/file_in_dir.py
%pycached %{python3_sitelib}/directory/file.py
%pycached %{python36_sitelib}/directory/file.py
%{python27_sitelib}/directory/file.py*
%changelog
* Thu Jan 01 2015 Fedora Packager <nobody@fedoraproject.org> - 0-0
- This changelog entry exists and is deliberately set in the past