#180 %pyproject_buildrequires: Support x.* versions
Merged 2 years ago by churchyard. Opened 2 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros asterisk_version  into  rawhide

@@ -107,6 +107,8 @@ 

  * Fri Jul 09 2021 Miro Hrončok <miro@hroncok.cz> - 0-44

  - Escape weird paths generated by %%pyproject_save_files

  - Fixes rhbz#1976363

+ - Support x.* versions in %%pyproject_buildrequires

+ - Fixes rhbz#1981558

  

  * Thu Jul 01 2021 Tomas Hrnciar <thrnciar@redhat.com> - 0-43

  - Generate BuildRequires from file

file modified
+9 -4
@@ -2,7 +2,6 @@ 

  import sys

  import importlib.metadata

  import argparse

- import functools

  import traceback

  import contextlib

  from io import StringIO
@@ -13,17 +12,23 @@ 

  import email.parser

  import pathlib

  

- print_err = functools.partial(print, file=sys.stderr)

  

  # Some valid Python version specifiers are not supported.

- # Whitelist characters we can handle.

- VERSION_RE = re.compile('[a-zA-Z0-9.-]+')

+ # Allow only the forms we know we can handle.

+ VERSION_RE = re.compile(r'[a-zA-Z0-9.-]+(\.\*)?')

  

  

  class EndPass(Exception):

      """End current pass of generating requirements"""

  

  

+ # nb: we don't use functools.partial to be able to use pytest's capsys

+ # see https://github.com/pytest-dev/pytest/issues/8900

+ def print_err(*args, **kwargs):

+     kwargs.setdefault('file', sys.stderr)

+     print(*args, **kwargs)

+ 

+ 

  try:

      from packaging.requirements import Requirement, InvalidRequirement

      from packaging.utils import canonicalize_name

@@ -69,6 +69,24 @@ 

      requires = ["pkg == 0.$.^.*"]

    except: ValueError

  

+ Single value version with unsupported compatible operator:

+   installed:

+     toml: 1

+   pyproject.toml: |

+     [build-system]

+     requires = ["pkg ~= 42"]

+   stderr_contains: "WARNING: Skipping invalid requirement: pkg ~= 42"

+   result: 0

+ 

+ Asterisk in version with unsupported compatible operator:

+   installed:

+     toml: 1

+   pyproject.toml: |

+     [build-system]

+     requires = ["pkg ~= 0.1.*"]

+   stderr_contains: "WARNING: Skipping invalid requirement: pkg ~= 0.1.*"

+   result: 0

+ 

  Build system dependencies in pyproject.toml with extras:

    generate_extras: true

    installed:
@@ -88,6 +106,7 @@ 

          "compatible ~= 0.4.0",

          "equal == 0.5.0",

          "arbitrary_equal === 0.6.0",

+         "asterisk_equal == 0.6.*",

          "multi[Extras1,Extras2] == 6.0",

          "combo >2, <5, != 3.0.0",

          "invalid!!ignored",
@@ -106,6 +125,7 @@ 

      (python3dist(compatible) >= 0.4 with python3dist(compatible) < 0.5)

      python3dist(equal) = 0.5

      python3dist(arbitrary-equal) = 0.6

+     (python3dist(asterisk-equal) >= 0.6 with python3dist(asterisk-equal) < 0.7)

      python3dist(multi) = 6

      python3dist(multi[extras1]) = 6

      python3dist(multi[extras2]) = 6

@@ -57,8 +57,16 @@ 

      else:

          assert 0 == case['result']

  

-         captured = capsys.readouterr()

-         assert captured.out == case['expected']

+         # this prevents us from accidentally writing "empty" tests

+         # if we ever need to do that, we can remove the check or change it:

+         assert 'expected' in case or 'stderr_contains' in case

+ 

+         out, err = capsys.readouterr()

+ 

+         if 'expected' in case:

+             assert out == case['expected']

+         if 'stderr_contains' in case:

+             assert case['stderr_contains'] in err

      finally:

          for req in requirement_files:

              req.close()

no initial comment

rebased onto 639beee

2 years ago

Build succeeded.

2 new commits added

  • %pyproject_buildrequires: Support x.* versions
  • CI tests: Update pytest's patch for Python 3.10.0b4+
2 years ago

Build succeeded.

rebased onto f88d106e05f863b2d1d620771d9f0beab9824b0d

2 years ago

rebased onto ddaf2e9

2 years ago

Build succeeded.

Pull-Request has been merged by churchyard

2 years ago