Skip to content

Commit d0191f0

Browse files
AustinSchuhbrandjon
authored andcommitted
Remove the temporary directory containing cacert.pem when done (bazel-contrib#169)
Our verification machines were filling up /tmp/ with this temporary folder. This patch removes it when piptool exits.
1 parent 120590e commit d0191f0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

rules_python/piptool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def extract_packages(package_names):
7373
def pip_main(argv):
7474
# Extract the certificates from the PAR following the example of get-pip.py
7575
# https://github.com/pypa/get-pip/blob/430ba37776ae2ad89/template.py#L164-L168
76-
cert_path = os.path.join(tempfile.mkdtemp(), "cacert.pem")
76+
cert_tmpdir = tempfile.mkdtemp()
77+
cert_path = os.path.join(cert_tmpdir, "cacert.pem")
78+
atexit.register(lambda: shutil.rmtree(cert_tmpdir, ignore_errors=True))
7779
with open(cert_path, "wb") as cert:
7880
cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))
7981
argv = ["--disable-pip-version-check", "--cert", cert_path] + argv

tools/piptool.par

212 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)