#233 %pyproject_buildrequires: Make -r (include runtime) the default, use -R to opt-out
Merged 2 years ago by churchyard. Opened 2 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros runtime_default  into  rawhide

file modified
+12 -6
@@ -42,7 +42,8 @@ 

      %pyproject_buildrequires

  

  This will add build dependencies according to [PEP 517] and [PEP 518].

- To also add run-time and test-time dependencies, see the section below.

+ This also adds run-time dependencies by default and

+ can add test-time dependencies, see the section below.

  If you need more dependencies, such as non-Python libraries, BuildRequire

  them manually.

  
@@ -68,17 +69,22 @@ 

  Adding run-time and test-time dependencies

  ------------------------------------------

  

- To run tests in the `%check` section, the package's runtime dependencies

- often need to also be included as build requirements.

- This can be done using the `-r` flag:

+ To run tests or import checks in the `%check` section,

+ the package's runtime dependencies need to also be included as build requirements.

  

-     %generate_buildrequires

-     %pyproject_buildrequires -r

+ Hence, `%pyproject_buildrequires` also generates runtime dependencies by default.

  

  For this to work, the project's build system must support the

  [`prepare-metadata-for-build-wheel` hook](https://www.python.org/dev/peps/pep-0517/#prepare-metadata-for-build-wheel).

  The popular buildsystems (setuptools, flit, poetry) do support it.

  

+ This behavior can be disabled

+ (e.g. when the project's build system does not support it)

+ using the `-R` flag:

+ 

+     %generate_buildrequires

+     %pyproject_buildrequires -R

+ 

  For projects that specify test requirements using an [`extra`

  provide](https://packaging.python.org/specifications/core-metadata/#provides-extra-multiple-use),

  these can be added using the `-x` flag.

file modified
+2 -1
@@ -115,7 +115,8 @@ 

  %toxenv %{default_toxenv}

  

  

- %pyproject_buildrequires(rxtNe:) %{expand:\\\

+ %pyproject_buildrequires(rRxtNe:) %{expand:\\\

+ %{-R:%{-r:%{error:The -R and -r options are mutually exclusive}}}

  %{-N:

  %{-r:%{error:The -N and -r options are mutually exclusive}}

  %{-x:%{error:The -N and -x options are mutually exclusive}}

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

  

  # Keep the version at zero and increment only release

  Version:        0

- Release:        52%{?dist}

+ Release:        53%{?dist}

  

  # Macro files

  Source001:      macros.pyproject
@@ -116,6 +116,9 @@ 

  %license LICENSE

  

  %changelog

+ * Fri Jan 14 2022 Miro Hrončok <mhroncok@redhat.com> - 0-53

+ - %%pyproject_buildrequires: Make -r (include runtime) the default, use -R to opt-out

+ 

  * Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-52

  - Handle legacy version specifiers that would previously raise exceptions.

  

file modified
+9 -2
@@ -367,8 +367,12 @@ 

          description='Generate BuildRequires for a Python project.'

      )

      parser.add_argument(

-         '-r', '--runtime', action='store_true',

-         help='Generate run-time requirements',

+         '-r', '--runtime', action='store_true', default=True,

+         help='Generate run-time requirements (default, disable with -R)',

+     )

+     parser.add_argument(

+         '-R', '--no-runtime', action='store_false', dest='runtime',

+         help="Don't generate run-time requirements (implied by -N)",

      )

      parser.add_argument(

          '-e', '--toxenv', metavar='TOXENVS', action='append',
@@ -405,6 +409,9 @@ 

  

      args = parser.parse_args(argv)

  

+     if not args.use_build_system:

+         args.runtime = False

+ 

      if args.toxenv:

          args.tox = True

  

@@ -30,6 +30,7 @@ 

    installed:

      setuptools: 50

      wheel: 1

+   include_runtime: false

    setup.py: |

    expected: |

      python3dist(setuptools) >= 40.8
@@ -42,6 +43,7 @@ 

      setuptools: 50

      wheel: 1

      toml: 1

+   include_runtime: false

    pyproject.toml: |

      # empty

    setup.py: |
@@ -201,6 +203,7 @@ 

    installed:

      setuptools: 50

      wheel: 1

+   include_runtime: false

    setup.py: |

      from setuptools import setup

      setup(
@@ -223,7 +226,6 @@ 

      setuptools: 50

      wheel: 1

      pyyaml: 1

-   include_runtime: true

    setup.py: |

      from setuptools import setup

      setup(
@@ -246,7 +248,6 @@ 

      setuptools: 50

      wheel: 1

      pyyaml: 1

-   include_runtime: true

    setup.py: &pytest_setup_py |

          # slightly abriged copy of pytest's setup.py

          from setuptools import setup

@@ -40,15 +40,16 @@ 

              )

      requirement_files = case.get('requirement_files', [])

      requirement_files = [open(f) for f in requirement_files]

+     use_build_system = case.get('use_build_system', True)

      try:

          generate_requires(

              get_installed_version=get_installed_version,

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

+             include_runtime=case.get('include_runtime', use_build_system),

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

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

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

              requirement_files=requirement_files,

-             use_build_system=case.get('use_build_system', True),

+             use_build_system=use_build_system,

          )

      except SystemExit as e:

          assert e.code == case['result']

file modified
+2 -2
@@ -24,9 +24,9 @@ 

  

  %generate_buildrequires

  cd markupsafe-%{markupsafe_version}

- %pyproject_buildrequires

+ %pyproject_buildrequires -R

  cd ../tldr-%{tldr_version}

- %pyproject_buildrequires

+ %pyproject_buildrequires -R

  cd ..

  

  

file modified
+2 -1
@@ -28,7 +28,8 @@ 

  

  

  %generate_buildrequires

- %pyproject_buildrequires

+ # this runtime-requires pastel<0.2 which is no longer available in Fedora

+ %pyproject_buildrequires -R

  

  

  %build

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

  

  

  %generate_buildrequires

- %pyproject_buildrequires -r

+ %pyproject_buildrequires

  

  

  %build

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

  

  

  %generate_buildrequires

- %pyproject_buildrequires

+ %pyproject_buildrequires -R

  

  

  %build

file modified
+2 -1
@@ -30,7 +30,8 @@ 

  

  %generate_buildrequires

  cd flit_core

- %pyproject_buildrequires

+ # this runtime-requires pytoml which is no longer available in Fedora

+ %pyproject_buildrequires -R

  cd ..

  

  %build

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

  

  

  %generate_buildrequires

- %pyproject_buildrequires -r

+ %pyproject_buildrequires

  

  

  %build

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

  # requirements/dev.in recursively includes tests.in and docs.in

  # we also list tests.in manually to verify we can pass multiple arguments,

  # but it should be redundant if this was a real package

- %pyproject_buildrequires -r requirements/dev.in requirements/tests.in

+ %pyproject_buildrequires requirements/dev.in requirements/tests.in

  

  

  %build

rebased onto a2b4c858763307b27e70c1fe1cfbb84c8ed9b05c

2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

5 packages failed in the testing copr repo and succeeded in the control copr:

Missing runtime dependencies that would prevent package installation (good):

Other:

  • python-apipkg

    • LookupError: setuptools-scm was unable to detect version for '/builddir/build/BUILD/apipkg-2.1.0'. -- we would need to add another export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} in %generate_buildrequires which makes perfect sense
  • python-tqdm

    • install: cannot stat '/builddir/build/BUILDROOT/python-tqdm-4.62.3-2.fc36.x86_64/usr/lib/python3.10/site-packages/tqdm/tqdm.1': No such file or directory -- no idea, will investigate

python-tqdm is the same problem as https://github.com/pypa/auditwheel/issues/321#issuecomment-1004327658 -- the files are not in MANIFEST.in and upon dist-info re-creation, they are gone -- I've created https://github.com/tqdm/tqdm/pull/1292

Other than that, this change is OK.

rebased onto 8c8afba

2 years ago

Amended changes to README that were originally forgotten.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Pull-Request has been merged by churchyard

2 years ago