pypa / pyproject-hooks

A low-level library for calling build-backends in `pyproject.toml`-based project
https://pyproject-hooks.readthedocs.io/
MIT License
122 stars 49 forks source link

`build_editable` provides wrong arguments #200

Closed thejcannon closed 4 months ago

thejcannon commented 4 months ago

https://github.com/pypa/pyproject-hooks/blob/261e4d82121782d05f6fddfaded8b8a7493d0370/src/pyproject_hooks/_in_process/_in_process.py#L195

According to PEP 660, this ought to be:

def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
    ...

(proof from setuptools: https://github.com/pypa/setuptools/blob/720862807dea012f3a0e7061880691025f736f11/setuptools/build_meta.py#L435)

takluyver commented 4 months ago

The line you're highlighting there is part of the fallback pathway for prepare_metadata_for_build_editable. The idea is that if the backend doesn't provide that hook, we fall back to creating the (edtitable) wheel, then extract the metadata from it, saving the wheel alongside it, where a future call to build_editable can use it. In this scenario, the parameters make sense - metadata_directory is the location this hook has been given to save output.

You can see the 'proper' invocation of the build_editable hook here:

https://github.com/pypa/pyproject-hooks/blob/261e4d82121782d05f6fddfaded8b8a7493d0370/src/pyproject_hooks/_in_process/_in_process.py#L294

thejcannon commented 4 months ago

Oh, so you're explicitly passing the metadata directory as the wheel directory as sort of a shortcut. You could use a tempdir, but then you'd be building the wheel twice as per this code?

Ok I see it now. Maybe next time you're in the neighborhood drop a comment, so the next guy isn't as puzzled as I was (and ultimately looks like the bug was my hook wasn't giving defaults for the latter two parameters which is what led me here).

thejcannon commented 4 months ago

Hope you have a nice weekend and life is treating you well. Thanks for responding!