The hash in torch-1.10.1.dist-info/RECORD
for the file torch-1.10.1.dist-info/METADATA
doesn't match that of the actual file and so wheel3 unpack torch-1.10.1-cp39-cp39-manylinux1_x86_64.whl
fails with:
Hash mismatch for file 'torch-1.10.1.dist-info/METADATA
I've also tried on 1.9.0 and get the same.
The hash is correct in the OSX wheel. For 1.9.0, the content of the METADATA
file is exactly the same in both OSX and manylinux wheels (verified by recomputing the hashes), but the hashes in the record files are different. The size is reported as 6 bytes more in the manylinux RECORD
file compared to OSX. For 1.10.1, the diff between OSX and Linux METADATA
is:
< License-File: LICENSE
< License-File: NOTICE
AFAICT for the manylinux wheel the hashes are re-computed manually here, as I think several files are added/modified after the initial build with setup.py bdist_wheel. It may be that the METADATA
file is modified somehow after it is extracted, a new hash is computed on the modified file, but then the original file is added back in to the wheel. I haven't verified that though, and can't see anything in obvious in the code.
I see the same for torchvision (have tried on 0.10.0 and 0.11.2).
To repro:
#!/bin/bash
OSX_URL="https://files.pythonhosted.org/packages/0f/fe/15c5eb63e5b0d92343469123ecc26579a4bb30df0a2813fe68aca4d36880/torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl"
MANYLINUX_URL="https://files.pythonhosted.org/packages/2c/c8/dcef19018d2fe730ecacf47650d3d6e8d6fe545f02fbdbde0174e0279f02/torch-1.10.1-cp39-cp39-manylinux1_x86_64.whl"
METADATA_FILENAME="torch-1.10.1.dist-info/METADATA"
RECORD_FILENAME="torch-1.10.1.dist-info/RECORD"
# OSX_URL="https://files.pythonhosted.org/packages/0c/e9/6ca380d925b3a834f0cb1cac75e4bb53c74a6170bb9b6ec40315501cbdfa/torch-1.9.0-cp39-none-macosx_10_9_x86_64.whl"
# MANYLINUX_URL="https://files.pythonhosted.org/packages/18/dc/364619ec35762f0fda9b1ac5bc73e4372a0e451f15e38ef601d3ef006a17/torch-1.9.0-cp39-cp39-manylinux1_x86_64.whl"
# METADATA_FILENAME="torch-1.9.0.dist-info/METADATA"
# RECORD_FILENAME="torch-1.9.0.dist-info/RECORD"
# OSX_URL="https://files.pythonhosted.org/packages/73/f2/b360ddc86b4b0e10750f1dcf95542c978f6a7893220af245a8e04a0d5664/torchvision-0.11.2-cp39-cp39-macosx_10_9_x86_64.whl"
# MANYLINUX_URL="https://files.pythonhosted.org/packages/92/8b/cbbcf8e055b074ea55ae07d1f3d8fb2888d47f2944ee5ea286243d4d2ba2/torchvision-0.11.2-cp39-cp39-manylinux1_x86_64.whl"
# METADATA_FILENAME="torchvision-0.11.2.dist-info/METADATA"
# RECORD_FILENAME="torchvision-0.11.2.dist-info/RECORD"
# OSX_URL="https://files.pythonhosted.org/packages/76/e6/7be72bbc5fa95a3c5f9690576bed1de45570f5f550a869bb19772f82d4c5/torchvision-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl"
# MANYLINUX_URL="https://files.pythonhosted.org/packages/00/03/88edb6f9f7f17ce264a01209ac550878713a66a99d9d8e25747b15d6aadb/torchvision-0.10.0-cp39-cp39-manylinux1_x86_64.whl"
# METADATA_FILENAME="torchvision-0.10.0.dist-info/METADATA"
# RECORD_FILENAME="torchvision-0.10.0.dist-info/RECORD"
OSX_WHEEL_NAME=$(basename "${OSX_URL}")
MANYLINUX_WHEEL_NAME=$(basename "${MANYLINUX_URL}")
function download_and_extract_wheel() {
url=$1
wheel_name=$( basename "${url}" )
echo "----------------------------------------"
echo "Fetching ${wheel_name}"
mkdir -p "${wheel_name}"
pushd ""${wheel_name}"" > /dev/null
wget -nc "${url}"
wheel3 unpack "${wheel_name}"
unzip -qo "${wheel_name}"
popd > /dev/null
}
function print_hashes() {
wheel_name=$1
echo "----------------------------------------"
echo "printing hashes"
echo "${wheel_name}"
computed_digest=`openssl dgst -sha256 -binary ${wheel_name}/${METADATA_FILENAME} | openssl base64 | sed -e 's/+/-/g' | sed -e 's/\//_/g' | sed -e 's/=//g'`
computed_size=`ls -nl ${wheel_name}/${METADATA_FILENAME} | awk '{print $5}'`
new_entry="${METADATA_FILENAME},sha256=${computed_digest},${computed_size}"
echo "RECORD entry: " $( grep METADATA ${wheel_name}/${RECORD_FILENAME} )
echo "manually computed entry:" $new_entry
}
function diff_metadata() {
wheel_name1=$1
wheel_name2=$2
echo "----------------------------------------"
echo "record diff:"
diff "${wheel_name1}/${RECORD_FILENAME}" "${wheel_name2}/${RECORD_FILENAME}" | grep METADATA
echo "metadata diff:"
diff "${wheel_name1}/${METADATA_FILENAME}" "${wheel_name2}/${METADATA_FILENAME}"
}
download_and_extract_wheel "${OSX_URL}"
download_and_extract_wheel "${MANYLINUX_URL}"
print_hashes "${OSX_WHEEL_NAME}"
print_hashes "${MANYLINUX_WHEEL_NAME}"
diff_metadata "${OSX_WHEEL_NAME}" "${MANYLINUX_WHEEL_NAME}"
Output for torch-1.10.1
is:
----------------------------------------
Fetching torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl
File ‘torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl’ already there; not retrieving.
Unpacking to: ./torch-1.10.1...OK
----------------------------------------
Fetching torch-1.10.1-cp39-cp39-manylinux1_x86_64.whl
File ‘torch-1.10.1-cp39-cp39-manylinux1_x86_64.whl’ already there; not retrieving.
Unpacking to: ./torch-1.10.1...Hash mismatch for file 'torch-1.10.1.dist-info/METADATA'
----------------------------------------
printing hashes
torch-1.10.1-cp39-none-macosx_10_9_x86_64.whl
RECORD entry: torch-1.10.1.dist-info/METADATA,sha256=edF_FwahbS66wyEe6zSnnQ5RuWIN03mwSkwtfeQcqT0,24871
manually computed entry: torch-1.10.1.dist-info/METADATA,sha256=edF_FwahbS66wyEe6zSnnQ5RuWIN03mwSkwtfeQcqT0,24871
----------------------------------------
printing hashes
torch-1.10.1-cp39-cp39-manylinux1_x86_64.whl
RECORD entry: torch-1.10.1.dist-info/METADATA,sha256=y_NV0MNN6tjiqKPWDm9w7-hVFwP6XDTRVvci-guOPII,24834
manually computed entry: torch-1.10.1.dist-info/METADATA,sha256=wKopP9RszkBTQzmqb6hjYD2o43BlBmy7OdEVxSG1wF4,24828
----------------------------------------
record diff:
< torch-1.10.1.dist-info/METADATA,sha256=edF_FwahbS66wyEe6zSnnQ5RuWIN03mwSkwtfeQcqT0,24871
> torch-1.10.1.dist-info/METADATA,sha256=y_NV0MNN6tjiqKPWDm9w7-hVFwP6XDTRVvci-guOPII,24834
metadata diff:
31,32d30
< License-File: LICENSE
< License-File: NOTICE
And for torch-1.9.0
:
----------------------------------------
Fetching torch-1.9.0-cp39-none-macosx_10_9_x86_64.whl
File ‘torch-1.9.0-cp39-none-macosx_10_9_x86_64.whl’ already there; not retrieving.
Unpacking to: ./torch-1.9.0...OK
----------------------------------------
Fetching torch-1.9.0-cp39-cp39-manylinux1_x86_64.whl
File ‘torch-1.9.0-cp39-cp39-manylinux1_x86_64.whl’ already there; not retrieving.
Unpacking to: ./torch-1.9.0...Hash mismatch for file 'torch-1.9.0.dist-info/METADATA'
----------------------------------------
printing hashes
torch-1.9.0-cp39-none-macosx_10_9_x86_64.whl
RECORD entry: torch-1.9.0.dist-info/METADATA,sha256=dGmSiwyVg6BFdUNA20hi3kq6l9skJniczgd281qjq80,25152
manually computed entry: torch-1.9.0.dist-info/METADATA,sha256=dGmSiwyVg6BFdUNA20hi3kq6l9skJniczgd281qjq80,25152
----------------------------------------
printing hashes
torch-1.9.0-cp39-cp39-manylinux1_x86_64.whl
RECORD entry: torch-1.9.0.dist-info/METADATA,sha256=hQJhAIZCgeUw4lHR6-TbBb2JlqQFtioPNhDz-mRNzTQ,25158
manually computed entry: torch-1.9.0.dist-info/METADATA,sha256=dGmSiwyVg6BFdUNA20hi3kq6l9skJniczgd281qjq80,25152
----------------------------------------
record diff:
< torch-1.9.0.dist-info/METADATA,sha256=dGmSiwyVg6BFdUNA20hi3kq6l9skJniczgd281qjq80,25152
> torch-1.9.0.dist-info/METADATA,sha256=hQJhAIZCgeUw4lHR6-TbBb2JlqQFtioPNhDz-mRNzTQ,25158
metadata diff: