Allow multiple -e in %pyproject_buildrequires
This commit is contained in:
parent
2660031756
commit
38ef5fb85b
@ -81,7 +81,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%pyproject_buildrequires(rxte:) %{expand:\\\
|
%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}-devel'
|
||||||
echo 'python%{python3_pkgversion}dist(pip) >= 19'
|
echo 'python%{python3_pkgversion}dist(pip) >= 19'
|
||||||
echo 'python%{python3_pkgversion}dist(packaging)'
|
echo 'python%{python3_pkgversion}dist(packaging)'
|
||||||
|
@ -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: 31%{?dist}
|
Release: 32%{?dist}
|
||||||
|
|
||||||
# Macro files
|
# Macro files
|
||||||
Source001: macros.pyproject
|
Source001: macros.pyproject
|
||||||
@ -16,6 +16,7 @@ Source101: pyproject_buildrequires.py
|
|||||||
Source102: pyproject_save_files.py
|
Source102: pyproject_save_files.py
|
||||||
Source103: pyproject_convert.py
|
Source103: pyproject_convert.py
|
||||||
Source104: pyproject_preprocess_record.py
|
Source104: pyproject_preprocess_record.py
|
||||||
|
Source105: pyproject_construct_toxenv.py
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
Source201: test_pyproject_buildrequires.py
|
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_convert.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||||
install -m 644 pyproject_save_files.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_preprocess_record.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||||
|
install -m 644 pyproject_construct_toxenv.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||||
|
|
||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
%check
|
%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_convert.py
|
||||||
%{_rpmconfigdir}/redhat/pyproject_save_files.py
|
%{_rpmconfigdir}/redhat/pyproject_save_files.py
|
||||||
%{_rpmconfigdir}/redhat/pyproject_preprocess_record.py
|
%{_rpmconfigdir}/redhat/pyproject_preprocess_record.py
|
||||||
|
%{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py
|
||||||
|
|
||||||
%doc README.md
|
%doc README.md
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|
||||||
%changelog
|
%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
|
* Mon Oct 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-31
|
||||||
- Support PEP 517 list based backend-path
|
- Support PEP 517 list based backend-path
|
||||||
|
|
||||||
|
@ -244,6 +244,7 @@ def parse_tox_requires_lines(lines):
|
|||||||
|
|
||||||
|
|
||||||
def generate_tox_requirements(toxenv, requirements):
|
def generate_tox_requirements(toxenv, requirements):
|
||||||
|
toxenv = ','.join(toxenv)
|
||||||
requirements.add('tox-current-env >= 0.0.3', source='tox itself')
|
requirements.add('tox-current-env >= 0.0.3', source='tox itself')
|
||||||
requirements.check(source='tox itself')
|
requirements.check(source='tox itself')
|
||||||
with tempfile.NamedTemporaryFile('r') as deps, tempfile.NamedTemporaryFile('r') as extras:
|
with tempfile.NamedTemporaryFile('r') as deps, tempfile.NamedTemporaryFile('r') as extras:
|
||||||
@ -297,7 +298,7 @@ def generate_requires(
|
|||||||
try:
|
try:
|
||||||
backend = get_backend(requirements)
|
backend = get_backend(requirements)
|
||||||
generate_build_requirements(backend, requirements)
|
generate_build_requirements(backend, requirements)
|
||||||
if toxenv is not None:
|
if toxenv:
|
||||||
include_runtime = True
|
include_runtime = True
|
||||||
generate_tox_requirements(toxenv, requirements)
|
generate_tox_requirements(toxenv, requirements)
|
||||||
if include_runtime:
|
if include_runtime:
|
||||||
@ -315,8 +316,8 @@ def main(argv):
|
|||||||
help='Generate run-time requirements',
|
help='Generate run-time requirements',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-e', '--toxenv', metavar='TOXENVS', default=None,
|
'-e', '--toxenv', metavar='TOXENVS', action='append',
|
||||||
help=('specify tox environments'
|
help=('specify tox environments (comma separated and/or repeated)'
|
||||||
'(implies --tox)'),
|
'(implies --tox)'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -346,8 +347,9 @@ def main(argv):
|
|||||||
|
|
||||||
if args.tox:
|
if args.tox:
|
||||||
args.runtime = True
|
args.runtime = True
|
||||||
args.toxenv = (args.toxenv or os.getenv('RPM_TOXENV') or
|
if not args.toxenv:
|
||||||
f'py{sys.version_info.major}{sys.version_info.minor}')
|
_default = f'py{sys.version_info.major}{sys.version_info.minor}'
|
||||||
|
args.toxenv = [os.getenv('RPM_TOXENV', _default)]
|
||||||
|
|
||||||
if args.extras:
|
if args.extras:
|
||||||
args.runtime = True
|
args.runtime = True
|
||||||
|
@ -294,7 +294,8 @@ Tox dependencies:
|
|||||||
wheel: 1
|
wheel: 1
|
||||||
tox: 3.5.3
|
tox: 3.5.3
|
||||||
tox-current-env: 0.0.3
|
tox-current-env: 0.0.3
|
||||||
toxenv: py3
|
toxenv:
|
||||||
|
- py3
|
||||||
setup.py: |
|
setup.py: |
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
@ -327,7 +328,8 @@ Tox extras:
|
|||||||
wheel: 1
|
wheel: 1
|
||||||
tox: 3.5.3
|
tox: 3.5.3
|
||||||
tox-current-env: 0.0.3
|
tox-current-env: 0.0.3
|
||||||
toxenv: py3
|
toxenv:
|
||||||
|
- py3
|
||||||
setup.py: |
|
setup.py: |
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
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
|
BuildArch: noarch
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: pyproject-rpm-macros
|
BuildRequires: pyproject-rpm-macros
|
||||||
|
BuildRequires: /usr/bin/git
|
||||||
|
BuildRequires: /usr/bin/hg
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Here we test that %%pyproject_extras_subpkg works and generates
|
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+.
|
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
|
%package -n python3-setuptools_scm
|
||||||
Summary: %{summary}
|
Summary: %{summary}
|
||||||
|
|
||||||
@ -28,9 +34,22 @@ Summary: %{summary}
|
|||||||
%prep
|
%prep
|
||||||
%autosetup -p1 -n setuptools_scm-%{version}
|
%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
|
%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
|
%pyproject_buildrequires
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -43,6 +62,16 @@ Summary: %{summary}
|
|||||||
|
|
||||||
|
|
||||||
%check
|
%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
|
# Internal check for our macros
|
||||||
# making sure that %%{pyproject_ghost_distinfo} has the right content
|
# making sure that %%{pyproject_ghost_distinfo} has the right content
|
||||||
test -f %{pyproject_ghost_distinfo}
|
test -f %{pyproject_ghost_distinfo}
|
||||||
|
Loading…
Reference in New Issue
Block a user