|
2 | 2 | import datetime |
3 | 3 | import os |
4 | 4 | import secrets |
| 5 | +import shutil |
5 | 6 | import subprocess |
6 | 7 | import sys |
7 | 8 | from contextlib import contextmanager |
@@ -99,8 +100,14 @@ def install_deps(branch: str, dir: Path) -> None: |
99 | 100 | reqpath = dir / 'code' / 'requirements-tests.txt' |
100 | 101 | if not reqpath.exists(): |
101 | 102 | return |
| 103 | + |
| 104 | + destpath = dir / 'code' / '.packages' |
| 105 | + # there have been cases when pip failed to leave a consistent |
| 106 | + # installation after a downgrade, so best to start clean |
| 107 | + if destpath.exists(): |
| 108 | + shutil.rmtree(str(destpath)) |
102 | 109 | if MODE == 'plain': |
103 | | - run(get_pip(), 'install', '--target', '.packages', '--upgrade', '-r', str(reqpath)) |
| 110 | + run(get_pip(), 'install', '--target', str(destpath), '--upgrade', '-r', str(reqpath)) |
104 | 111 | else: |
105 | 112 | run(get_pip(), 'install', '--upgrade', '-r', str(reqpath)) |
106 | 113 |
|
@@ -138,7 +145,7 @@ def run_branch_tests(conf: Dict[str, str], dir: Path, run_id: str, clone: bool = |
138 | 145 |
|
139 | 146 | cwd = (dir / 'code') if clone else Path('.') |
140 | 147 | env = dict(os.environ) |
141 | | - env['PYTHONPATH'] = str(Path('.').resolve() / '.packages') \ |
| 148 | + env['PYTHONPATH'] = str(cwd.resolve() / '.packages') \ |
142 | 149 | + ':' + str(cwd.resolve() / 'src') \ |
143 | 150 | + (':' + env['PYTHONPATH'] if 'PYTHONPATH' in env else '') |
144 | 151 | subprocess.run(args, cwd=cwd.resolve(), env=env) |
|
0 commit comments