Support multiple -x options for %pyproject_buildrequires

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1877978
This commit is contained in:
Miro Hrončok 2020-09-30 22:31:07 +02:00
parent 9f3eea2ae5
commit 2ecbed7441
4 changed files with 15 additions and 9 deletions

View File

@ -97,7 +97,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
* Tue Sep 29 2020 Lumír Balhar <lbalhar@redhat.com> - 0-30 * Tue Sep 29 2020 Lumír Balhar <lbalhar@redhat.com> - 0-30
- Process RECORD files in %%pyproject_install and remove them - Process RECORD files in %%pyproject_install and remove them
- Support the extras configuration option of tox in %%pyproject_buildrequires -t - Support the extras configuration option of tox in %%pyproject_buildrequires -t
- Support multiple -x options for %%pyproject_buildrequires
- Fixes: rhbz#1877977 - Fixes: rhbz#1877977
- Fixes: rhbz#1877978
* Wed Sep 23 2020 Miro Hrončok <mhroncok@redhat.com> - 0-29 * Wed Sep 23 2020 Miro Hrončok <mhroncok@redhat.com> - 0-29
- Check the requirements after installing "requires_for_build_wheel" - Check the requirements after installing "requires_for_build_wheel"

View File

@ -49,13 +49,14 @@ def hook_call():
class Requirements: class Requirements:
"""Requirement printer""" """Requirement printer"""
def __init__(self, get_installed_version, extras='', def __init__(self, get_installed_version, extras=None,
generate_extras=False, python3_pkgversion='3'): generate_extras=False, python3_pkgversion='3'):
self.get_installed_version = get_installed_version self.get_installed_version = get_installed_version
self.extras = set() self.extras = set()
if extras: if extras:
self.add_extras(*extras.split(',')) for extra in extras:
self.add_extras(*extra.split(','))
self.missing_requirements = False self.missing_requirements = False
@ -276,7 +277,7 @@ def python3dist(name, op=None, version=None, python3_pkgversion="3"):
def generate_requires( def generate_requires(
*, include_runtime=False, toxenv=None, extras='', *, include_runtime=False, toxenv=None, extras=None,
get_installed_version=importlib_metadata.version, # for dep injection get_installed_version=importlib_metadata.version, # for dep injection
generate_extras=False, python3_pkgversion="3", generate_extras=False, python3_pkgversion="3",
): ):
@ -285,7 +286,7 @@ def generate_requires(
This is the main Python entry point. This is the main Python entry point.
""" """
requirements = Requirements( requirements = Requirements(
get_installed_version, extras=extras, get_installed_version, extras=extras or [],
generate_extras=generate_extras, generate_extras=generate_extras,
python3_pkgversion=python3_pkgversion python3_pkgversion=python3_pkgversion
) )
@ -321,9 +322,9 @@ def main(argv):
'(implies --runtime)'), '(implies --runtime)'),
) )
parser.add_argument( parser.add_argument(
'-x', '--extras', metavar='EXTRAS', default='', '-x', '--extras', metavar='EXTRAS', action='append',
help='comma separated list of "extras" for runtime requirements ' help='comma separated list of "extras" for runtime requirements '
'(e.g. -x testing,feature-x) (implies --runtime)', '(e.g. -x testing,feature-x) (implies --runtime, can be repeated)',
) )
parser.add_argument( parser.add_argument(
'--generate-extras', action='store_true', '--generate-extras', action='store_true',

View File

@ -238,7 +238,8 @@ Run dependencies with extras (selected):
wheel: 1 wheel: 1
pyyaml: 1 pyyaml: 1
include_runtime: true include_runtime: true
extras: testing extras:
- testing
setup.py: *pytest_setup_py setup.py: *pytest_setup_py
expected: | expected: |
python3dist(setuptools) >= 40.8 python3dist(setuptools) >= 40.8
@ -264,7 +265,9 @@ Run dependencies with multiple extras:
wheel: 1 wheel: 1
pyyaml: 1 pyyaml: 1
include_runtime: true include_runtime: true
extras: testing,more-testing, even-more-testing , cool-feature extras:
- testing,more-testing
- even-more-testing , cool-feature
setup.py: | setup.py: |
from setuptools import setup from setuptools import setup
setup( setup(

View File

@ -43,7 +43,7 @@ def test_data(case_name, capsys, tmp_path, monkeypatch):
generate_requires( generate_requires(
get_installed_version=get_installed_version, get_installed_version=get_installed_version,
include_runtime=case.get('include_runtime', False), include_runtime=case.get('include_runtime', False),
extras=case.get('extras', ''), extras=case.get('extras', []),
toxenv=case.get('toxenv', None), toxenv=case.get('toxenv', None),
generate_extras=case.get('generate_extras', False), generate_extras=case.get('generate_extras', False),
) )