Commit Graph

350 Commits

Author SHA1 Message Date
Gordon Messmer
10f0ca0ffa %pyproject_save_files: Also save top level typing stub files (.pyi) 2025-10-27 14:39:03 +01:00
Miro Hrončok
fbd3dcd22b %pyproject_extras_subpkg: Only %ghost the dist-info directory, not the content
That way, accidentally unpackaged files within are reported as errors.

Currently, when %pyproject_extras_subpkg is used, the dist-info directory
is packaged as %ghost. When the main package does not have it,
the RPM build would succeed. The extras packages would have the python3dist()
requires and provides, but the main package would not.

By adding %dir after %ghost, we only package the directory
(which is enough for python3-rpm-generators to process it),
but the files in the directory are not included.
When not packaged in the main package, the RPM build fails.

This is a safeguard against packaging mistakes.

The visible difference is that rpm -ql/repoquery -l would only return the metadata directory.

See also https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/195
2025-10-22 22:46:40 +02:00
Miro Hrončok
8a209c9005 CI: Add Python 3.13 on EPEL 9 and 10 2025-09-02 11:56:46 +02:00
4aaa4be87e Speed %pyproject_save_files up significantly by using sets instead of lists
For packages with a lot of files, it took a really long time to run.
Profiling the code revealed most of the time is spent in PurePath.__eq__.

The code was using lists but checked
if to-be-added paths were not already in them.

Considering the order is insignificant
(the generated %files list is sorted at the end anyway),
the lists were essentially working as (very slow) sets.

Using sets instead of lists makes %pyproject_save_files over 20 times faster
(51.66 -> 2.39 seconds) for the ansible package (~62k files).

Checking if an item is in a list is O(N),
checking every added item is O(N**2).

Checking if an item is in a set is O(1),
checking every added item is O(N).

Additionally, with set, it is unnecessary to check for presence before addition,
so the code is easier.

(Commit message and removal of the check by Miro.)

Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
2025-09-02 09:09:53 +02:00
Miro Hrončok
3ae687d401 On RPM 4.20+ don't put pyproject-macros-specific files in %buildsubdir
- Works around https://github.com/rpm-software-management/rpm/issues/3890
2025-09-02 09:09:53 +02:00
Miro Hrončok
ea56d1c870 Don't exit from pyproject-srpm-macros implementation of %pyproject_buildrequires
- Fixes: rhbz#2391290

Consider code like this:

    %generate_buildrequires
    mv setup.py{,.ignore}
    %pyproject_buildrequires
    mv setup.py{.ignore,}

When %pyproject_buildrequires exits, the second mv is never executed.
The next round of %generate_buildrequires will then fail.

In fact, there is probably not a good reason to call exit from %pyproject_buildrequires.

From https://src.fedoraproject.org/rpms/libcpuid/pull-request/7
2025-09-01 13:18:45 +02:00
Lukáš Zachar
84e6d30255 CI: Drop STI and use tmt
Resolves: rhbz#2383022
2025-07-30 17:46:32 +02:00
Lukáš Zachar
8998e8e027 CI: Respect TEST_ARTIFACTS but detect tmt
STI used to allow /tmp/artifacts, in tmt we have
TMT_PLAN_DATA and TMT_TEST_DATA. Use the later, which is test specific.
2025-07-30 17:44:52 +02:00
Fedora Release Engineering
3feea218e7 Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-25 06:23:37 +00:00
Miro Hrončok
1a867b5ab7 Only BuildRequire wheel when setuptools < 71 2025-07-24 00:01:34 +02:00
Miro Hrončok
a4e0e04344 %pyproject_buildrequires: Do not generate BuildRequires from Requires core metadata fields
See https://packaging.python.org/en/latest/specifications/core-metadata/#requires

That field is deprecated and should include importable module names, not distribution packages.

We have no RPM Provides for importable names.
Treating this like python3dist() Requires is wrong and may result in stuff like:

    No match for argument: python3dist(pkg-resources)

For packages using python-distutils-extra.

See https://bugzilla.redhat.com/show_bug.cgi?id=2378463#c2

This bug existed from the very beginning of the %pyproject_buildrequires,
but the field is almost unused in real packages, so it was not noticed until
we asked all Python packages to be ported to the new macros.

---

I considered flattening the structure returned from requires_from_parsed_metadata_file,
but then we would need to hardcode "Requires-Dist" in various source= declarations,
so I kept the structure as is.
2025-07-11 12:34:57 +02:00
Miro Hrončok
f0b3a0b860 Avoid non-fatal errors in %pyproject_install with multiple wheels
Use double quotes around a shell variable that may contain spaces.

There were errors like:

    + '[' -z markupsafe==2.0.1 tldr==0.4.4 ']'
    /var/tmp/rpm-tmp.v6rA4u: line 55: [: markupsafe==2.0.1: binary operator expected

Or:

    + '[' -z nemo_audio_tab==6.4.0 nemo_compare==6.4.0 nemo_emblems==6.4.0 nemo_pastebin==6.4.0 nemo_terminal==6.4.0 ']'
    /var/tmp/rpm-tmp.BD4qxp: line 53: [: too many arguments

But considering the exit code of [ was non-zero, the built continued.
2025-07-10 11:07:05 +02:00
Miro Hrončok
38866ffe87 CI: Update tested pytest to fix build with Python 3.14
We got:

    DEBUG:   File "/builddir/build/BUILD/python-pytest-7.2.0-build/BUILDROOT/usr/lib/python3.14/site-packages/_pytest/assertion/rewrite.py", line 670, in run
    DEBUG:     and isinstance(item.value, ast.Str)
    DEBUG:                                ^^^^^^^
    DEBUG: AttributeError: module 'ast' has no attribute 'Str'

Version 8.0.2 builds in Fedora 43, 42, 41, EPEL 10 (still without tests).

The setup.py manipulation was moved to pluggy,
as pytest 8 no longer has setup.py.
2025-06-20 13:36:01 +02:00
570b5a6ee6
pyproject_buildrequires: don't pass config_settings as kwarg
PEP 517 says that the argument should be named config_settings but
pip/pyproject-hooks and other build frontends just pass it as a
positional argument, so some build backends name this argument other
things. Even though those build backends are wrong, it still makes sense
to align pyproject-rpm-macros with what the other frontends do.

Ref: https://github.com/PyO3/maturin/pull/2612
Ref: https://github.com/Rogdham/pyzstd/pull/2
2025-05-19 16:51:57 -05:00
Benson Muite
be0ace6df6 Mark Qt language files
Ensure translation files used in PyQt projects get marked as such.
2025-04-20 10:56:42 +03:00
Miro Hrončok
fc9cfbe360 CI: Adjust for normalized dist-info names with new setuptools 2025-04-11 21:05:34 +02:00
Miro Hrončok
5e1a6e91f0 Update comment wrt setuptools not putting licenses in licenses/ directory 2025-04-11 19:23:18 +02:00
Miro Hrončok
c1326723a9 Fix reverted conditional in %pyproject_buildrequires -t/-e Fedora version comparison 2025-03-21 14:49:58 +01:00
Miro Hrončok
fb7bcbb068 Allow %pyproject_buildrequires -t/-e without tox config on Fedora 40-42
This still does not allow %tox without tox config.
2025-03-21 12:08:13 +00:00
Miro Hrončok
d3dfd5fdb2 Make %pyproject_buildrequires -t/-e and %tox fail when no suitable tox configuration exists
Since tox 4, tox does not fail without configuration
(tox.ini, or tox section in setup.cfg/pyproject.toml).

As a result, packages that use %pyproject_buildrequires with -t or -e
without having a tox confuration
only generate additional BuildRequires on tox & tox-current-env itself.

More dangerously, %tox without tox configuration does nothing (and succeeds).
This behavior is dangerous and warrants an announced breakage.

Packagers of ~100 affected Fedora packages were informed about the problem earlier in
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/ZSHSHZKVA4XJQBJD7FMMCALKN4UP5SAJ/

There will be a further announcement and warning about this change.

EPEL 9 packages are not affected,
EPEL 9 has tox 3 which fails without config by default.

The change used a newly added option for tox-current-env: --assert-config.
This was added in tox-current-env 0.0.16:
https://github.com/fedora-python/tox-current-env/pull/89
2025-03-21 12:08:13 +00:00
Lumir Balhar
d1c632d76c Make dependencies in test_data order-independent
When updating setuptools from 74 to 76, order of extras has changed.
The order of the output is not considered stable and does not need to be asserted.
2025-03-17 08:20:11 +01:00
Miro Hrončok
e9f7ceb420 CI: Update the tested pluggy
Fedora 43 no longer has pytest 7.
2025-03-14 10:13:07 +01:00
Tomas Orsava
caad857e1a Mention ELN/CentOS Stream version needed for the Declarative Build System 2025-03-06 18:25:23 +01:00
Karolina Surma
b2862d315f PEP 639 is now accepted, remove the note about its provisional status 2025-02-27 13:44:24 +01:00
Miro Hrončok
ac4f008073 CI: Convert all test spec License tags to SPDX
python-ldap is a SPDX tag: https://spdx.org/licenses/python-ldap.html
2025-02-05 16:17:50 +01:00
Miro Hrončok
aac6644d02 Add the -M flag to %pyproject_save_files
- The flag can be used to indicate no Python modules should be saved

The change wrt users using '*' was necessary,
as `glob` was undefined when `module_globs` was empty.
2025-02-05 16:17:50 +01:00
Fedora Release Engineering
79d31f177e Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-18 11:18:54 +00:00
Miro Hrončok
ee9d130fdc Deprecate the provisional -w flag for %pyproject_buildrequires
The option was provisional, so it had no compatibility guarantees.
We keep the option anyway: there will be no removals just for the sake of removals.

All remaining usages in Fedora Rawhide have open Pull Requests to replace it with -p,
or remove it entirely.

Examples:

 https://src.fedoraproject.org/rpms/python-scikit-misc/pull-request/13
 https://src.fedoraproject.org/rpms/python-traitlets/pull-request/8
 https://src.fedoraproject.org/rpms/packit/pull-request/1402
2024-12-03 21:43:58 +01:00
Miro Hrončok
c1de18f683 Accept arbitrary options from %pyproject_buildrequires in pyproject-srpm-macros
This way, when we add new options to the actual macro in pyproject-rpm-macros,
spec files that use them are parsable with the old pyproject-srpm-macros package.

Last time, when we added the -g option in 1.16.0,
it took at least a week for Fedora CI to be able to parse a spec file with it,
as pyproject-srpm-macros 1.16.0+ needed to actually be installed on the CI systems.

Next time this happens, the new option will be parsable with older versions of pyproject-rpm-macros

Note that the (-) syntax is not supported yet on RPM 4.16 in RHEL 9.
I'd use an expression to keep the literal set of flags for older RPM versions:

    %pyproject_buildrequires(%[v"0%{?rpmversion}" >= v"4.19" ? "-" : "rRxtNwpe:g:C:"])

But macro options are not processed as macros:
https://github.com/rpm-software-management/rpm/issues/3440

As a result, this is not compatible with RHEL 9 and cannot be backported to it.
Unless the (-) syntax is backported:
https://issues.redhat.com/browse/RHEL-67161
https://gitlab.com/redhat/centos-stream/rpms/rpm/-/merge_requests/60
2024-12-03 12:58:44 +01:00
Miro Hrončok
d0e32d9246 CI: Rename in-tree patches to make them nicer in a single directory 2024-12-03 11:31:09 +01:00
Lukáš Zachar
cd00547996 Change the test source location
Change the test source location to support evolving downstream testing
requirements. This is needed both for downstream certification
activities and changes to test development for internal infrastructure
differences.

Cherry-picked from https://gitlab.com/redhat/centos-stream/rpms/pyproject-rpm-macros/-/merge_requests/25

Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
2024-12-02 13:34:42 +01:00
Miro Hrončok
665fd2456d CI: Simplify spec conditionals wrt Fedora 39 going EOL 2024-11-20 13:29:25 +01:00
Miro Hrončok
a69fb4e183 CI: %{pyproject_build_lib} changed on EL9
The actual value is still OK, but the tests were too strict.
2024-11-15 14:41:41 +01:00
Miro Hrončok
1532f1893f Fix one remaining test for setuptools 70+
This test was previously skipped because we didn't have new enough tox.
That's why it was never fixed for setuptools 70+.

This is a fixup for 20b7ac63f3
2024-11-13 14:01:09 +01:00
Miro Hrončok
4ddd57c537 Fixup the version-release 2024-11-07 17:14:52 +01:00
Miro Hrončok
20b7ac63f3 Support for setuptools 70+
- wheel is no longer generated as a dependency of the default build system
- test cases are adapted to support both old and new setuptools version
2024-11-07 13:00:47 +01:00
Miro Hrončok
8baa94160c %pyproject_buildrequires: Add support for dependency groups (PEP 735), via tox configuration 2024-11-06 13:31:41 +01:00
Miro Hrončok
307d2bef63 %pyproject_buildrequires: Add support for dependency groups (PEP 735), via the -g flag 2024-11-05 11:31:33 +01:00
Miro Hrončok
80d9abe0f4 Minor documentation clarification wrt -p/-w 2024-11-05 11:31:03 +01:00
Miro Hrončok
beceb2c94b PEP 639 is provisional, no longer a draft 2024-11-03 10:00:34 +01:00
Karolina Surma
bc6cb55227 Fix handling of self-referencing extras when reading pyproject.toml
Keep the information about the requirement extras by storing the
Requirement instances in the list of the ignored requirements, rather
than the strings in the form they were initially read from metadata.
The requirements strings read from pyproject.toml don't contain the
extra information, we insert the extra marker only after converting them to
Requirement instances. When stored as the text, the information about
the extra went missing in the course of the script.
2024-10-04 09:54:08 +02:00
Miro Hrončok
c7553b2c7d Even when %_auto_set_build_flags is disabled, set all compiler flags when building wheels
- Fixes: rhbz#2293616
2024-09-23 15:53:23 +02:00
Miro Hrončok
8a41ec5715 Don't generate a dependency on pip when %pyproject_buildrequires -N is used
- Fixes: rhbz#2294510
2024-09-23 14:39:00 +02:00
Karolina Surma
9f43e2a760 Add a possibility to read runtime dependencies from pyproject.toml
This adds a new flag, -p, to %pyproject_buildrequires.
When set, the runtime dependencies are read from the pyproject.toml's
[project] table.

See: https://bugzilla.redhat.com/2261939

pyproject_buildrequires.py already had a short `-p` option for
--python3_pkgversion (hidden from the macro users).
This change removes the one-letter option and leaves the long-one.
`-p` is now reused for reading dependencies from pyproject.toml
and made visible to the macro users.
2024-09-23 11:48:20 +02:00
Miro Hrončok
ab3dc0126a CI: Update setuptools_scm to a version that can be tested on EL9, EL10, Fedora 39-42 2024-09-07 12:42:44 +02:00
Miro Hrončok
459cda2e67 CI: python-ipykernel: Drop unneeded python3-ipyparallel dependency
It is not available in EPEL 10 and we can avoid it by excluding more imports,
which is what this spec file tests anyway.
2024-09-07 12:42:44 +02:00
Miro Hrončok
89374b9107 CI: python-virtualenv: Drop an unused dependency on python3-flaky
We don't have flaky in EL 10 yet.
2024-09-07 12:42:44 +02:00
Miro Hrončok
4a4614d13a CI: Use poetry-core in python-clikit.spec for EL10 compatibility 2024-09-07 12:42:44 +02:00
Miro Hrončok
32a3b5613f CI: Use flit_core in python-entrypoints.spec for EL10 compatibility 2024-09-07 12:42:44 +02:00
Miro Hrončok
049eb198d0 CI: Make python-pytest.spec build on EL 10 (but not on EL 9 anymore) 2024-09-07 12:42:44 +02:00