|
12 | 12 | import subprocess |
13 | 13 | import sys |
14 | 14 | import json |
| 15 | +import tempfile |
15 | 16 |
|
16 | 17 | from python.pip_install.extract_wheels.lib import bazel, requirements |
17 | 18 |
|
@@ -83,12 +84,24 @@ def main() -> None: |
83 | 84 | # Pip is run with the working directory changed to the folder containing the requirements.txt file, to allow for |
84 | 85 | # relative requirements to be correctly resolved. The --wheel-dir is therefore required to be repointed back to the |
85 | 86 | # current calling working directory (the repo root in .../external/name), where the wheel files should be written to |
86 | | - pip_args = [sys.executable, "-m", "pip", "--isolated", "wheel", "-r", args.requirements, "--wheel-dir", os.getcwd()] |
87 | | - if args.extra_pip_args: |
88 | | - pip_args += json.loads(args.extra_pip_args)["args"] |
89 | | - |
90 | | - # Assumes any errors are logged by pip so do nothing. This command will fail if pip fails |
91 | | - subprocess.run(pip_args, check=True, cwd=str(pathlib.Path(args.requirements).parent.resolve())) |
| 87 | + with tempfile.TemporaryDirectory(dir = os.environ['TEST_TMPDIR']) as build_dir: |
| 88 | + pip_args = [ |
| 89 | + sys.executable, |
| 90 | + "-m", "pip", |
| 91 | + "--isolated", |
| 92 | + "wheel", |
| 93 | + "-r", args.requirements, |
| 94 | + "--wheel-dir", os.getcwd(), |
| 95 | + "--build", build_dir, |
| 96 | + ] |
| 97 | + if args.extra_pip_args: |
| 98 | + pip_args += json.loads(args.extra_pip_args)["args"] |
| 99 | + |
| 100 | + # Assumes any errors are logged by pip so do nothing. This command will fail if pip fails |
| 101 | + subprocess.run(pip_args, |
| 102 | + check=True, |
| 103 | + cwd=str(pathlib.Path(args.requirements).parent.resolve()), |
| 104 | + env={"TMPDIR": build_dir}) |
92 | 105 |
|
93 | 106 | extras = requirements.parse_extras(args.requirements) |
94 | 107 |
|
|
0 commit comments