Handle tox provision (tox.requires / tox.minversion)
This commit is contained in:
parent
11021cf250
commit
7e1a8fd079
@ -111,6 +111,11 @@ Use `%{default_toxenv}` to get the default value.
|
||||
|
||||
The `-t`/`-e` option uses [tox-current-env]'s `--print-deps-to-file` behind the scenes.
|
||||
|
||||
If your package specifies some tox plugins in `tox.requires`,
|
||||
such plugins will be BuildRequired as well.
|
||||
Not all plugins are guaranteed to play well with [tox-current-env],
|
||||
in worst case, patch/sed the requirement out from the tox configuration.
|
||||
|
||||
Note that both `-x` and `-t` imply `-r`,
|
||||
because runtime dependencies are always required for testing.
|
||||
|
||||
|
@ -6,7 +6,7 @@ License: MIT
|
||||
|
||||
# Keep the version at zero and increment only release
|
||||
Version: 0
|
||||
Release: 38%{?dist}
|
||||
Release: 39%{?dist}
|
||||
|
||||
# Macro files
|
||||
Source001: macros.pyproject
|
||||
@ -42,7 +42,7 @@ BuildRequires: python3dist(packaging)
|
||||
BuildRequires: python3dist(pip)
|
||||
BuildRequires: python3dist(setuptools)
|
||||
BuildRequires: python3dist(toml)
|
||||
BuildRequires: python3dist(tox-current-env) >= 0.0.3
|
||||
BuildRequires: python3dist(tox-current-env) >= 0.0.6
|
||||
BuildRequires: python3dist(wheel)
|
||||
%endif
|
||||
|
||||
@ -104,6 +104,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
%license LICENSE
|
||||
|
||||
%changelog
|
||||
* Mon Mar 29 2021 Miro Hrončok <mhroncok@redhat.com> - 0-39
|
||||
- Handle tox provision (tox.requires / tox.minversion)
|
||||
- Fixes: rhbz#1922495
|
||||
|
||||
* Sun Feb 07 2021 Miro Hrončok <mhroncok@redhat.com> - 0-38
|
||||
- Include nested __pycache__ directories in %%pyproject_save_files
|
||||
- Fixes: rhbz#1925963
|
||||
|
@ -6,6 +6,7 @@ import functools
|
||||
import traceback
|
||||
import contextlib
|
||||
from io import StringIO
|
||||
import json
|
||||
import subprocess
|
||||
import re
|
||||
import tempfile
|
||||
@ -248,13 +249,16 @@ 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.add('tox-current-env >= 0.0.6', 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, \
|
||||
tempfile.NamedTemporaryFile('r') as provision:
|
||||
r = subprocess.run(
|
||||
[sys.executable, '-m', 'tox',
|
||||
'--print-deps-to', deps.name,
|
||||
'--print-extras-to', extras.name,
|
||||
'--no-provision', provision.name,
|
||||
'-qre', toxenv],
|
||||
check=False,
|
||||
encoding='utf-8',
|
||||
@ -263,6 +267,21 @@ def generate_tox_requirements(toxenv, requirements):
|
||||
)
|
||||
if r.stdout:
|
||||
print_err(r.stdout, end='')
|
||||
|
||||
provision_content = provision.read()
|
||||
if provision_content and r.returncode != 0:
|
||||
provision_requires = json.loads(provision_content)
|
||||
if 'minversion' in provision_requires:
|
||||
requirements.add(f'tox >= {provision_requires["minversion"]}',
|
||||
source='tox provision (minversion)')
|
||||
if 'requires' in provision_requires:
|
||||
requirements.extend(provision_requires["requires"],
|
||||
source='tox provision (requires)')
|
||||
requirements.check(source='tox provision') # this terminates the script
|
||||
raise RuntimeError(
|
||||
'Dependencies requested by tox provisioning appear installed, '
|
||||
'but tox disagreed.')
|
||||
else:
|
||||
r.check_returncode()
|
||||
|
||||
deplines = deps.read().splitlines()
|
||||
|
@ -290,7 +290,7 @@ Tox dependencies:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
tox: 3.5.3
|
||||
tox-current-env: 0.0.3
|
||||
tox-current-env: 0.0.6
|
||||
toxenv:
|
||||
- py3
|
||||
setup.py: |
|
||||
@ -313,7 +313,7 @@ Tox dependencies:
|
||||
python3dist(setuptools) >= 40.8
|
||||
python3dist(wheel)
|
||||
python3dist(wheel)
|
||||
python3dist(tox-current-env) >= 0.0.3
|
||||
python3dist(tox-current-env) >= 0.0.6
|
||||
python3dist(toxdep1)
|
||||
python3dist(toxdep2)
|
||||
python3dist(inst)
|
||||
@ -324,7 +324,7 @@ Tox extras:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
tox: 3.5.3
|
||||
tox-current-env: 0.0.3
|
||||
tox-current-env: 0.0.6
|
||||
toxenv:
|
||||
- py3
|
||||
setup.py: |
|
||||
@ -354,7 +354,7 @@ Tox extras:
|
||||
python3dist(setuptools) >= 40.8
|
||||
python3dist(wheel)
|
||||
python3dist(wheel)
|
||||
python3dist(tox-current-env) >= 0.0.3
|
||||
python3dist(tox-current-env) >= 0.0.6
|
||||
python3dist(toxdep)
|
||||
python3dist(inst)
|
||||
python3dist(dep11) > 11
|
||||
@ -363,3 +363,74 @@ Tox extras:
|
||||
python3dist(dep22)
|
||||
python3dist(dep23)
|
||||
result: 0
|
||||
|
||||
Tox provision unsatisfied:
|
||||
installed:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
tox: 3.5.3
|
||||
tox-current-env: 0.0.6
|
||||
toxenv:
|
||||
- py3
|
||||
setup.py: |
|
||||
from setuptools import setup
|
||||
setup(
|
||||
name='test',
|
||||
version='0.1',
|
||||
install_requires=['inst'],
|
||||
)
|
||||
tox.ini: |
|
||||
[tox]
|
||||
minversion = 3.999
|
||||
requires =
|
||||
setuptools > 40
|
||||
wheel > 2
|
||||
[testenv]
|
||||
deps =
|
||||
toxdep1
|
||||
toxdep2
|
||||
expected: |
|
||||
python3dist(setuptools) >= 40.8
|
||||
python3dist(wheel)
|
||||
python3dist(wheel)
|
||||
python3dist(tox-current-env) >= 0.0.6
|
||||
python3dist(tox) >= 3.999
|
||||
python3dist(setuptools) > 40
|
||||
python3dist(wheel) > 2
|
||||
result: 0
|
||||
|
||||
Tox provision satisfied:
|
||||
installed:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
tox: 3.5.3
|
||||
tox-current-env: 0.0.6
|
||||
toxenv:
|
||||
- py3
|
||||
setup.py: |
|
||||
from setuptools import setup
|
||||
setup(
|
||||
name='test',
|
||||
version='0.1',
|
||||
install_requires=['inst'],
|
||||
)
|
||||
tox.ini: |
|
||||
[tox]
|
||||
minversion = 3.5
|
||||
requires =
|
||||
setuptools > 40
|
||||
[testenv]
|
||||
deps =
|
||||
toxdep1
|
||||
toxdep2
|
||||
expected: |
|
||||
python3dist(setuptools) >= 40.8
|
||||
python3dist(wheel)
|
||||
python3dist(wheel)
|
||||
python3dist(tox-current-env) >= 0.0.6
|
||||
python3dist(tox) >= 3.5
|
||||
python3dist(setuptools) > 40
|
||||
python3dist(toxdep1)
|
||||
python3dist(toxdep2)
|
||||
python3dist(inst)
|
||||
result: 0
|
||||
|
Loading…
Reference in New Issue
Block a user