Commit Graph

44 Commits

Author SHA1 Message Date
Miro Hrončok
9b2577f91d CI: Also run tests for an alternate Python version, now when we have Python 3.11
Resolves: rhbz#2186267
2023-04-12 17:28:31 +02: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
a30059967b Add an Obsoletes tag with the python39- prefix
.. for smoother upgrade from RHEL8

Related: rhbz#1990421
2022-02-15 17:37:31 +01:00
Miro Hrončok
32385d7b9e Explicitly opt-out from Python name-based provides and obsoletes generators
In Koji, python3-rpm-generators are not installed during the build.
However, packagers can have them installed locally, in mock or in Copr.
This way, we make sure the automatic provides (and obsoletes)
do not magically appear only in some environments.

Since python3-rpm-macros actually requires python-rpm-macros,
the requirement is self-satisfied when the automatic provides are generated.

Related: rhbz#1950291
2022-02-01 01:06:09 +01:00
Charalampos Stratakis
785aef2702 Disable certain rpminspect inspections not relevant to this package 2022-01-28 19:17:49 +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
Tomas Orsava
e22e5600bd Add lua helper functions to make it possible to automatically generate Obsoletes tags
And modify the %%py_provides macro to also generate Obsoletes tags on CentOS/RHEL

Resolves: rhbz#1990421
2022-01-21 15:04:18 +01:00
Karolina Surma
25272d7d36 Let pytest see the package source code in the CI test run
This fixes ImportError which was caused by an incomplete
backport from Fedora (introduced in eb3f38c).

Related: rhbz#1950291
2021-12-21 15:49:40 +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
3a652b1c29 Move %python3_pkgversion definition earlier in the file
So we can use it later in %__python3 and maintain readability.

Related: rhbz#1950291
2021-12-14 21:34:53 +01:00
Miro Hrončok
c9f6636cc6 Move import_all_modules out of python-srpm-macros
There's no need for it in the default buildroot.

Related: rhbz#1950291
2021-12-14 21:33:55 +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
5cf7712d6f Set $RPM_BUILD_ROOT in %{python3_...} macros, for alternate sysconfig install scheme
Our Pythons currently patches distutils to install packages to
/usr/lib(64)/pythonX.Y/site-packages when the $RPM_BUILD_ROOT environment
variable is set (and to /usr/local/lib(64)/pythonX.Y/site-packages otherwise).
With the deprecation of distutils [1] we want to change the patch to create
and use a different sysconfig install scheme [2].

However, we have realized that macros defined as %(%{__python3} ...) don't
"see" the environment variables set by rpmbuild because they are expanded earlier
and hence e.g. %{python3_sitelib} evaluates to
/usr/local/lib/python3.X/site-packages -- which is not desired.
To be able to reliably detect an RPM build environment by checking
the presence of the $RPM_BUILD_ROOT environment variable,
we manually set it in the macro definitions.

Since %{buildroot} in not fully populated
(e.g. it can expand literally to
/home/anna/rpmbuild/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64),
we don't use it here.
The variable simply needs to present in the environment.

See also the analysis of the build failures when this is not done [3].

[1] https://www.python.org/dev/peps/pep-0632/
[2] https://bugs.python.org/issue43976
[3] https://src.fedoraproject.org/rpms/python3.10/pull-request/63#comment-79042

Related: rhbz#1950291
2021-12-14 21:28:24 +01:00
Tomas Orsava
3b86d5797c Define a new macros %python_wheel_dir and %python_wheel_pkg_prefix
Related: rhbz#1982668
2021-11-05 10:47:41 +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
Mohan Boddu
76df3dcf3d Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
Signed-off-by: Mohan Boddu <mboddu@redhat.com>
2021-08-10 00:22:25 +00: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
9235955bb3 Fix %python_provide when fed python3.10-foo to obsolete python-foo instead of python--foo
This has unlikely broken anything in practice,
no packages in Fedora use %python_provide with major.minor-version-prefixed names.

Related: rhbz#1950291
2021-06-30 12:17:29 +02:00
Petr Viktorin
4f73bb9538 Add the project's canonical URL
Related: rhbz#1950291
2021-06-30 12:17:29 +02:00
Lukas Zachar
9fec1d5a46 Add gating.yaml from RHEL 2021-06-02 12:42:49 +02:00
Miro Hrončok
cc83a8b62e Update %python3_pkgversion comment
Related: rhbz#1950291
2021-05-05 17:18:43 +02:00
Miro Hrončok
fd837e515a Remove EPEL 7 compatibility macros that were actually not defined at all
The %{? in the comment made the entire block of macros not work.

Since nobody actually used those on Fedora, because they did not exist,
we can safely remove them. No need to document this in the %changelog.

Related: rhbz#1950291
2021-05-05 17:18:41 +02:00
Miro Hrončok
a272f59825 Escape % symbols in macro files comments
This is most likely not neccessary but can prevent serious problems like:

https://bugzilla.redhat.com/show_bug.cgi?id=1953910

Related: rhbz#1950291
2021-05-05 17:18:32 +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
019f8b973d Escape a macro in an old %changelog entry
Related: rhbz#1950291
2021-04-22 18:28:24 +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
Miro Hrončok
f3df5e1d87 Update comment for python_altnames() to reflect the reality
Related: rhbz#1950291
2021-04-22 18:25:28 +02:00
Mohan Boddu
f9564fc7d5 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
Signed-off-by: Mohan Boddu <mboddu@redhat.com>
2021-04-16 04:44:32 +00: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
a1ceaecbcd 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#626168789c73d62eb211ec72fe260a128e66df45
2021-02-18 16:40:19 +00:00
Troy Dawson
f73468722f 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#626168789c73d62eb211ec72fe260a128e66df45
2021-02-10 06:05:59 -08: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
0e23a801f0 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#5b5cc39d89ceca9fba82f1c03cf06ea2f4e1f00b
2021-02-05 03:39:24 +01: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
Release Configuration Management
58fcc99e25 New branch setup 2020-10-08 23:33:09 +00:00