Skip to content

RECORD size and hash do not reflect rewritten shebangs #10744

@LukeShu

Description

@LukeShu

Description

When installing a wheel, pip rewrites the shebang in scripts in {dist}-{ver}.dist-info/scripts/ from #!python to the appropriate path to the Python interpreter. However, the hash and size in RECORD for the script correspond to the original version of the script, not the rewritten version.

Expected behavior

I expected the RECORD to reflect the files that actually get installed, so that an install can be integrity-checked.

pip version

20.3.4

Python version

3.9.9

OS

Parabola GNU/Linux-libre (like Arch Linux)

How to Reproduce

  1. Use pip to install a wheel that contains a {dist}-{ver}.dist-info/scripts/* script with a #!python shebang. One such wheel is websocket-client 0.57.0.
  2. Check whether the hash and size of the script match what got recorded in RECORD.

Output

$ wget https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl

$ pip install --ignore-installed --no-deps --prefix=testdir ./websocket_client-0.57.0-py2.py3-none-any.whl


$ # Observe what the resulting RECORD says
$ grep bin/w testdir/lib/python3.9/site-packages/websocket_client-0.57.0.dist-info/RECORD 
../../../bin/wsdump.py,sha256=S54et6zebnxb2VJcgBadSnvXblK1iBF93ap54hlc5O8,6403

$ # Observe whether this matches the resulting script file
$ sha256sum testdir/bin/wsdump.py | xargs python -c 'import sys, base64; print(base64.b64encode(bytes.fromhex(sys.argv[1])).decode("utf-8"))'
6GQkITdeQFmlpL7/T9+O/X0sWsKeddIZCvwtU0ld+hc=
$ wc -c < testdir/bin/wsdump.py 
6412

$ # Observe whether this matches the original script in the wheel
$ bsdtar xfO websocket_client-0.57.0-py2.py3-none-any.whl websocket_client-0.57.0.data/scripts/wsdump.py | sha256sum | xargs python -c 'import sys, base64; print(base64.b64encode(bytes.fromhex(sys.argv[1])).decode("utf-8"))'
S54et6zebnxb2VJcgBadSnvXblK1iBF93ap54hlc5O8=
$ bsdtar xfO websocket_client-0.57.0-py2.py3-none-any.whl websocket_client-0.57.0.data/scripts/wsdump.py |wc -c
6403

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions