Skip to content

Commit df6ea4d

Browse files
committed
Temporarily creating a build directory
1 parent b4026a3 commit df6ea4d

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

python/pip_install/extract_wheels/__init__.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import subprocess
1313
import sys
1414
import json
15+
import tempfile
1516

1617
from python.pip_install.extract_wheels.lib import bazel, requirements
1718

@@ -83,12 +84,24 @@ def main() -> None:
8384
# Pip is run with the working directory changed to the folder containing the requirements.txt file, to allow for
8485
# relative requirements to be correctly resolved. The --wheel-dir is therefore required to be repointed back to the
8586
# 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})
92105

93106
extras = requirements.parse_extras(args.requirements)
94107

0 commit comments

Comments
 (0)