Skip to content

Conversation

@thrau
Copy link
Member

@thrau thrau commented Nov 28, 2025

Motivation

Plux has been deeply depending on setuptools, but with #34 we now have a way to easily integrate new build backends. Hatch and hatchling are the first candidates given their significance in the python ecosystem.

This PR adds a Project implementation for hatchling as build backend, but limited to manual build mode for now (no build hook integration). The main things I added are:

  • Finding packages with hatchling: The primary difference to manual build mode in setuptools is the way the config is scanned and packages are discovered. In setuptools, there is a package finder that already recursively lists all existing python packages in the source tree. Hatchling does not have that, so I needed to add our own implementation that resolves packages, but uses information from the hatchling config in the case of namespace packages.

  • Test isolation: Because having both hatchling and setuptools in the same process makes testing unreliable, I found a hacky way to isolate tests (see the docstrings in the module for more explanation). I guess it's ok for now, given that everything was previously set up to use setuptools, so the codebase is still biased towards it. In the future, it would be great if we find a better way to test and develop multiple build backends.

  • Build backend detection: I had to add explicit build backend detection to fix an issue where setuptools may be in the sys path, but actually hatchling is being used. I added a config option with which the build backend can be set explicitly with [tool.plux] build_backend = "hatchling" if needed, but will automatically pick the one that's set in the build-backend field of build-system . If none of that is set it falls back to auto detection using imports.

Changes

  • Hatchling support for manual entrypoint build mode
  • Build backend can now be set explicitly with [tool.plux] build_backend = "hatchling" if needed, but will automatically pick the one that's set in the build-backend field of build-system

TODO

  • package discovery for hatchling
  • isolated testing mode for hatchling and setuptools
  • explicit build backend selection via config (setuptools seems to be included somehow in 3.10 and 3.11, which always leads to setuptools being selected, see this run)
  • more tests for hatch config scenarios

@thrau thrau force-pushed the hatchling-support branch from 3c47c8d to a7bac7b Compare January 28, 2026 21:07
@thrau thrau marked this pull request as ready for review January 29, 2026 13:36
@thrau thrau requested a review from dfangl as a code owner January 29, 2026 13:36
Comment on lines 196 to 198
if plux_config.bild_backend != BuildBackend.AUTO:
# first, check if the user configured one
return plux_config.bild_backend
Copy link
Member

@dfangl dfangl Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if plux_config.bild_backend != BuildBackend.AUTO:
# first, check if the user configured one
return plux_config.bild_backend
if plux_config.build_backend != BuildBackend.AUTO:
# first, check if the user configured one
return plux_config.build_backend

I will review the rest a bit later, however this seems like an obvious error 😅 It is quite consistent, however it is not instantiated with that name on line 138.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for spotting, i'll do one more pass and write some tests :)

@thrau thrau requested a review from dfangl January 29, 2026 17:00
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.

3 participants