Commit Graph

21 Commits

Author SHA1 Message Date
Tomas Orsava
c2a69948b3 Add pathfix.py into python-rpm-macros and update macros to use it
Resolves: RHEL-6107
2023-11-02 17:39:46 +01:00
Tomas Orsava
85209d6c46 %py_provides: Do not generate Obsoletes for names containing parentheses
This mechanism is already implemented in the old %python_provide macro.

Related: rhbz#1990421
2022-02-15 17:37:31 +01:00
Tomas Orsava
30da77e6af Hardcode that python3-* packages will obsolete python39-* packages
We hardcode the xy prefix we want to obsolete to "39", because:
1. Python 3.9 will remain the main Python versin in RHEL 9
2. python39 in RHEL 8 is still using the dotless naming (as opposed to
   python3.9)

Resolves: rhbz#1990421
2022-01-24 11:31:46 +01:00
Miro Hrončok
04145e4cdd Add eval tests to RHEL %py_provides Obsoletes functionality
Related: rhbz#1990421
2022-01-24 11:29:17 +01:00
Miro Hrončok
c7a9537dba Set %__python3 value according to %python3_pkgversion
I.e. when %python3_pkgversion is 3.12, %__python3 is /usr/bin/python3.12

We assume that when packagers package for Python 3.X, they want to change both
%python3_pkgversion and %__python3 value.

Hence instead of copy-pasting this:

    %global python3_pkgversion 3.X
    %global __python3 /usr/bin/python3.X

They just need to do:

    %global python3_pkgversion 3.X

Packagers who want to change the value of %__python3 without touching
%python3_pkgversion can still do it:

    %global __python3 /usr/bin/pypy3

Related: rhbz#1950291
2021-12-14 21:35:59 +01:00
Miro Hrončok
e247e4dbae %py(3)_check_import: Process .pth files in site(arch|lib)
Related: rhbz#1950291
2021-12-14 21:32:50 +01:00
Karolina Surma
b2a5690d6b Fix %%py_shebang_flags handling within %%py_check_import
%%py{3}_check_import now respects the custom setting of %%py{3}_shebang_flags
and invokes Python with the respective values.
If %%py{3}_shebang_flags is undefined or set to no value,
there no flags are passed to Python on invoke.

Related: rhbz#1950291
2021-12-14 21:31:31 +01:00
Karolina Surma
62cbbbc802 Allow multiline arguments processing for %%py3_check_import
Fixes the regression introduced with the macro reimplementation.

Related: rhbz#1950291
2021-12-14 21:30:27 +01:00
Karolina Surma
eb3f38ce4b Add new options for %%py{3}_check_import: -f, -t, -e
-f: optionally read a file with module names to test
-t: bool flag - if set, filter only top-level modules
-e: optionally exclude module names matching the given glob (Unix
shell-style wildcards)
Importing all modules may cause bogus failures in some cases,
eg. when the imported code assumes there is an existing graphical window.
Such behaviour may be by design, hence for automatic processing it's
more convinient to - in some cases - check only for top-level modules
or filter out the troublemakers.

Related: rhbz#1950291
2021-12-14 21:28:45 +01:00
Miro Hrončok
f5bbbce169 CI eval tests: Drop the python3.6 dependency
It is not available on RHEL 9, so we skip the tests.

Once we have another python3.x available, we can enable them again.

Cherry-picked from https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/109

Resolves: rhbz#1984407
2021-08-25 14:21:23 +02:00
Miro Hrončok
7d8d1b3283 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)

Related: rhbz#1950291
2021-07-14 18:42:26 +02:00
Miro Hrončok
1232cc253e %pytest: Set $PYTEST_ADDOPTS when %{__pytest_addopts} is defined
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1935212

Related: rhbz#1950291
2021-06-30 16:25:45 +02:00
Miro Hrončok
093a0036db Document a TESTED_FILES value that currently works
Related: rhbz#1950291
2021-04-22 18:30:37 +02:00
Miro Hrončok
779cbd6fa3 Tests: Assert single-line macros are single-line
Related: rhbz#1950291
2021-04-22 18:30:18 +02:00
Karolina Surma
20a3073f02 Use sysconfig.get_path() to define %python_sitelib and %python_sitearch
Distutils which were used to define the macros are deprecated in Python3.10:
https://www.python.org/dev/peps/pep-0632/.
Sysconfig isn't and it works across our Pythons, making it better choice for the task.

Related: rhbz#1950291
2021-04-22 18:29:53 +02:00
Miro Hrončok
ca0a3311c5 Allow commas as argument separator for extras names in %python_extras_subpkg
This allows e.g.:

    %global extras cli,ghostwriter,pytz,dateutil,lark,numpy,pandas,pytest,redis,zoneinfo,django
    %{pyproject_extras_subpkg -n python3-hypothesis %{extras}}
    ...
    %pyproject_buildrequires -x %{extras}

(Note that %pyproject_extras_subpkg is a tiny wrapper around %python_extras_subpkg.)

Related: rhbz#1950291
2021-04-22 18:28:04 +02:00
Lumir Balhar
9a79a6cef6 Make extras_subpkg description more general
Because extra subpackages actually might contain code.
See for example: https://src.fedoraproject.org/rpms/python-dns/pull-request/9

Related: rhbz#1950291
2021-04-22 18:25:59 +02:00
DistroBaker
6bf18de563 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/python-rpm-macros.git#a6382f5b5a6536d01477b71cf5a378c30c828783
2021-03-11 20:31:16 +00:00
DistroBaker
b18966f2a7 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/python-rpm-macros.git#230ce7f0613816bd7daf1f615bca443d6c5aa7d5
2021-02-08 11:37:59 +00:00
DistroBaker
ede6a5b9bf Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/python-rpm-macros.git#e5429a7a486e470b514aed207457fb237d061598
2020-12-10 15:38:11 +00:00
Troy Dawson
365a69534a RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/python-rpm-macros#06987f5024e2618f3169ca829462b71f7bbae463
2020-10-14 20:10:31 -07:00