Commit Graph

30 Commits

Author SHA1 Message Date
Maxwell G 7f75263357 Allow passing config_settings to the build backend
Related: rhbz#2208971
2023-05-31 21:37:01 +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 500d43c1c0 %pyproject_buildrequires: Add support for self-referential extras requirements
Related: rhbz#2208971
2023-05-30 10:43:42 +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
Miro Hrončok 000ca45f91 Remove duplicate import
Related: rhbz#2208971
2023-05-30 10:43:25 +02: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 fe71860ca5 Reorder %pyproject_buildrequires arguments for a nicer usage string
Before:

    usage: %pyproject_buildrequires [-w] [-R] [-e TOXENVS] [-t] [-x EXTRAS] [-N] [REQUIREMENTS.TXT ...]

After:

    usage: %pyproject_buildrequires [-x EXTRAS] [-t] [-e TOXENVS] [-w] [-R] [-N] [REQUIREMENTS.TXT ...]

The order was determined as:

    0. suppressed options
    1. extras, the easiest way to specify test deps (x)
    2. tox related options (te)
    3. build wheel, as it is provisional (w)
    4. "disablers" (RN)
    5. varargs are always listed last

Previous order was pretty much random.

Related: rhbz#2168193
2023-02-13 16:42:58 +01:00
Miro Hrončok 9eb042c336 Make %pyproject_buildrequires and %pyproject_save_files argparser errors nicer to macro users
Before:

    %pyproject_buildrequires bogus_arg
    usage: pyproject_buildrequires.py [-h] [-r] [-w] [--wheeldir PATH] [-R]
                                      [-e TOXENVS] [-t] [-x EXTRAS]
                                      [--generate-extras] [-p PYTHON3_PKGVERSION]
                                      [-N]
                                      [requirement_files ...]
    pyproject_buildrequires.py: error: argument requirement_files: can't open 'bogus_arg': ...

    %pyproject_save_files
    ...
    usage: pyproject_save_files.py [-h] --output-files OUTPUT_FILES
                                   --output-modules OUTPUT_MODULES --buildroot
                                   BUILDROOT --sitelib SITELIB --sitearch SITEARCH
                                   --python-version PYTHON_VERSION
                                   --pyproject-record PYPROJECT_RECORD --prefix
                                   PREFIX
                                   varargs [varargs ...]
    pyproject_save_files.py: error: the following arguments are required: varargs

After:

    %pyproject_buildrequires bogus_arg
    usage: %pyproject_buildrequires [-w] [-R] [-e TOXENVS] [-t] [-x EXTRAS] [-N]
                                    [REQUIREMENTS.TXT ...]
    %pyproject_buildrequires: error: argument REQUIREMENTS.TXT: can't open 'bogus_arg': ...

    %pyproject_save_files
    ...
    usage: %pyproject_save_files MODULE_GLOB [MODULE_GLOB ...] [+auto]
    %pyproject_save_files: error: the following arguments are required: MODULE_GLOB

Related: rhbz#2168193
2023-02-13 16:42:58 +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
Miro Hrončok 07598e61d1 Use tomllib from the standard library on Python 3.11+
Related: rhbz#2117571
2022-08-11 12:56:41 +02:00
Miro Hrončok 235e0c94a6 Allow building wheels in %pyproject_buildrequires to support other build backends
The hook is optional, see https://www.python.org/dev/peps/pep-0517/#prepare-metadata-for-build-wheel

> If a build frontend needs this information and the method is not defined,
> it should call build_wheel and look at the resulting metadata directly.

This is not yet automatically detected because the feature is provisional.
Use `%pyproject_buildrequires -w` to opt-in.

Resolves: rhbz#2060109
2022-05-06 12:19:26 +02:00
Lumir Balhar 17cd08d6a0 Updated compatibility with tox4
Related: rhbz#2060109
2022-03-02 18:33:48 +01:00
Miro Hrončok 93cf48f615 %pyproject_buildrequires: Make -r (include runtime) the default, use -R to opt-out
See the proposal:
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/2R6NKELTHAWE6PI3CCZBVW5PMGO5VPDG/

 - -N now implies -R
 - the macro still guards against -Nr and now also against -Rr

Related: rhbz#1950291
2022-01-26 11:41:43 +01:00
Miro Hrončok 655f6dda0e %pyproject_buildrequires: Accept installed pre-releases for all requirements
Related: rhbz#1950291
2022-01-26 11:27:08 +01:00
Benjamin A. Beasley 21166f584a Change “requirement file” to match “requirements file[s]” elsewhere
Related: rhbz#1950291
2021-08-10 10:52:23 +02:00
Benjamin A. Beasley 4d93e74bf2 Fix two misspellings of “requirements,” one user-visible
Related: rhbz#1950291
2021-08-10 10:52:23 +02:00
Petr Viktorin a3a1caf32a Split requirements.txt parsing to its own module; test & improve it
Related: rhbz#1950291
2021-08-10 10:52:23 +02:00
Miro Hrončok f190b5b225 %pyproject_buildrequires now fails when it encounters an invalid requirement
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1983053

Related: rhbz#1950291
2021-08-10 10:52:23 +02:00
Tomas Hrnciar d74e61b485 %pyproject_buildrequires: Fallback to setuptools.build_meta:__legacy__ only if setup.py exists
Fixes: rhbz#1976459

Related: rhbz#1950291
2021-08-10 10:52:05 +02:00
Miro Hrončok 7602b9a77a %pyproject_buildrequires: Support x.* versions
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1981558

Related: rhbz#1950291
2021-08-10 10:51:46 +02:00
Tomas Hrnciar aac0af8401 Generate BuildRequires from file
%pyproject_buildrequires macro now accepts multiple file names to load
additional dependencies from them.

New option -N was added to disable automatical generation of requirements
in case package does not use build system. Option -N cannot be used in
combination with options -r, -e, -t, -x.

Co-authored-by: Miro Hrončok <miro@hroncok.cz>

Related: rhbz#1950291
2021-07-09 17:30:46 +02:00
Miro Hrončok dd25ce59a6 Don't accidentally treat "~= X.0" requirement as "~= X"
Don't canonicalize the version twice.

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

Related: rhbz#1950291
2021-06-30 13:08:48 +02:00
Miro Hrončok a8147ee22b Fix a typo
Related: rhbz#1950291
2021-06-30 12:21:50 +02:00
Miro Hrončok 2c0257dc43 Generate BuildRequires on extras in lower case
Fixes: rhbz#1947074
Related: rhbz#1950291
2021-04-22 18:16:02 +02:00
Miro Hrončok cd82d51b8a Handle tox provision (tox.requires / tox.minversion)
Related: rhbz#1950291
2021-04-22 18:15:57 +02:00
DistroBaker 795a9b3332 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/pyproject-rpm-macros.git#26bb3cb4d123a7f57df5ec56b17ccbf3d415c505
2021-02-04 13:32:12 +00:00
DistroBaker 5919cec39c 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/pyproject-rpm-macros.git#6a8d86ed709871dc99fda2a02fb9e21d362c637e
2020-12-04 19:01:54 +01:00
Troy Dawson bdcdcffab9 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/pyproject-rpm-macros#38ef5fb85baa8d9529853c325ddd5e3fb2ec08a7
2020-11-16 15:10:26 -08:00
DistroBaker a2bd1e357d 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/pyproject-rpm-macros.git#6a8d86ed709871dc99fda2a02fb9e21d362c637e
2020-11-04 23:27:14 +01:00
Troy Dawson 89b6866906 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/pyproject-rpm-macros#6a44fe2d7a819cdcb55159d19c6878419871b41f
2020-10-14 16:43:13 -07:00