Commit Graph

157 Commits

Author SHA1 Message Date
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
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
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
Lumir Balhar
c8abf80acd Mark the license in the specfile as SPDX formula 2024-09-05 21:41:19 +00:00
Miro Hrončok
e7b37d02f8 Add a provisional RPM Declarative Buildsystem (RPM 4.20+) 2024-07-25 11:54:55 +02:00
Fedora Release Engineering
bc3d8013a4 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-19 08:56:55 +00:00
Miro Hrončok
436695615e Revert the temporary workaround for RPM 4.20 alpha 2 leaking \x1f (unit separators)
This reverts commit 996ac31b46.
2024-07-03 16:03:03 +02:00
Miro Hrončok
6d455af4dc Properly escape weird characters from paths in %{pyproject_files} (RPM 4.19+ only) 2024-07-02 23:53:19 +02:00
Cristian Le
d74914ec13 %pyproject_extras_subpkg: Allow passing -a or -A to %python_extras_subpkg
Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
2024-06-25 12:27:56 +02:00
Miro Hrončok
996ac31b46 Add a temporary workaround for RPM 4.20 alpha 2 leaking \x1f (unit separators)
Strip them.
This workaround is safe with RPM < 4.20 or when RPM is fixed.
2024-06-04 10:46:50 +02:00
Miro Hrončok
5aca0a6034 Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion} 2024-01-26 09:45:58 +01:00
Fedora Release Engineering
48d8f4493a Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-26 00:40:39 +00:00
Fedora Release Engineering
e9d0e2578a Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-21 22:48:05 +00:00
Miro Hrončok
900c578fc8 Fix %pyproject_buildrequires -w when the build backend is already installed and pip isn't
Fixes: https://bugzilla.redhat.com/2169855
2023-12-13 17:19:14 +01:00
Miro Hrončok
89c9b407fa Show a better error message when %pyproject_install finds no wheel
Fixes: https://bugzilla.redhat.com/2242452
2023-12-13 17:18:40 +01:00
Miro Hrončok
89f2408342 Prevent incorrect usage of %pyproject_buildrequires -R with -x/-e/-t
Fixes: https://bugzilla.redhat.com/2244282
2023-12-13 17:17:33 +01:00
Miro Hrončok
f39261901c Add the -l/-L flag to %pyproject_save_files
- The -l flag can be used to assert at least 1 License-File was detected
- The -L flag explicitly disables this check (which remains the default)

Co-Authored-By: Maxwell G <maxwell@gtmx.me>
2023-12-11 13:16:09 +01:00
Miro Hrončok
633cfd6634 Fix a typo in the latest changelog entry 2023-09-27 18:17:58 +02:00
Miro Hrončok
089e2518ea Fix handling of tox 4 provision without tox minversion
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2240590

The added test actually blows up without the fix with both tox 4 or tox 3,
so perhaps this bug also existed with tox 3.
2023-09-27 16:08:45 +02:00
Miro Hrončok
15acb6ee5b Communicate loudly that this does not work with old RPM
I have seen several folks building this package in a RHEL 8 environment.
This won't prevent them doing so, but at least they will be forced to make changes,
acknowledging the fact that what they are doing has consequences.
2023-09-27 11:51:03 +00:00
Karolina Surma
97a7574518 Add %_pyproject_check_import_allow_no_modules
Macro which allows to pass the import check even if no Python modules
are detected in the package.
Only to be used in the automated environments.

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
2023-09-26 10:23:49 +00:00
Carl George
a39d658f0f Fix PEP number typo 2023-09-25 16:32:54 -05:00
Fedora Release Engineering
53c81f57c1 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-21 06:47:19 +00:00
156e2fc8fe
Allow passing config_settings to the build backend
Resolves: https://bugzilla.redhat.com/2192581
2023-05-31 19:26:32 +00:00
Miro Hrončok
638ba27daf Fix literal % handling in %{pyproject_files} on RPM 4.19
RPM 4.19 now requires 2 %s to escape a single literal % in the filelist.

The test has been adjusted to actually run our code
instead of only verifying the assumptions.
2023-05-31 18:26:51 +02:00
Miro Hrončok
ca3771c78d Fix the conditional tests-related BuildRequires for Python version
python3-devel is not installed, hence the conditional needs to be on python3.
It only "worked" with toml because toml was pulled as a transitive dependency.
2023-05-31 18:25:49 +02:00
Miro Hrončok
5ab7319ece Use tomli for older Pythons, now when RHEL 9 has it 2023-05-31 09:51:54 +02:00
Miro Hrončok
161c16b15f
Bump the release for ELN dependency changes 2023-05-23 19:19:38 +00:00
Miro Hrončok
b05b7f600b
Don't run tox tests on RHEL by default, as tox is unwanted in RHEL
See https://github.com/fedora-eln/eln/issues/126
2023-05-23 19:19:38 +00:00
aaac9203b9
don't use pytest-xdist in RHEL
Relates: https://github.com/fedora-eln/eln/issues/125
2023-05-23 19:19:38 +00:00
Miro Hrončok
17dab005cc In %check, assert the two signatures of %pyproject_buildrequires match exactly 2023-05-23 14:56:52 +02:00
Miro Hrončok
bd7890110c %pyproject_buildrequires: Add support for self-referential extras requirements 2023-04-27 11:18:18 +02:00
Miro Hrončok
a5e7a3cd07 Deprecate the provisional %{pyproject_build_lib} macro
There is no scheduled removal.

See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/HMLOPAU3RZLXD4BOJHTIPKI3I4U6U7OE/
2023-04-26 23:08:07 +02:00
Miro Hrončok
456903666c Redirect stdout to stderr via Shell
Dependencies are recorded to a text file that is catted at the end.

This should prevent subtle bugs like https://bugzilla.redhat.com/2183519 in the future.
2023-04-17 15:32:26 +02:00
Lumir Balhar
1e37a4d872 Remove .dist-info directory at the end of %pyproject_buildrequires
An incomplete .dist-info directory in $PWD can confuse tests in %check.
For example, virtualenv uses importlib.metadata to load its
entry points and it does not work when it finds a virtualenv...dist-info without them.
2023-03-03 10:02:49 +01:00
Lumir Balhar
7ba21ea4a8 Improve detection of lang files 2023-02-09 11:01:23 +00:00
Miro Hrončok
d53d20c711 %check: Use %pytest -n auto for faster build
The speedup is tiny but noticeable (pytest took 8.49s, now 5.87s on my 8-core workstation).
2023-02-06 22:26:02 +01:00
Miro Hrončok
85fc41174d %pyproject_buildrequires: Avoid leaking stdout from subprocesses
When the build backend prints to stdout via non-Python means,
for example when a setup.py script calls a verbose program via os.system(),
the output leaked to stdout of %pyproject_buildrequires was treated as generated BuildRequires.

Fore example, if the setup.py script has:

    rv = os.system('/usr/bin/patch -N -p3 -d build/lib < lib/py-lmdb/env-copy-txn.patch')

(From https://github.com/jnwatson/py-lmdb/blob/py-lmdb_1.0.0/setup.py#L117)

The stdout of /usr/bin/patch leaked to stdout of %pyproject_buildrequires:

    [lmdb-1.0.0]$ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --python3_pkgversion 3 2>/dev/null
    python3dist(setuptools) >= 40.8
    python3dist(wheel)
    patching file lmdb.h
    patching file mdb.c
    python3dist(wheel)
    patching file lmdb.h
    patching file mdb.c

This resulted in DNF errors like this:

    No matching package to install: 'lmdb.h'
    No matching package to install: 'mdb.c'
    No matching package to install: 'patching'

Moreover, it resulted in bogus BuildRequires that may have existed (e.g. "file").

By replacing the usage of contextlib.redirect_stdout
(which only redirects Python's sys.stdout)
with a custom context manager that captures stdout on file descriptor level
(in addition to Python's sys.stdout),
we avoid this leak.

File descriptor magic heavily inspired by the capfd pytest fixture.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2166888
2023-02-06 21:17:42 +01:00
Miro Hrončok
a4d05ba2c2 Add pyproject-srpm-macros with a minimal %pyproject_buildrequires macro
pyproject-srpm-macros is intended to be installed in the default buildroot.

That way, no explicit BuildRequires for pyproject-rpm-macros are required,
as long as %pyproject_buildrequires is used in %generate_buildrequires.

When only pyproject-srpm-macros is installed, the minimal implementation of
%pyproject_buildrequires generates a dependency on pyproject-rpm-macros.
When pyproject-rpm-macros is installed, it overrides the implementation
of %pyproject_buildrequires with the full one.

Note that in Fedora, pyproject-rpm-macros is required by python3-devel,
but not in RHEL.
This allows us to keep pyproject-rpm-macros in the RHEL CRB repository.
2023-01-20 21:57:49 +01:00
Fedora Release Engineering
05aaf0674a Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-20 10:43:08 +00:00