Commit Graph

102 Commits

Author SHA1 Message Date
Miro Hrončok
cc15860ccf 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

(cherry picked from commit 1532f1893f)
2024-11-15 00:29:10 +01:00
Miro Hrončok
e8d079ef42 Fixup the version-release
(cherry picked from commit 4ddd57c537)
2024-11-15 00:29:10 +01:00
Miro Hrončok
9ecce29cd3 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

(cherry picked from commit 20b7ac63f3)
2024-11-15 00:29:10 +01:00
Miro Hrončok
35f8482574 %pyproject_buildrequires: Add support for dependency groups (PEP 735), via tox configuration
(cherry picked from commit 8baa94160c)
2024-11-15 00:29:10 +01:00
Miro Hrončok
f1186740e0 %pyproject_buildrequires: Add support for dependency groups (PEP 735), via the -g flag
(cherry picked from commit 307d2bef63)
2024-11-15 00:29:10 +01:00
Karolina Surma
4c6bd08a70 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.

(cherry picked from commit bc6cb55227)
2024-11-15 00:29:10 +01:00
Miro Hrončok
c34065ccca Even when %_auto_set_build_flags is disabled, set all compiler flags when building wheels
- Fixes: rhbz#2293616

(cherry picked from commit c7553b2c7d)
2024-11-15 00:29:10 +01:00
Miro Hrončok
a33eda232e Don't generate a dependency on pip when %pyproject_buildrequires -N is used
- Fixes: rhbz#2294510

(cherry picked from commit 8a41ec5715)
2024-11-15 00:29:10 +01:00
Karolina Surma
a1488d18df 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.

(cherry picked from commit 9f43e2a760)
2024-11-15 00:29:10 +01:00
Lumir Balhar
e161cd449e Mark the license in the specfile as SPDX formula
(cherry picked from commit c8abf80acd)
2024-11-14 17:18:21 +01:00
Miro Hrončok
4669de1250 Add a provisional RPM Declarative Buildsystem (RPM 4.20+)
(cherry picked from commit e7b37d02f8)
2024-11-14 17:16:04 +01:00
Fedora Release Engineering
c8de77f22e Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
(cherry picked from commit bc3d8013a4)
2024-11-14 17:15:59 +01:00
Miro Hrončok
4dc9dd6f33 Revert the temporary workaround for RPM 4.20 alpha 2 leaking \x1f (unit separators)
This reverts commit 996ac31b46.

(cherry picked from commit 436695615e)
2024-11-14 17:15:53 +01:00
Miro Hrončok
1bcb45eb11 Properly escape weird characters from paths in %{pyproject_files} (RPM 4.19+ only)
(cherry picked from commit 6d455af4dc)
2024-11-14 17:15:49 +01:00
Cristian Le
244da58cb9 %pyproject_extras_subpkg: Allow passing -a or -A to %python_extras_subpkg
Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
(cherry picked from commit d74914ec13)
2024-11-14 17:15:46 +01:00
Miro Hrončok
7309d3a880 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.

(cherry picked from commit 996ac31b46)
2024-11-14 17:15:42 +01:00
Miro Hrončok
345517d213 Run tests with Python 3.12 in %check (RHEL 9 specific)
Also, add a Python 3.12 CI job (isort_c9s already contains that as well).

Resolves: RHEL-22803
2024-01-26 11:48:54 +01:00
Miro Hrončok
29eb590e45 Namespace pyproject-rpm-macros generated text files with %{python3_pkgversion} 2024-01-26 11:36:24 +01:00
Miro Hrončok
f8b0e925e8 Fix %pyproject_buildrequires -w when the build backend is already installed and pip isn't
Fixes: https://bugzilla.redhat.com/2169855
2024-01-26 11:19:37 +01:00
Miro Hrončok
9afde6e68e Show a better error message when %pyproject_install finds no wheel
Fixes: https://bugzilla.redhat.com/2242452
2024-01-26 11:19:37 +01:00
Miro Hrončok
b5c55d6167 Prevent incorrect usage of %pyproject_buildrequires -R with -x/-e/-t
Fixes: https://bugzilla.redhat.com/2244282
2024-01-26 11:19:37 +01:00
Miro Hrončok
22918dd2a6 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>
2024-01-26 11:19:37 +01:00
Miro Hrončok
7e0207e048 Fix a typo in the latest changelog entry 2024-01-26 11:19:37 +01:00
Miro Hrončok
fa2855f6ce 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.
2024-01-26 11:19:37 +01:00
Miro Hrončok
d95890489a 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.
2024-01-26 11:19:37 +01:00
Karolina Surma
47cfbcf6e3 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>
2024-01-26 11:19:35 +01:00
Carl George
39dc109d06 Fix PEP number typo 2024-01-26 11:16:14 +01:00
Miro Hrončok
5f5038f73e Run tests with Python 3.11 in %check (RHEL 9 specific)
Related: rhbz#2208971
2023-06-07 09:55:37 +02:00
7f75263357 Allow passing config_settings to the build backend
Related: rhbz#2208971
2023-05-31 21:37:01 +02:00
Miro Hrončok
d5a5919a27 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.

Related: rhbz#2208971
2023-05-31 18:21:18 +02:00
Miro Hrončok
1ca4dcdce7 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.

Related: rhbz#2208971
2023-05-31 09:52:27 +02:00
Miro Hrončok
9422982693 Use tomli for older Pythons, now when RHEL 9 has it
Related: rhbz#2208971
2023-05-31 09:52:27 +02:00
Miro Hrončok
1d24fae689 Bump the release for ELN dependency changes
Related: rhbz#2208971
2023-05-30 10:43:55 +02:00
Miro Hrončok
fb1cb520d9 Don't run tox tests on RHEL by default, as tox is unwanted in RHEL
See https://github.com/fedora-eln/eln/issues/126

Related: rhbz#2208971
2023-05-30 10:43:53 +02:00
0dd9e91f43 don't use pytest-xdist in RHEL
Relates: https://github.com/fedora-eln/eln/issues/125

Related: rhbz#2208971
2023-05-30 10:43:49 +02:00
Miro Hrončok
a7a8d6bda0 In %check, assert the two signatures of %pyproject_buildrequires match exactly
Related: rhbz#2208971
2023-05-30 10:43:47 +02:00
Miro Hrončok
500d43c1c0 %pyproject_buildrequires: Add support for self-referential extras requirements
Related: rhbz#2208971
2023-05-30 10:43:42 +02:00
Miro Hrončok
ccc11a3af7 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/

Related: rhbz#2208971
2023-05-30 10:43:39 +02:00
Miro Hrončok
e9b491535c 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.

Related: rhbz#2208971
2023-05-30 10:43:35 +02:00
Lumir Balhar
e828b8291a 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.

Related: rhbz#2208971
2023-05-30 10:37:26 +02:00
Lumir Balhar
ea94129e35 Improve detection of lang files
Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok
6923c14ba5 %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).

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok
ecf0a140a8 %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.

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok
159b22e742 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.

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok
df1ddd0ccd Adjust %pyproject_buildrequires tests for tox 4
Fixes: https://bugzilla.redhat.com/2160687

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok
9801a61106 Use %py3_test_envvars in %tox when available
The new %py3_test_envvars macro was added
to remove duplication of environment variables used in %check.

We reuse it in %tox to gain support e.g. for PYTEST_XDIST_AUTO_NUM_WORKERS.

However, we keep support for platforms where the macro is not yet available,
not to be forced to backport %py3_test_envvars everywhere right away.

Technically, this should change little, but it sets CFLAGS and LDFLAGS now,
hence a new Y version.

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Karolina Surma
14b3f4b9c3 Filter discovered modules to match the given %pyproject_save_files globs
When certain modules are deliberately not included into the built RPM,
they shouldn't be listed in the list of qualified module names which are
used by %pyproject_check_import to test importability of the
distribution.

Related: rhbz#2168193
2023-02-13 16:42:57 +01:00
Miro Hrončok
064e6f283c %pyproject_save_files: Support License-Files installed into the *Root License Directory* from PEP 369
Files still need to be marked as License-File to be considered %license,
but if their path in METADATA is specified relative to dist-info/licenses,
they are correctly recognised.

This makes License-Files specified by hatchling 1.9.0+ marked as %license.

Related: rhbz#2168193
2023-02-13 16:42:39 +01:00
Otto Liljalaakso
e8135abc2f Fix typo in function name 'evaluate_all_environamnets'
The function is only used internally in these macros,
so name change should not break any users.

Related: rhbz#2168193
2023-02-13 16:27:15 +01:00
Karolina Surma
50012935df Don't fail %pyproject_save_files '*' if no modules are present
Users invoking %pyproject_save_files with glob: '*' don't care about the
files in the Python package, hence it shouldn't error when no modules
are detected.
There may be legitimate reasons to create a package without Python
modules in it, hence we shouldn't be blocking this possibility.

Related: rhbz#2117571
2022-08-11 13:05:53 +02:00