-
-
Notifications
You must be signed in to change notification settings - Fork 541
Description
What's the problem this feature will solve?
I want to test my sdist packages that requires a pep517 backend config setting to be built. However, there doesn't seem to be a way to set this when using "tox run" with "--installpkg".
Describe the solution you'd like
When using pip and uv, I can set config settings using "--config-setting" and these values will be passed to the pep517 builder's build_wheel function hook . However, There doesn't seem to be a way to pass these values to the pep517 build using tox from the command line.
What I would like to happen is that I could run tox like this
tox run --installpkg "pykdu_compress-0.1.11.dev0.tar.gz" --config-setting=kdusdk-libdir=/somewhere/on/my/machine/libs --config-setting=kdusdk-libdir=/somewhere/on/my/machine/libs
I would love to be able to set this for normal builds other than sdist packages too.
tox run --config-setting=kdusdk-libdir=/somewhere/on/my/machine/libs --config-setting=kdusdk-libdir=/somewhere/on/my/machine/libs
In fact, the only place where this wouldn't make sense would be with using config-settings is with a whl, since a whl is already built.
Having a way to set config-setting in tox run would make testing packages that have C extensions dependencies much easier because a custom pep517 builder can override a standard config and test builds against user-defined pre-built dependencies.
Alternative Solutions
The way I've worked around this in the past is having my pep517 builders accept environment variables in build_wheel(wheel_directory, config_settings, metadata_directory) as well as taking values from config_settings parameter. However, environment variables can get messy and multiple things could use the same environment variables.
I've tried using config_settings_get_requires_for_build_sdist, config_settings_build_sdist, config_settings_get_requires_for_build_wheel, config_settings_prepare_metadata_for_build_wheel, config_settings_build_wheel, config_settings_get_requires_for_build_editable, config_settings_prepare_metadata_for_build_editable configurations that were added in Tox version 4.11 but these features are not clearly documented on how to use them.
From what I can tell, the values set in config_settings_build_wheel don't get passed to build_wheel() in the pep517 unless you have package = wheel in [testenv]. Also, from what I gathered config_settings_build_wheel only works when used in the testenv for the wheel build environment.
If one sets package to wheel in [testenv], tox uses "<package_env>-" template by default and it's not possible to configure a templated testenv such as [testenv:<package_env>-]. If you override this by "setting wheel_build_env" to a hard-coded value, the every version of Python that you are testing using the same wheel file to test against the same whl file. This becomes a problem if your wheel is Python version specific, such as in the case with ones that contain C extensions.