%pyproject_buildrequires: Make -r (include runtime) the default, use -R to opt-out
See the proposal: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/2R6NKELTHAWE6PI3CCZBVW5PMGO5VPDG/ - -N now implies -R - the macro still guards against -Nr and now also against -Rr
This commit is contained in:
parent
832e19f5ab
commit
8c8afba774
18
README.md
18
README.md
@ -42,7 +42,8 @@ the macros themselves) by running `%pyproject_buildrequires` in the
|
|||||||
%pyproject_buildrequires
|
%pyproject_buildrequires
|
||||||
|
|
||||||
This will add build dependencies according to [PEP 517] and [PEP 518].
|
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
|
If you need more dependencies, such as non-Python libraries, BuildRequire
|
||||||
them manually.
|
them manually.
|
||||||
|
|
||||||
@ -68,17 +69,22 @@ And install the wheel in `%install` with `%pyproject_install`:
|
|||||||
Adding run-time and test-time dependencies
|
Adding run-time and test-time dependencies
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
To run tests in the `%check` section, the package's runtime dependencies
|
To run tests or import checks in the `%check` section,
|
||||||
often need to also be included as build requirements.
|
the package's runtime dependencies need to also be included as build requirements.
|
||||||
This can be done using the `-r` flag:
|
|
||||||
|
|
||||||
%generate_buildrequires
|
Hence, `%pyproject_buildrequires` also generates runtime dependencies by default.
|
||||||
%pyproject_buildrequires -r
|
|
||||||
|
|
||||||
For this to work, the project's build system must support the
|
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).
|
[`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.
|
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`
|
For projects that specify test requirements using an [`extra`
|
||||||
provide](https://packaging.python.org/specifications/core-metadata/#provides-extra-multiple-use),
|
provide](https://packaging.python.org/specifications/core-metadata/#provides-extra-multiple-use),
|
||||||
these can be added using the `-x` flag.
|
these can be added using the `-x` flag.
|
||||||
|
@ -115,7 +115,8 @@ fi
|
|||||||
%toxenv %{default_toxenv}
|
%toxenv %{default_toxenv}
|
||||||
|
|
||||||
|
|
||||||
%pyproject_buildrequires(rxtNe:) %{expand:\\\
|
%pyproject_buildrequires(rRxtNe:) %{expand:\\\
|
||||||
|
%{-R:%{-r:%{error:The -R and -r options are mutually exclusive}}}
|
||||||
%{-N:
|
%{-N:
|
||||||
%{-r:%{error:The -N and -r options are mutually exclusive}}
|
%{-r:%{error:The -N and -r options are mutually exclusive}}
|
||||||
%{-x:%{error:The -N and -x options are mutually exclusive}}
|
%{-x:%{error:The -N and -x options are mutually exclusive}}
|
||||||
|
@ -6,7 +6,7 @@ License: MIT
|
|||||||
|
|
||||||
# Keep the version at zero and increment only release
|
# Keep the version at zero and increment only release
|
||||||
Version: 0
|
Version: 0
|
||||||
Release: 52%{?dist}
|
Release: 53%{?dist}
|
||||||
|
|
||||||
# Macro files
|
# Macro files
|
||||||
Source001: macros.pyproject
|
Source001: macros.pyproject
|
||||||
@ -116,6 +116,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
|||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|
||||||
%changelog
|
%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
|
* Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-52
|
||||||
- Handle legacy version specifiers that would previously raise exceptions.
|
- Handle legacy version specifiers that would previously raise exceptions.
|
||||||
|
|
||||||
|
@ -367,8 +367,12 @@ def main(argv):
|
|||||||
description='Generate BuildRequires for a Python project.'
|
description='Generate BuildRequires for a Python project.'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-r', '--runtime', action='store_true',
|
'-r', '--runtime', action='store_true', default=True,
|
||||||
help='Generate run-time requirements',
|
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(
|
parser.add_argument(
|
||||||
'-e', '--toxenv', metavar='TOXENVS', action='append',
|
'-e', '--toxenv', metavar='TOXENVS', action='append',
|
||||||
@ -405,6 +409,9 @@ def main(argv):
|
|||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
if not args.use_build_system:
|
||||||
|
args.runtime = False
|
||||||
|
|
||||||
if args.toxenv:
|
if args.toxenv:
|
||||||
args.tox = True
|
args.tox = True
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ No pyproject.toml, empty setup.py:
|
|||||||
installed:
|
installed:
|
||||||
setuptools: 50
|
setuptools: 50
|
||||||
wheel: 1
|
wheel: 1
|
||||||
|
include_runtime: false
|
||||||
setup.py: |
|
setup.py: |
|
||||||
expected: |
|
expected: |
|
||||||
python3dist(setuptools) >= 40.8
|
python3dist(setuptools) >= 40.8
|
||||||
@ -42,6 +43,7 @@ Default build system, empty setup.py:
|
|||||||
setuptools: 50
|
setuptools: 50
|
||||||
wheel: 1
|
wheel: 1
|
||||||
toml: 1
|
toml: 1
|
||||||
|
include_runtime: false
|
||||||
pyproject.toml: |
|
pyproject.toml: |
|
||||||
# empty
|
# empty
|
||||||
setup.py: |
|
setup.py: |
|
||||||
@ -201,6 +203,7 @@ Default build system, build dependencies in setup.py:
|
|||||||
installed:
|
installed:
|
||||||
setuptools: 50
|
setuptools: 50
|
||||||
wheel: 1
|
wheel: 1
|
||||||
|
include_runtime: false
|
||||||
setup.py: |
|
setup.py: |
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
@ -223,7 +226,6 @@ Default build system, run dependencies in setup.py:
|
|||||||
setuptools: 50
|
setuptools: 50
|
||||||
wheel: 1
|
wheel: 1
|
||||||
pyyaml: 1
|
pyyaml: 1
|
||||||
include_runtime: true
|
|
||||||
setup.py: |
|
setup.py: |
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
@ -246,7 +248,6 @@ Run dependencies with extras (not selected):
|
|||||||
setuptools: 50
|
setuptools: 50
|
||||||
wheel: 1
|
wheel: 1
|
||||||
pyyaml: 1
|
pyyaml: 1
|
||||||
include_runtime: true
|
|
||||||
setup.py: &pytest_setup_py |
|
setup.py: &pytest_setup_py |
|
||||||
# slightly abriged copy of pytest's setup.py
|
# slightly abriged copy of pytest's setup.py
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
@ -40,15 +40,16 @@ def test_data(case_name, capsys, tmp_path, monkeypatch):
|
|||||||
)
|
)
|
||||||
requirement_files = case.get('requirement_files', [])
|
requirement_files = case.get('requirement_files', [])
|
||||||
requirement_files = [open(f) for f in requirement_files]
|
requirement_files = [open(f) for f in requirement_files]
|
||||||
|
use_build_system = case.get('use_build_system', True)
|
||||||
try:
|
try:
|
||||||
generate_requires(
|
generate_requires(
|
||||||
get_installed_version=get_installed_version,
|
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', []),
|
extras=case.get('extras', []),
|
||||||
toxenv=case.get('toxenv', None),
|
toxenv=case.get('toxenv', None),
|
||||||
generate_extras=case.get('generate_extras', False),
|
generate_extras=case.get('generate_extras', False),
|
||||||
requirement_files=requirement_files,
|
requirement_files=requirement_files,
|
||||||
use_build_system=case.get('use_build_system', True),
|
use_build_system=use_build_system,
|
||||||
)
|
)
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
assert e.code == case['result']
|
assert e.code == case['result']
|
||||||
|
@ -24,9 +24,9 @@ tar xf %{SOURCE2}
|
|||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
cd markupsafe-%{markupsafe_version}
|
cd markupsafe-%{markupsafe_version}
|
||||||
%pyproject_buildrequires
|
%pyproject_buildrequires -R
|
||||||
cd ../tldr-%{tldr_version}
|
cd ../tldr-%{tldr_version}
|
||||||
%pyproject_buildrequires
|
%pyproject_buildrequires -R
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
%pyproject_buildrequires
|
# this runtime-requires pastel<0.2 which is no longer available in Fedora
|
||||||
|
%pyproject_buildrequires -R
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
@ -31,7 +31,7 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
%pyproject_buildrequires -r
|
%pyproject_buildrequires
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
@ -28,7 +28,7 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
%pyproject_buildrequires
|
%pyproject_buildrequires -R
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
@ -30,7 +30,8 @@ Summary: %{summary}
|
|||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
cd flit_core
|
cd flit_core
|
||||||
%pyproject_buildrequires
|
# this runtime-requires pytoml which is no longer available in Fedora
|
||||||
|
%pyproject_buildrequires -R
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
@ -29,7 +29,7 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%generate_buildrequires
|
%generate_buildrequires
|
||||||
%pyproject_buildrequires -r
|
%pyproject_buildrequires
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
@ -36,7 +36,7 @@ sed -Ei 's/sphinx\.git@([0-9a-f]+)/sphinx.git@\1#egg=sphinx/' requirements/docs.
|
|||||||
# requirements/dev.in recursively includes tests.in and docs.in
|
# requirements/dev.in recursively includes tests.in and docs.in
|
||||||
# we also list tests.in manually to verify we can pass multiple arguments,
|
# we also list tests.in manually to verify we can pass multiple arguments,
|
||||||
# but it should be redundant if this was a real package
|
# 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
|
%build
|
||||||
|
Loading…
Reference in New Issue
Block a user