From caf63452514c800a3b1d6be653b150b1510705ab Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 13 Sep 2021 08:38:45 +0200 Subject: requirements: Test --use-feature=in-tree-build --- misc/requirements/requirements-pylint.txt-raw | 3 +++ scripts/dev/recompile_requirements.py | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/misc/requirements/requirements-pylint.txt-raw b/misc/requirements/requirements-pylint.txt-raw index 08d340665..ccee2ac10 100644 --- a/misc/requirements/requirements-pylint.txt-raw +++ b/misc/requirements/requirements-pylint.txt-raw @@ -12,3 +12,6 @@ pefile # Already included via test requirements #@ ignore: urllib3 + +# For pylint_checkers +#@ pip_args: --use-feature=in-tree-build diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index d8ed9974b..7a7d66c0e 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -238,6 +238,7 @@ def read_comments(fobj): 'add': [], 'replace': {}, 'pre': False, + 'pip_args': [], } for line in fobj: if line.startswith('#@'): @@ -267,6 +268,8 @@ def read_comments(fobj): comments['add'].append(args) elif command == 'pre': comments['pre'] = True + elif command == 'pip_args': + comments['pip_args'] += args.split() return comments @@ -290,7 +293,7 @@ def run_pip(venv_dir, *args, quiet=False, **kwargs): return subprocess.run([venv_python, '-m', 'pip'] + args, check=True, **kwargs) -def init_venv(host_python, venv_dir, requirements, pre=False): +def init_venv(host_python, venv_dir, requirements, pre=False, pip_args=None): """Initialize a new virtualenv and install the given packages.""" with utils.gha_group('Creating virtualenv'): utils.print_col('$ python3 -m venv {}'.format(venv_dir), 'blue') @@ -302,6 +305,8 @@ def init_venv(host_python, venv_dir, requirements, pre=False): install_command = ['install', '-r', requirements] if pre: install_command.append('--pre') + if pip_args: + install_command += pip_args with utils.gha_group('Installing requirements'): run_pip(venv_dir, *install_command) @@ -497,7 +502,8 @@ def build_requirements(name): init_venv(host_python=host_python, venv_dir=tmpdir, requirements=filename, - pre=comments['pre']) + pre=comments['pre'], + pip_args=comments['pip_args']) with utils.gha_group('Freezing requirements'): args = ['--all'] if name == 'tox' else [] proc = run_pip(tmpdir, 'freeze', *args, stdout=subprocess.PIPE) @@ -556,9 +562,13 @@ def test_requirements(name, outfile, *, force=False): print(f"Skipping test as there were no changes for {name}.") return + in_file = os.path.join(REQ_DIR, 'requirements-{}.txt-raw'.format(name)) + with open(in_file, 'r', encoding='utf-8') as f: + comments = read_comments(f) + host_python = get_host_python(name) with tempfile.TemporaryDirectory() as tmpdir: - init_venv(host_python, tmpdir, outfile) + init_venv(host_python, tmpdir, outfile, pip_args=comments['pip_args']) def main(): -- cgit v1.2.3-54-g00ecf