-
Notifications
You must be signed in to change notification settings - Fork 0
add hatchling support for manual build mode #35
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
base: main
Are you sure you want to change the base?
Conversation
3c47c8d to
a7bac7b
Compare
plux/build/config.py
Outdated
| if plux_config.bild_backend != BuildBackend.AUTO: | ||
| # first, check if the user configured one | ||
| return plux_config.bild_backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
There was a problem hiding this comment.
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 :)
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
Projectimplementation 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 thebuild-backendfield ofbuild-system. If none of that is set it falls back to auto detection using imports.Changes
[tool.plux] build_backend = "hatchling"if needed, but will automatically pick the one that's set in thebuild-backendfield ofbuild-systemTODO