c2305ea Introduce %py3_check_import

Authored and Committed by churchyard 2 years ago
    Introduce %py3_check_import
    
    With $PATH and $PYTHONPATH set to the %buildroot,
    the macro tries to import the given Python 3 module(s).
    Useful as a smoke test in %check when ruining tests is not feasible.
    Accepts spaces or commas as separators.
    
    Package python-six:
    
        %check
        %py3_check_import six
    
        Executing(%check): ...
        ...
        + PATH=...
        + PYTHONPATH=...
        + PYTHONDONTWRITEBYTECODE=1
        + /usr/bin/python3 -c 'import six'
        + RPM_EC=0
        ++ jobs -p
        + exit 0
    
        %py3_check_import six seven
    
        ...
        + /usr/bin/python3 -c 'import six, seven'
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
        ModuleNotFoundError: No module named 'seven'
    
        error: Bad exit status from ... (%check)
    
        ...
        %py3_check_import five, six, seven
    
        + /usr/bin/python3 -c 'import five, six, seven'
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
        ModuleNotFoundError: No module named 'five'
    
        error: Bad exit status from ... (%check)
    
    Package python-packaging:
    
        %py3_check_import packaging, packaging.markers  packaging.requirements, packaging.tags
    
        Executing(%check): ...
        ...
        + PATH=...
        + PYTHONPATH=...
        + PYTHONDONTWRITEBYTECODE=1
        + /usr/bin/python3 -c 'import packaging, packaging.markers, packaging.requirements, packaging.tags'
        + RPM_EC=0
        ++ jobs -p
        + exit 0
    
        %py3_check_import packaging, packaging.markers  packaging.notachance, packaging.tags
    
        ...
        + /usr/bin/python3 -c 'import packaging, packaging.markers, packaging.notachance, packaging.tags'
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
        ModuleNotFoundError: No module named 'packaging.notachance'
    
        error: Bad exit status from ... (%check)
    
        
file modified
+13 -0
file modified
+13 -0
file modified
+4 -1
file modified
+45 -0