-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when executed as a wheel, pip creates a temporary file containing ca certificates which is not cleaned up #10753
Comments
Using pip directly from a wheel is not supported, as far as I'm aware. |
I can reproduce but only by running it exactly as you listed (which is setting the wheel as the pip module?):
If I simply run:
I can not reproduce. |
this is (for instance)
|
here's a reproduction using $ du -hs /tmp/tmp*
du: cannot access '/tmp/tmp*': No such file or directory
$ python3.10 -m venv venv
$ du -hs /tmp/tmp*
256K /tmp/tmpq8131b28cacert.pem (the filename is a little different as |
Ugh. Can someone check whether |
yep looks like that works fine: $ ~/opt/venv/bin/python -m pip download pip
Collecting pip
Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Saved ./pip-21.3.1-py3-none-any.whl
Successfully downloaded pip
$ python3 -m venv --without-pip venv
$ PYTHONPATH=pip-21.3.1-py3-none-any.whl venv/bin/python3 -m pip install isort --no-binary :all:
Collecting isort
Downloading isort-5.10.1.tar.gz (174 kB)
|████████████████████████████████| 174 kB 5.3 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: isort
Building wheel for isort (pyproject.toml) ... done
Created wheel for isort: filename=isort-5.10.1-py3-none-any.whl size=103431 sha256=eea14d9ea804d971049b4a1f35d1fde5a1988a3d6adc52a01f84f6ed4afca079
Stored in directory: /home/asottile/.cache/pip/wheels/17/33/b8/4531f2a5211bf911323d26bbf429c922ef72f0483567135943
Successfully built isort
Installing collected packages: isort
Successfully installed isort-5.10.1 |
Ensurepip doesn't need the certificates, as far as I know (it installs what's bundled with Python). And ensurepip is closely tied to pip, as well as being essentially part of pip's delivery mechanism, so it's a special case. Virtualenv may be doing the same, or it may need the certificates. But it's relying on unsupported behaviour, regardless. Note that happens in our patch to Or you could submit an issue to certifi, asking them to support running from a zipfile. Then we could remove our patch altogether. That would probably be the most reliable solution, if you care enough to go down that route. |
get-pip also uses this mechanism: https://github.com/pypa/get-pip/blob/6043201e89b1193f7bf050979436eff6a7337247/templates/default.py#L130-L136 and I'm pretty sure it needs the certificates in that case since it reaches out to pypi to download the dependencies |
It looks like certifi already has the Also, get-pip uses different code which does do the cleanup1. But the certifi/importlib approach is independent, and get-pip can't fix that. Footnotes
|
Hi, I also noticed this bug and I found the root issue. It's a bug in Python importlib.resources: python/cpython#93353 |
I think that this pip issue since importlib.resources has been fixed in Python. |
Thanks @vstinner - that was a complicated one to find, thanks for digging into it to work out what the root cause was! |
Description
a temporary file is leaked during the execution of
pip
as a wheel. repeated execution consumes ~250KB per execution which quickly fills up disk if run in a loopExpected behavior
I expect the temporary file to be cleaned up instead of left around after execution
pip version
21.3.1
Python version
3.8.10
OS
ubuntu 20.04
How to Reproduce
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: