adang1345 / delvewheel

Self-contained Python wheels for Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

delvewheel 1.5.1 broken for Python 3.7

dvarrazzo opened this issue · comments

I noticed a breakage upon release of delvewheel 1.5.1, in psycopg 3 daily build:

The error is: Invalid format './wheelhouse/psycopg_c-3.2.0.dev1-cp37-cp37m-win_amd64.whl'

I understand Python 3.7 is senescent, however the metadata state that delvewheel 1.5.1 is still compatible with Python 3.7.

python_requires = >= 3.7

I think it would be totally reasonable to drop support for Python 3.7, as long as the package metadata are updated accordingly.

I think this is due to the fact that delvewheel 1.5.1 now copies the wheel to the destination as-is if the wheel has no external dependencies, and the psycopg build pipeline is not handling this properly. I noticed that the builds for Python 3.7 ask delvewheel to repair importlib-metadata, typing_extensions, and zipp, which have no DLL dependencies.

From the failed build log:

repairing psycopg_c/dist/importlib_metadata-6.7.0-py3-none-any.whl
finding DLL dependencies
no external dependencies are needed
wheel copied to D:\a\psycopg\psycopg\wheelhouse\importlib_metadata-6.7.0-py3-none-any.whl
repairing psycopg_c/dist/psycopg_c-3.2.0.dev1-cp37-cp37m-win_amd64.whl
finding DLL dependencies
copying DLLs into psycopg_c.libs
mangling DLL names
patching psycopg_c\__init__.py
repackaging wheel
fixed wheel written to D:\a\psycopg\psycopg\wheelhouse\psycopg_c-3.2.0.dev1-cp37-cp37m-win_amd64.whl
repairing psycopg_c/dist/typing_extensions-4.7.1-py3-none-any.whl
finding DLL dependencies
no external dependencies are needed
wheel copied to D:\a\psycopg\psycopg\wheelhouse\typing_extensions-4.7.1-py3-none-any.whl
repairing psycopg_c/dist/zipp-3.15.0-py3-none-any.whl
finding DLL dependencies
no external dependencies are needed
wheel copied to D:\a\psycopg\psycopg\wheelhouse\zipp-3.15.0-py3-none-any.whl

In contrast, the builds for Python 3.8 and higher do not ask delvewheel to repair those other wheels.

repairing psycopg_c/dist/psycopg_c-3.2.0.dev1-cp38-cp38-win_amd64.whl
finding DLL dependencies
copying DLLs into psycopg_c.libs
mangling DLL names
patching psycopg_c\__init__.py
repackaging wheel
fixed wheel written to D:\a\psycopg\psycopg\wheelhouse\psycopg_c-3.2.0.dev1-cp38-cp38-win_amd64.whl

I think the solution would be to update the psycopg build pipeline to avoid repairing importlib-metadata, typing_extensions, and zipp for Python 3.7.

I believe the error is at https://github.com/psycopg/psycopg/blob/2d3835ae2ba7b270d3ac09da7906d8298274d3a2/.github/workflows/tests.yml#L228C22-L228C22.

delvewheel repair --no-mangle "libiconv-2.dll;libwinpthread-1.dll" \
  -w ./wheelhouse/ psycopg_c/dist/*.whl
echo "DEPS=$DEPS $(ls ./wheelhouse/*.whl)" >> $GITHUB_ENV

If psycopg_c/dist/*.whl matches multiple wheels, then delvewheel repairs all of them. If all those wheels end up in the wheelhouse directory, then ls ./wheelhouse/*.whl outputs multiple lines, and multiline strings must be encoded a particular way when written to $GITHUB_ENV. Otherwise they cause an error that matches the error in the build log: Error: Unable to process file command 'env' successfully.

I believe changing that line to

delvewheel repair --no-mangle "libiconv-2.dll;libwinpthread-1.dll" \
  -w ./wheelhouse/ psycopg_c/dist/psycopg_c-*.whl

would fix your problem.