#134 F31: Allow multiple -e in %pyproject_buildrequires
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros multiple_toxenv_options2  into  f31

file modified
+1 -1
@@ -134,7 +134,7 @@ 

   - If not defined, sets `$PYTHONPATH` to `%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}`

   - If not defined, sets `$TOX_TESTENV_PASSENV` to `*`

   - Runs `tox` with `-q` (quiet), `--recreate` and `--current-env` (from [tox-current-env]) flags

-  - Implicitly uses the tox environment name stored in `%{toxenv}` - as overridden by `%pyproject_buildrequires -t`

+  - Implicitly uses the tox environment name stored in `%{toxenv}` - as overridden by `%pyproject_buildrequires -e`

  

  By using the `-e` flag, you can use a different tox environment(s):

  

file modified
+1 -1
@@ -81,7 +81,7 @@ 

  

  

  %pyproject_buildrequires(rxte:) %{expand:\\\

- %{-e:%{expand:%global toxenv %{-e*}}}

+ %{-e:%{expand:%global toxenv %(%{__python3} -s %{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py %{?**})}}

  echo 'python%{python3_pkgversion}-devel'

  echo 'python%{python3_pkgversion}dist(pip) >= 19'

  echo 'python%{python3_pkgversion}dist(packaging)'

file modified
+8 -1
@@ -6,7 +6,7 @@ 

  

  # Keep the version at zero and increment only release

  Version:        0

- Release:        31%{?dist}

+ Release:        32%{?dist}

  

  # Macro files

  Source001:      macros.pyproject
@@ -16,6 +16,7 @@ 

  Source102:      pyproject_save_files.py

  Source103:      pyproject_convert.py

  Source104:      pyproject_preprocess_record.py

+ Source105:      pyproject_construct_toxenv.py

  

  # Tests

  Source201:      test_pyproject_buildrequires.py
@@ -75,6 +76,7 @@ 

  install -m 644 pyproject_convert.py %{buildroot}%{_rpmconfigdir}/redhat/

  install -m 644 pyproject_save_files.py  %{buildroot}%{_rpmconfigdir}/redhat/

  install -m 644 pyproject_preprocess_record.py %{buildroot}%{_rpmconfigdir}/redhat/

+ install -m 644 pyproject_construct_toxenv.py %{buildroot}%{_rpmconfigdir}/redhat/

  

  %if %{with tests}

  %check
@@ -89,11 +91,16 @@ 

  %{_rpmconfigdir}/redhat/pyproject_convert.py

  %{_rpmconfigdir}/redhat/pyproject_save_files.py

  %{_rpmconfigdir}/redhat/pyproject_preprocess_record.py

+ %{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py

  

  %doc README.md

  %license LICENSE

  

  %changelog

+ * Tue Nov 03 2020 Miro Hrončok <mhroncok@redhat.com> - 0-32

+ - Allow multiple -e in %%pyproject_buildrequires

+ - Fixes: rhbz#1886509

+ 

  * Mon Oct 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-31

  - Support PEP 517 list based backend-path

  

file modified
+7 -5
@@ -244,6 +244,7 @@ 

  

  

  def generate_tox_requirements(toxenv, requirements):

+     toxenv = ','.join(toxenv)

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

      requirements.check(source='tox itself')

      with tempfile.NamedTemporaryFile('r') as deps, tempfile.NamedTemporaryFile('r') as extras:
@@ -297,7 +298,7 @@ 

      try:

          backend = get_backend(requirements)

          generate_build_requirements(backend, requirements)

-         if toxenv is not None:

+         if toxenv:

              include_runtime = True

              generate_tox_requirements(toxenv, requirements)

          if include_runtime:
@@ -315,8 +316,8 @@ 

          help='Generate run-time requirements',

      )

      parser.add_argument(

-         '-e', '--toxenv', metavar='TOXENVS', default=None,

-         help=('specify tox environments'

+         '-e', '--toxenv', metavar='TOXENVS', action='append',

+         help=('specify tox environments (comma separated and/or repeated)'

                '(implies --tox)'),

      )

      parser.add_argument(
@@ -346,8 +347,9 @@ 

  

      if args.tox:

          args.runtime = True

-         args.toxenv = (args.toxenv or os.getenv('RPM_TOXENV') or

-                        f'py{sys.version_info.major}{sys.version_info.minor}')

+         if not args.toxenv:

+             _default = f'py{sys.version_info.major}{sys.version_info.minor}'

+             args.toxenv = [os.getenv('RPM_TOXENV', _default)]

  

      if args.extras:

          args.runtime = True

@@ -294,7 +294,8 @@ 

      wheel: 1

      tox: 3.5.3

      tox-current-env: 0.0.3

-   toxenv: py3

+   toxenv:

+     - py3

    setup.py: |

      from setuptools import setup

      setup(
@@ -327,7 +328,8 @@ 

      wheel: 1

      tox: 3.5.3

      tox-current-env: 0.0.3

-   toxenv: py3

+   toxenv:

+     - py3

    setup.py: |

      from setuptools import setup

      setup(

@@ -0,0 +1,15 @@ 

+ import argparse

+ import sys

+ 

+ 

+ def main(argv):

+     parser = argparse.ArgumentParser(

+         description='Parse -e arguments instead of RPM getopt.'

+     )

+     parser.add_argument('-e', '--toxenv', action='append')

+     args, _ = parser.parse_known_args(argv)

+     return ','.join(args.toxenv)

+ 

+ 

+ if __name__ == '__main__':

+     print(main(sys.argv[1:]))

@@ -10,6 +10,7 @@ 

  

  BuildArch:      noarch

  BuildRequires:  pyproject-rpm-macros

+ BuildRequires:  python3-devel

  

  %description

  Tests building with the poetry build backend.

@@ -9,6 +9,7 @@ 

  

  BuildArch:      noarch

  BuildRequires:  pyproject-rpm-macros

+ BuildRequires:  python3-devel

  

  %description

  This package contains one .py module
@@ -41,8 +42,8 @@ 

  

  %check

  # Internal check: Top level __pycache__ is never owned

- grep -vE '/__pycache__$' %{pyproject_files}

- grep -vE '/__pycache__/$' %{pyproject_files}

+ ! grep -E '/__pycache__$' %{pyproject_files}

+ ! grep -E '/__pycache__/$' %{pyproject_files}

  grep -F '/__pycache__/' %{pyproject_files}

  

  

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

  URL:                https://github.com/timothycrosley/%{modname}

  Source0:            %{url}/archive/%{version}-2/%{modname}-%{version}-2.tar.gz

  BuildArch:          noarch

+ BuildRequires:      python3-devel

  BuildRequires:      pyproject-rpm-macros

  

  %description
@@ -46,7 +47,7 @@ 

  test -d %{buildroot}%{python3_sitelib}/%{modname}-%{version}.dist-info/

  

  # Internal check that executables are not present when +auto was not used with %%pyproject_save_files

- grep -vF %{buildroot}%{_bindir}/%{modname} %{pyproject_files}

+ ! grep -F %{buildroot}%{_bindir}/%{modname} %{pyproject_files}

  

  

  %files -n python3-%{modname} -f %{pyproject_files}

file modified
+7 -6
@@ -5,6 +5,7 @@ 

  Summary:        An object-oriented API to access LDAP directory servers

  Source0:        %{pypi_source}

  

+ BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

  

  BuildRequires:  cyrus-sasl-devel
@@ -63,14 +64,14 @@ 

  

  # Internal check: Unmatched modules are not supposed to be listed in %%{pyproject_files}

  # We'll list them explicitly

- grep -vF %{python3_sitearch}/ldif.py %{pyproject_files}

- grep -vF %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.pyc %{pyproject_files}

- grep -vF %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.opt-1.pyc %{pyproject_files}

- grep -vF %{python3_sitearch}/slapdtest/ %{pyproject_files}

+ ! grep -F %{python3_sitearch}/ldif.py %{pyproject_files}

+ ! grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.pyc %{pyproject_files}

+ ! grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.opt-1.pyc %{pyproject_files}

+ ! grep -F %{python3_sitearch}/slapdtest %{pyproject_files}

  

  # Internal check: Top level __pycache__ is never owned

- grep -vE '/__pycache__$' %{pyproject_files}

- grep -vE '/__pycache__/$' %{pyproject_files}

+ ! grep -E '/__pycache__$' %{pyproject_files}

+ ! grep -E '/__pycache__/$' %{pyproject_files}

  

  

  %files -n python3-ldap -f %{pyproject_files}

@@ -8,6 +8,7 @@ 

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

  

  BuildRequires:  gcc

+ BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

  

  # optional dependency, listed explicitly to have the extension module:

@@ -9,6 +9,7 @@ 

  Source0:        %{pypi_source}

  

  BuildArch:      noarch

+ BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

  

  %description

@@ -10,6 +10,7 @@ 

  

  BuildArch:      noarch

  BuildRequires:  pyproject-rpm-macros

+ # we don't BR python3-devel here just for test purposes, but we recommend you do it

  

  %description

  A pure Python library. The package contains tox.ini. Does not contain executables.

@@ -8,6 +8,7 @@ 

  Source0:        %{pypi_source}

  

  BuildArch:      noarch

+ BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

  

  %description

@@ -9,6 +9,8 @@ 

  BuildArch:      noarch

  BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

+ BuildRequires:  /usr/bin/git

+ BuildRequires:  /usr/bin/hg

  

  %description

  Here we test that %%pyproject_extras_subpkg works and generates
@@ -16,6 +18,10 @@ 

  

  Note that it only works on Fedora 33+.

  

+ We also check passing multiple -e flags to %%pyproject_buildrequires.

+ The tox environments also have a dependency on an extra ("toml").

+ 

+ 

  %package -n python3-setuptools_scm

  Summary:        %{summary}

  
@@ -28,9 +34,22 @@ 

  %prep

  %autosetup -p1 -n setuptools_scm-%{version}

  

+ # there is a mistake in the flake8 environment configuration

+ # https://github.com/pypa/setuptools_scm/pull/444

+ # https://github.com/pypa/setuptools_scm/pull/489

+ sed -i -e 's@flake8 setuptools_scm/@flake8 src/setuptools_scm/@' -e 's@--exclude=setuptools_scm/@--exclude=src/setuptools_scm/@' tox.ini

+ 

  

  %generate_buildrequires

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

+ # Note that you should not run flake8-like linters in Fedora spec files,

+ # here we do it solely to check the *ability* to use multiple toxenvs.

+ %pyproject_buildrequires -e %{default_toxenv}-test -e flake8

+ %else

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

  %pyproject_buildrequires

+ %endif

+ 

  

  

  %build
@@ -43,6 +62,16 @@ 

  

  

  %check

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

+ # This tox should run all the toxenvs specified via -e in %%pyproject_buildrequires

+ # We only run some of the tests (running all of them requires network connection and is slow)

+ %tox -- -- -k test_version | tee toxlog

+ 

+ # Internal check for our macros: Assert both toxenvs were executed.

+ grep -F 'py%{python3_version_nodots}-test: commands succeeded' toxlog

+ grep -F 'flake8: commands succeeded' toxlog

+ %endif

+ 

  # Internal check for our macros

  # making sure that %%{pyproject_ghost_distinfo} has the right content

  test -f %{pyproject_ghost_distinfo}

file modified
+1
@@ -8,6 +8,7 @@ 

  Source0:        %{pypi_source}

  

  BuildArch:      noarch

+ BuildRequires:  python3-devel

  BuildRequires:  pyproject-rpm-macros

  

  %description

Build failed.

4 new commits added

  • Allow multiple -e in %pyproject_buildrequires
  • CI tests: Use `! grep` to assert something is missing
  • BR python3-devel from the test/example specs
  • Fix name of option that redefines %{toxenv}
3 years ago

Build succeeded.

Pull-Request has been merged by churchyard

3 years ago