Allow multiple -e in %pyproject_buildrequires
This commit is contained in:
parent
2660031756
commit
38ef5fb85b
@ -81,7 +81,7 @@ fi
|
||||
|
||||
|
||||
%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)'
|
||||
|
@ -6,7 +6,7 @@ License: MIT
|
||||
|
||||
# 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 @@ Source101: pyproject_buildrequires.py
|
||||
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_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||
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 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
%{_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
|
||||
|
||||
|
@ -244,6 +244,7 @@ def parse_tox_requires_lines(lines):
|
||||
|
||||
|
||||
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 @@ def generate_requires(
|
||||
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 @@ def main(argv):
|
||||
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 @@ def main(argv):
|
||||
|
||||
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 @@ Tox dependencies:
|
||||
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 @@ Tox extras:
|
||||
wheel: 1
|
||||
tox: 3.5.3
|
||||
tox-current-env: 0.0.3
|
||||
toxenv: py3
|
||||
toxenv:
|
||||
- py3
|
||||
setup.py: |
|
||||
from setuptools import setup
|
||||
setup(
|
||||
|
15
pyproject_construct_toxenv.py
Normal file
15
pyproject_construct_toxenv.py
Normal file
@ -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:]))
|
@ -9,6 +9,8 @@ Source0: %{pypi_source setuptools_scm}
|
||||
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 @@ setuptools_scm[toml] extra subpackage.
|
||||
|
||||
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 @@ Summary: %{summary}
|
||||
%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 @@ Summary: %{summary}
|
||||
|
||||
|
||||
%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}
|
||||
|
Loading…
Reference in New Issue
Block a user