#115 Support the extras configuration option of tox in %pyproject_buildrequires -t, support multiple -x options for %pyproject_buildrequires
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros tox_extras  into  master

file modified
+5 -1
@@ -46,7 +46,7 @@ 

  BuildRequires: python3dist(pip)

  BuildRequires: python3dist(setuptools)

  BuildRequires: python3dist(toml)

- BuildRequires: python3dist(tox-current-env) >= 0.0.2

+ BuildRequires: python3dist(tox-current-env) >= 0.0.3

  BuildRequires: python3dist(wheel)

  %endif

  
@@ -96,6 +96,10 @@ 

  %changelog

  * Tue Sep 29 2020 Lumír Balhar <lbalhar@redhat.com> - 0-30

  - Process RECORD files in %%pyproject_install and remove them

+ - Support the extras configuration option of tox in %%pyproject_buildrequires -t

+ - Support multiple -x options for %%pyproject_buildrequires

+ - Fixes: rhbz#1877977

+ - Fixes: rhbz#1877978

  

  * Wed Sep 23 2020 Miro Hrončok <mhroncok@redhat.com> - 0-29

  - Check the requirements after installing "requires_for_build_wheel"

file modified
+26 -14
@@ -49,20 +49,29 @@ 

  

  class Requirements:

      """Requirement printer"""

-     def __init__(self, get_installed_version, extras='',

+     def __init__(self, get_installed_version, extras=None,

                   generate_extras=False, python3_pkgversion='3'):

          self.get_installed_version = get_installed_version

+         self.extras = set()

  

          if extras:

-             self.marker_envs = [{'extra': e.strip()} for e in extras.split(',')]

-         else:

-             self.marker_envs = [{'extra': ''}]

+             for extra in extras:

+                 self.add_extras(*extra.split(','))

  

          self.missing_requirements = False

  

          self.generate_extras = generate_extras

          self.python3_pkgversion = python3_pkgversion

  

+     def add_extras(self, *extras):

+         self.extras |= set(e.strip() for e in extras)

+ 

+     @property

+     def marker_envs(self):

+         if self.extras:

+             return [{'extra': e} for e in sorted(self.extras)]

+         return [{'extra': ''}]

+ 

      def evaluate_all_environamnets(self, requirement):

          for marker_env in self.marker_envs:

              if requirement.marker.evaluate(environment=marker_env):
@@ -226,18 +235,20 @@ 

                  f'WARNING: Skipping dependency line: {line}\n'

                  + f'    tox deps options other than -r are not supported (yet).',

              )

-         else:

+         elif line:

              packages.append(line)

      return packages

  

  

  def generate_tox_requirements(toxenv, requirements):

-     requirements.add('tox-current-env >= 0.0.2', source='tox itself')

+     requirements.add('tox-current-env >= 0.0.3', source='tox itself')

      requirements.check(source='tox itself')

-     with tempfile.NamedTemporaryFile('r') as depfile:

+     with tempfile.NamedTemporaryFile('r') as deps, tempfile.NamedTemporaryFile('r') as extras:

          r = subprocess.run(

-             [sys.executable, '-m', 'tox', '--print-deps-to-file',

-              depfile.name, '-qre', toxenv],

+             [sys.executable, '-m', 'tox',

+              '--print-deps-to', deps.name,

+              '--print-extras-to', extras.name,

+              '-qre', toxenv],

              check=False,

              encoding='utf-8',

              stdout=subprocess.PIPE,
@@ -247,8 +258,9 @@ 

              print_err(r.stdout, end='')

          r.check_returncode()

  

-         deplines = depfile.read().splitlines()

+         deplines = deps.read().splitlines()

          packages = parse_tox_requires_lines(deplines)

+         requirements.add_extras(*extras.read().splitlines())

          requirements.extend(packages,

                              source=f'tox --print-deps-only: {toxenv}')

  
@@ -265,7 +277,7 @@ 

  

  

  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

      generate_extras=False, python3_pkgversion="3",

  ):
@@ -274,7 +286,7 @@ 

      This is the main Python entry point.

      """

      requirements = Requirements(

-         get_installed_version, extras=extras,

+         get_installed_version, extras=extras or [],

          generate_extras=generate_extras,

          python3_pkgversion=python3_pkgversion

      )
@@ -310,9 +322,9 @@ 

                '(implies --runtime)'),

      )

      parser.add_argument(

-         '-x', '--extras', metavar='EXTRAS', default='',

+         '-x', '--extras', metavar='EXTRAS', action='append',

          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(

          '--generate-extras', action='store_true',

@@ -238,7 +238,8 @@ 

      wheel: 1

      pyyaml: 1

    include_runtime: true

-   extras: testing

+   extras:

+     - testing

    setup.py: *pytest_setup_py

    expected: |

      python3dist(setuptools) >= 40.8
@@ -264,7 +265,9 @@ 

      wheel: 1

      pyyaml: 1

    include_runtime: true

-   extras: testing,more-testing, even-more-testing , cool-feature

+   extras:

+     - testing,more-testing

+     - even-more-testing , cool-feature

    setup.py: |

      from setuptools import setup

      setup(
@@ -290,7 +293,7 @@ 

      setuptools: 50

      wheel: 1

      tox: 3.5.3

-     tox-current-env: 0.0.2

+     tox-current-env: 0.0.3

    toxenv: py3

    setup.py: |

      from setuptools import setup
@@ -312,8 +315,52 @@ 

      python3dist(setuptools) >= 40.8

      python3dist(wheel)

      python3dist(wheel)

-     python3dist(tox-current-env) >= 0.0.2

+     python3dist(tox-current-env) >= 0.0.3

      python3dist(toxdep1)

      python3dist(toxdep2)

      python3dist(inst)

    result: 0

+ 

+ Tox extras:

+   installed:

+     setuptools: 50

+     wheel: 1

+     tox: 3.5.3

+     tox-current-env: 0.0.3

+   toxenv: py3

+   setup.py: |

+     from setuptools import setup

+     setup(

+         name='test',

+         version='0.1',

+         install_requires=['inst'],

+         extras_require={

+             'extra1':  ['dep11 > 11', 'dep12'],

+             'extra2': ['dep21', 'dep22', 'dep23'],

+             'nope': ['nopedep'],

+         }

+     )

+   tox.ini: |

+     [tox]

+     envlist = py36,py37,py38

+     [testenv]

+     deps =

+         toxdep

+     extras =

+         extra2

+         extra1

+     commands =

+         true

+   expected: |

+     python3dist(setuptools) >= 40.8

+     python3dist(wheel)

+     python3dist(wheel)

+     python3dist(tox-current-env) >= 0.0.3

+     python3dist(toxdep)

+     python3dist(inst)

+     python3dist(dep11) > 11

+     python3dist(dep12)

+     python3dist(dep21)

+     python3dist(dep22)

+     python3dist(dep23)

+   result: 0

@@ -43,7 +43,7 @@ 

          generate_requires(

              get_installed_version=get_installed_version,

              include_runtime=case.get('include_runtime', False),

-             extras=case.get('extras', ''),

+             extras=case.get('extras', []),

              toxenv=case.get('toxenv', None),

              generate_extras=case.get('generate_extras', False),

          )

@@ -0,0 +1,73 @@ 

+ Name:           python-dns-lexicon

+ Version:        3.4.0

+ Release:        0%{?dist}

+ Summary:        Manipulate DNS records on various DNS providers in a standardized/agnostic way

+ License:        MIT

+ URL:            https://github.com/AnalogJ/lexicon

+ Source0:        %{url}/archive/v%{version}/lexicon-%{version}.tar.gz

+ BuildArch:      noarch

+ 

+ BuildRequires:  pyproject-rpm-macros

+ BuildRequires:  python3-devel

+ 

+ %description

+ This package has extras specified in tox configuration,

+ we test that the extras are installed when -e is used.

+ This package also uses a custom toxenv and creates several extras subpackages.

+ 

+ 

+ %package -n     python3-dns-lexicon

+ Summary:        %{summary}

+ 

+ %description -n python3-dns-lexicon

+ ...

+ 

+ 

+ %pyproject_extras_subpackage -n python3-dns-lexicon plesk route53

+ 

+ 

+ %prep

+ %autosetup -n lexicon-%{version}

+ # The tox configuration lists a [dev] extra, but that installs nothing (is missing).

+ # The test requirements are only specified via poetry.dev-dependencies.

+ # Here we amend the data a bit so we can test more things, adding the tests deps to the dev extra:

+ sed -i \

+ 's/\[tool.poetry.extras\]/'\

+ 'pytest = {version = ">3", optional = true}\n'\

+ 'vcrpy = {version = ">1", optional = true}\n\n'\

+ '[tool.poetry.extras]\n'\

+ 'dev = ["pytest", "vcrpy"]/' pyproject.toml

+ 

+ 

+ %generate_buildrequires

+ %if 0%{?fedora} >= 33 || 0%{?rhel} >= 9

+ # We use the "light" toxenv because the default one installs the [full] extra and we don't have all the deps.

+ # Note that [full] contains [plesk] and [route53] but we specify them manually instead:

+ %pyproject_buildrequires -e light -x plesk -x route53

+ %else

+ # older Fedora don't have the required runtime dependencies, so we don't test it there

+ %pyproject_buildrequires

+ %endif

+ 

+ 

+ %build

+ %pyproject_wheel

+ 

+ 

+ %install

+ %pyproject_install

+ %pyproject_save_files lexicon

+ 

+ 

+ %if 0%{?fedora} >= 33 || 0%{?rhel} >= 9

+ %check

+ # we cannot use %%tox here, because the configured commands call poetry directly :/

+ # we use %%pytest instead, running a subset of tests not o waste CI time

+ %pytest -k "test_route53 or test_plesk"

+ %endif

+ 

+ 

+ %files -n python3-dns-lexicon -f %{pyproject_files}

+ %license LICENSE

+ %doc README.rst

+ %{_bindir}/lexicon

@@ -14,6 +14,8 @@ 

  %description

  This package uses multiple extras in %%pyproject_extras_subpkg and in

  %%pyproject_buildrequires.

+ This test is mostly obsoleted by python-dns-lexicon.spec on Fedora 33+,

+ but we keep it around until Fedora 32 EOL.

  

  

  %package -n python3-requests

file modified
+3
@@ -64,6 +64,9 @@ 

      - printrun:

          dir: .

          run: ./mocktest.sh printrun

+     - dns_lexicon:

+         dir: .

+         run: ./mocktest.sh python-dns-lexicon

      required_packages:

      - mock

      - rpmdevtools

rebased onto fafcd49a022ae4d109130dd04494d86a742004e7

3 years ago

Build succeeded.

4 new commits added

  • CI: Replace requests with dns-lexicon to tests more things
  • Skip empty lines from tox deps
  • Support multiple -x options for %pyproject_buildrequires
  • Support the extras configuration option of tox in %pyproject_buildrequires -t
3 years ago

+1, merge if it passes

Build succeeded.

4 new commits added

  • CI: Add dns-lexicon to tests new things
  • Skip empty lines from tox deps
  • Support multiple -x options for %pyproject_buildrequires
  • Support the extras configuration option of tox in %pyproject_buildrequires -t
3 years ago

4 new commits added

  • CI: Add dns-lexicon to tests new things
  • Skip empty lines from tox deps
  • Support multiple -x options for %pyproject_buildrequires
  • Support the extras configuration option of tox in %pyproject_buildrequires -t
3 years ago

Build succeeded.

rebased onto 9f3eea2

3 years ago

Build succeeded.

Pull-Request has been merged by churchyard

3 years ago