Add a test for %py_byte_compile macro
This commit is contained in:
parent
2eb41fe707
commit
431e4380cc
|
@ -0,0 +1,33 @@
|
||||||
|
%global basedir /opt/test/byte_compilation
|
||||||
|
|
||||||
|
Name: pythontest
|
||||||
|
Version: 0
|
||||||
|
Release: 0
|
||||||
|
Summary: ...
|
||||||
|
License: MIT
|
||||||
|
BuildRequires: python3-devel
|
||||||
|
|
||||||
|
%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
|
||||||
|
|
||||||
|
%check
|
||||||
|
# Count .py and .pyc files
|
||||||
|
PY=$(find %{buildroot}%{basedir} -name "*.py" | wc -l)
|
||||||
|
PYC=$(find %{buildroot}%{basedir} -name "*.pyc" | wc -l)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
%files
|
||||||
|
%pycached %{basedir}/file.py
|
||||||
|
%pycached %{basedir}/directory/to/test/recursion/file_in_dir.py
|
|
@ -16,6 +16,9 @@
|
||||||
- pytest:
|
- pytest:
|
||||||
dir: .
|
dir: .
|
||||||
run: pytest -v
|
run: pytest -v
|
||||||
|
- manual_byte_compilation:
|
||||||
|
dir: .
|
||||||
|
run: rpmbuild -ba pythontest.spec
|
||||||
required_packages:
|
required_packages:
|
||||||
- rpm-build
|
- rpm-build
|
||||||
- python-rpm-macros
|
- python-rpm-macros
|
||||||
|
|
Loading…
Reference in New Issue