question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build meta wheel does not respect metadata_directory per PEP-517

See original GitHub issue

From https://www.python.org/dev/peps/pep-0517/#build-wheel:

If the build frontend has previously called prepare_metadata_for_build_wheel and depends on the wheel resulting from this call to have metadata matching this earlier call, then it should provide the path to the created .dist-info directory as the metadata_directory argument.

https://github.com/pypa/setuptools/blob/master/setuptools/build_meta.py#L208 though ignores the passed in metadata_directory argument and goes to regenerate this information in the root of the project.

    def build_wheel(self, wheel_directory, config_settings=None,
                    metadata_directory=None):
        return self._build_with_temp_dir(['bdist_wheel'], '.whl',
                                         wheel_directory, config_settings)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
uranusjrcommented, Feb 1, 2021

But then what happens if a backend return different things from build_wheel and prepare_metadata_for_build_wheel? (Which setuptools is guity of doing right now.) It is certainly possible to remove the requirement for backend to make use of the metadata_directory argument, but the backend should still somehow return consistent things from the two hooks. Otherwise the frontend would be stuck and can’t proceed. The discussion needs to be moved to discuss.python.org if you want to do that so frontend authors can join the conversation.

0reactions
wimglenncommented, May 15, 2022

setuptools-ext is a thin wrapper around setuptools.build_meta allowing to specify some more metadata fields such as Requires-External, which aren’t otherwise supported by setuptools. Passing around the metadata_directory (ref) would have been really useful if it worked!

If setuptools were to diligently follow PEP 517 (i.e. does not just ignore the metadata_directory), we could simply call prepare_metadata_for_build_wheel before dropping in some additional files, or modify existing ones, under .dist-info subdir, and then call build_wheel passing in the metadata dir.

However since that didn’t work, instead setuptools-ext has to call build_wheel, and then completely rewrite the result, which is a lot more complicated (considering that modifying the METADATA file also invalidates the RECORD file!)

This “tweaking” of a build backend by wrapping the hooks is apparently an expected usage, because it’s documented as a way for an in-tree build backend to augment the build dependencies (by @abravalheri here). It’s unfortunate that one can’t reliably use a similar technique for prepare_metadata_for_build_wheel + build_wheel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nobody is following the metadata_directory promise in PEP 517
The directory passed in by the build frontend MUST be identical to the ... build meta wheel does not respect metadata_directory per PEP-517...
Read more >
Could not build wheels for _ which use PEP 517 and cannot ...
The easiest solution to deal with the error "Could not build wheels for ____ which use PEP 517 and cannot be installed directly"....
Read more >
could not build wheels for pandas, numpy which use pep 517 ...
I think NumPy is not yet being prepared for Python 3.9 since they need to check a lot of times. You should try...
Read more >
Changelog - PDM
#1401; Do not save the python path when using non-interactive mode in pdm init . ... Bug Fixes#. Respect requires-python when creating the...
Read more >
Sharing Your Labor of Love: PyPI Quick and Dirty
This is not a history lesson, therefore we will use: pip to install packages,; setuptools, wheel, and build to build your packages in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found