Skip to content

Pass config_settings from build frontend to builders#2240

Open
brandon-avantus wants to merge 1 commit intopypa:masterfrom
brandon-avantus:backend-config-settings-support
Open

Pass config_settings from build frontend to builders#2240
brandon-avantus wants to merge 1 commit intopypa:masterfrom
brandon-avantus:backend-config-settings-support

Conversation

@brandon-avantus
Copy link
Copy Markdown

As a Python packager writing custom hatchling build hooks (using hatch_build.py), I would like hatchling to support passing config_settings from build frontends that support it to hatchling builders so that users can customize certain aspects of the build experience (i.e., build jobs, compiler choice, etc.) using the command-line options provided by build frontends.

PEP 517 defines a config_settings dictionary in the backend hooks specifications for passing configuration from build frontends. Many build frontends already support passing in config_settings using the -C/--config-settings command-line option.

  • uv build
  • pip install
  • pip wheel
  • pyproject-build (from the build package)

Currently, hatchling does not pass config_settings on to builders. I finally realized that the reluctance to implement such a feature in hatch, as indicated by responses in #1072, stem from the ambiguity in how frontends should implement the feature. What I'm suggesting here is not that we add support to the hatch frontend, but that we provide the backend with settings from frontends that already support it.

See #1072

Please let me know if anything should be added to the documentation or if additional tests would be helpful.

`uv build`, `pip wheel`, and `pyproject-build` (from the build package)
all support passing config settings, as defined in PEP 517, to the build
backend. Until now, `hatchling.build` ignored them. This change passes
the `config_settings` dictionary on to `SdistBuilder` and
`WheelBuilder` so that custom build scripts can access those settings
when passed by frontends that support it.

See pypa#1072
@brandon-avantus
Copy link
Copy Markdown
Author

I just realized this is incomplete. I need to get the config_settings all the way to the BuildHookInterface. I'll update the PR as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant