Skip to content

Commit

Permalink
Remove the temporary directory containing cacert.pem when done (#169)
Browse files Browse the repository at this point in the history
Our verification machines were filling up /tmp/ with this temporary
folder.  This patch removes it when piptool exits.
  • Loading branch information
AustinSchuh authored and brandjon committed Aug 1, 2019
1 parent 120590e commit d0191f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rules_python/piptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def extract_packages(package_names):
def pip_main(argv):
# Extract the certificates from the PAR following the example of get-pip.py
# https://github.com/pypa/get-pip/blob/430ba37776ae2ad89/template.py#L164-L168
cert_path = os.path.join(tempfile.mkdtemp(), "cacert.pem")
cert_tmpdir = tempfile.mkdtemp()
cert_path = os.path.join(cert_tmpdir, "cacert.pem")
atexit.register(lambda: shutil.rmtree(cert_tmpdir, ignore_errors=True))
with open(cert_path, "wb") as cert:
cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))
argv = ["--disable-pip-version-check", "--cert", cert_path] + argv
Expand Down
Binary file modified tools/piptool.par
Binary file not shown.

0 comments on commit d0191f0

Please sign in to comment.