poetry-core icon indicating copy to clipboard operation
poetry-core copied to clipboard

fix binary wheel tag determination

Open jrandall opened this issue 2 years ago • 0 comments

Resolves: poetry#3509 (https://github.com/python-poetry/poetry/issues/3509)

This change fixes a bug with poetry-core when building a binary wheel (actually any wheel that uses a build script). The previous behaviour was that the wheel tag was determined according to the first entry in the list of compatible tags returned from the python interpreter that is running poetry. However, that is in some cases not the version of python being used to actually build the wheel and so the tag can often be wrong.

In addition, some projects will have outside information as to which of the compatible tags is most appropriate to use (such as selecting a PEP-513 style manylinux1 based tag rather than the default most-specific tag, which tends to currently be one of the new PEP-600 style manylinux_${GLIBCMAJOR}_${GLIBCMINOR}_${ARCH} tags which are only supported by the very latest versions of package managers. For this reason, this change introduces a new build-config option that allows one to specify a filter (regex) in the config and use it to select the first matching tag. This is backwards compatible with previous behaviour (selecting the first listed tag) when no regex is specified.

  • [ ] Added tests for changed code.
  • [ ] Updated documentation for changed code.

Tests have not been updated as I am not certain how to extend the text environment to support testing a binary wheel build that is built against a different python interpreter than the one poetry is running in.

The documentation has not been updated as I did not locate any documentation in poetry-core that references any of this functionality, so I am not sure where it should belong. User-facing documentation of the build-config / build-script functionality seems to be missing from poetry as well (though I think it would be appropriate to add some documentation to poetry following incorporation of this fix).

There does not appear to be a develop branch in poetry-core, so this is currently based on master (PR template indicated it should be based against develop which is why I bring it up).

Because the fix requires the ability to enumerate compatible tags in the target/build python interpreter, following this change any project that uses a build script to build a wheel should include packaging = ">= 20.0" in the dev-dependencies for the project so that that dependency is installed into the environment (it is included with poetry itself, but poetry is not typically installed into the target environment).

jrandall avatar Nov 04 '21 10:11 jrandall