Support the metadata directory (as per PEP-517) for build_wheel
Summary of changes
Allow dist-info-dir to be passed to bdist_wheel.
More importantly, fixes the build_wheel PEP-517 interface to treat the given metadata as per the spec.
With this change, I was able to verify that I could:
python setup.py dist_info
touch setuptools-74.1.2.post20240913.dist-info/FOO
python setup.py bdist_wheel --dist-info-dir setuptools-74.1.2.post20240913.dist-info/
And the resulting wheel contained my desired metadata file. My personal goal is to support this behaviour in PEP-517 build backends, and to write a setuptools build backend wrapper which injects such metadata (I need to do something like setuptools-ext does). Presently, the functionality does not exist, you end up having to post-process the built wheel (hence the complexity that exists in setuptools-ext).
Honestly, despite having written many Command subclasses over many years, I am very unfamiliar with the intricacies of distutils.Command and setuptools in general, and may have implemented a solution which is not quite right due to a lack of that knowledge.
Closes #1825. Follows a prototype I did in https://github.com/pypa/wheel/issues/611.
Pull Request Checklist
- [x] Changes have tests
- [x] News fragment added in
newsfragments/. (See documentation for details)
Also, I just noticed you're a first-time contributor. Thanks for the contribution and nice work!
I noticed that this PR needed a rebase, so have just done so. Please let me know if there is anything else you need from my side.
Thank you very much!
Thanks for your review :+1: :tada:
This seems to have broken building some projects. https://github.com/yaml/pyyaml I am seeing failures like:
Processing /home/tcaswell/source/p/yaml/pyyaml
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: PyYAML
Building wheel for PyYAML (pyproject.toml): started
Building wheel for PyYAML (pyproject.toml): finished with status 'error'
Failed to build PyYAML
error: subprocess-exited-with-error
× Building wheel for PyYAML (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
usage: _in_process.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: _in_process.py --help [cmd1 cmd2 ...]
or: _in_process.py --help-commands
or: _in_process.py cmd --help
error: option --dist-info-dir not recognized
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for PyYAML
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (PyYAML)
with the main branch of setuptools, but going back to the commit before this was merged (3106af0512fe67464a8b5e7524c07fddf7717660 which is v75.1.0) works again.
I have not had time to debug this further and it is not all packages nor do I know if this is the only one.
Looks like that project is importing bdist_wheel from wheel (https://github.com/yaml/pyyaml/blob/69c141adcf805c5ebdc9ba519927642ee5c7f639/setup.py#L97) and setting that as the bdist_wheel command.
To be honest, that implementation looks to be rather unnecessary - I'm not sure on the backwards compat policy of setuptools, but I think this one is best addressed in pyyaml otherwise it will never be possible to add and use new features to the bdist_wheel command in setuptools.
Looks like that project is importing
bdist_wheelfromwheelTo be honest, that implementation looks to be rather unnecessary
@henryiii already has a proposed fix in https://github.com/yaml/pyyaml/pull/823 (a few weeks before I made this MR :joy:).
OK, I hit the PyYAML problem in the integration tests when trying to cut a release. I wonder if there is any workaround for this problem. Trying out #4684.