Skip to content

🎨📝 Fix in-tree PEP 517 backend wrapper example #3893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/3893.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improved the documentation example regarding making a thin :pep:`517` in-tree
backend wrapper of ``setuptools.build_meta`` that is future-proof and supports
:pep:`660` hook too -- by :user:`webknjaz`.
17 changes: 10 additions & 7 deletions docs/build_meta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ the ``_custom_build/backend.py`` file, as shown in the following example:
.. code-block:: python

from setuptools import build_meta as _orig

prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist
from setuptools.build_meta import *


def get_requires_for_build_wheel(config_settings=None):
Expand All @@ -151,9 +148,15 @@ the ``_custom_build/backend.py`` file, as shown in the following example:
return _orig.get_requires_for_build_sdist(config_settings) + [...]


Note that you can override any of the functions specified in :pep:`PEP 517
<517#build-backend-interface>`, not only the ones responsible for gathering
requirements.
.. note::

You can override any of the functions specified in :pep:`PEP 517
<517#build-backend-interface>`, not only the ones responsible for gathering
requirements. It is important to ``import *`` so that the hooks that you
choose not to reimplement would be inherited from the setuptools' backend
automatically. This will also cover hooks that might be added in the future
like the ones that :pep:`660` declares.


.. important:: Make sure your backend script is included in the :doc:`source
distribution </userguide/distribution>`, otherwise the build will fail.
Expand Down