Bug 2240590 - ValueError: Requirement 'tox >= None' from tox provision (minversion) is invalid.
Summary: ValueError: Requirement 'tox >= None' from tox provision (minversion) is inva...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: pyproject-rpm-macros
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-09-25 11:43 UTC by Miro Hrončok
Modified: 2023-11-03 18:24 UTC (History)
5 users (show)

Fixed In Version: pyproject-rpm-macros-1.10.0-1.fc40 pyproject-rpm-macros-1.10.0-1.fc38 pyproject-rpm-macros-1.10.0-1.fc37 pyproject-rpm-macros-1.10.0-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-30 03:34:48 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources pyproject-rpm-macros pull-request 414 0 None None None 2023-09-25 12:53:28 UTC

Description Miro Hrončok 2023-09-25 11:43:27 UTC
Consider the following spec:

===============================
Name:           minversion-none
Version:        0
Release:        0
Summary:        ...
License:        MIT
BuildArch:      noarch

BuildRequires:  python3-devel

%description
...


%prep
touch setup.py
cat > tox.ini << EOF
[tox]
requires =
    you-cant-have-this
EOF


%generate_buildrequires
%pyproject_buildrequires -t
===============================

Build it with pyproject-rpm-macros 1.9.0-2.fc39.

You'll get:

+ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --generate-extras --python3_pkgversion 3 --wheeldir /builddir/build/BUILD/pyproject-wheeldir --output /builddir/build/BUILD/minversion-none-0-0.x86_64-pyproject-buildrequires -t
Handling setuptools >= 40.8 from default build backend
Requirement satisfied: setuptools >= 40.8
   (installed: setuptools 67.7.2)
Handling wheel from default build backend
Requirement satisfied: wheel
   (installed: wheel 0.40.0)
Handling wheel from get_requires_for_build_wheel
Requirement satisfied: wheel
   (installed: wheel 0.40.0)
Handling tox-current-env >= 0.0.6 from tox itself
Requirement satisfied: tox-current-env >= 0.0.6
   (installed: tox-current-env 0.0.11)
ROOT: HandledError| provisioning explicitly disabled within /usr/bin/python3, but is missing [requires (has)]: you-cant-have-this and wrote to /builddir/build/BUILD/.pyproject-builddir/tmpovnqr8qa
Handling tox >= None from tox provision (minversion)
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/packaging/requirements.py", line 35, in __init__
    parsed = _parse_requirement(requirement_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 64, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 82, in _parse_requirement
    url, specifier, marker = _parse_requirement_details(tokenizer)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 126, in _parse_requirement_details
    marker = _parse_requirement_marker(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 147, in _parse_requirement_marker
    tokenizer.raise_syntax_error(
  File "/usr/lib/python3.12/site-packages/packaging/_tokenizer.py", line 165, in raise_syntax_error
    raise ParserSyntaxError(
packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after name and no valid version specifier)
    tox >= None
        ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 107, in add
    requirement = Requirement(requirement_str)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/requirements.py", line 37, in __init__
    raise InvalidRequirement(str(e)) from e
packaging.requirements.InvalidRequirement: Expected end or semicolon (after name and no valid version specifier)
    tox >= None
        ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 555, in main
    generate_requires(
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 454, in generate_requires
    generate_tox_requirements(toxenv, requirements)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 390, in generate_tox_requirements
    requirements.add(f'tox >= {provision_requires["minversion"]}',
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 113, in add
    raise ValueError(message)
ValueError: Requirement 'tox >= None' from tox provision (minversion) is invalid.

RPM build warnings:

RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.rR8yiJ (%generate_buildrequires)




This is caused by tox 4 incompatibility in pyproject_buildrequires.py

We have:

            provision_requires = json.loads(provision_content)
            if 'minversion' in provision_requires:
                requirements.add(f'tox >= {provision_requires["minversion"]}',
                                 source='tox provision (minversion)')

But tox 4 generates:

    {
        "minversion": null,
        "requires": [
            "you-cant-have-this",
            "tox"
        ]
    }

Hence we should update the conditional to check for non-None value.

Reproducible: Always

Steps to Reproduce:
1. Build the provided spec
Actual Results:  
Build fails with invalid Python requirements: Requirement 'tox >= None' from tox provision (minversion) is invalid.

Expected Results:  
Build fails with unmet RPM requirements: python3dist(you-cant-have-this)

Comment 1 Miro Hrončok 2023-09-25 11:53:14 UTC
This fixes the problem:

  -            if 'minversion' in provision_requires:
  +            if provision_requires.get("minversion") is not None:

Obviously, this also needs tests etc.

Comment 3 Fedora Update System 2023-09-27 16:24:21 UTC
FEDORA-2023-bec0eb6622 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-bec0eb6622

Comment 4 Fedora Update System 2023-09-27 16:25:45 UTC
FEDORA-2023-bec0eb6622 has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 5 Fedora Update System 2023-09-27 16:30:48 UTC
FEDORA-2023-fce9985dc0 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fce9985dc0

Comment 6 Fedora Update System 2023-09-27 16:30:48 UTC
FEDORA-2023-1e499386d7 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-1e499386d7

Comment 7 Fedora Update System 2023-09-27 16:30:49 UTC
FEDORA-2023-f292d597c2 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-f292d597c2

Comment 8 Fedora Update System 2023-09-28 01:31:41 UTC
FEDORA-2023-fce9985dc0 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-fce9985dc0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-fce9985dc0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2023-09-28 02:05:45 UTC
FEDORA-2023-1e499386d7 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-1e499386d7`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-1e499386d7

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2023-09-28 20:17:30 UTC
FEDORA-2023-f292d597c2 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-f292d597c2`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f292d597c2

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2023-09-30 03:34:48 UTC
FEDORA-2023-1e499386d7 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2023-10-13 01:32:12 UTC
FEDORA-2023-fce9985dc0 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2023-11-03 18:24:03 UTC
FEDORA-2023-f292d597c2 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.