The build project now has a --config-setting flag to pass options to the backend:
$ python -m build --help
usage: python -m build [-h] [--version] [--sdist] [--wheel] [--outdir dir] [--skip-dependencies]
[--no-isolation] [--config-setting CONFIG_SETTING]
[srcdir]
- - - >8 - - -
--config-setting CONFIG_SETTING, -C CONFIG_SETTING
pass option to the backend
I wanted to use this to set wheel's --plat-name argument like so:
$ python -m build --wheel --config-setting plat-name=foo
I found that this worked as expected until the settings got to setuptool's _build_with_temp_dir function:
|
def _build_with_temp_dir(self, setup_command, result_extension, |
|
result_directory, config_settings): |
|
config_settings = self._fix_config(config_settings) |
|
result_directory = os.path.abspath(result_directory) |
|
|
|
# Build in a temporary directory, then copy to the target. |
|
os.makedirs(result_directory, exist_ok=True) |
|
with tempfile.TemporaryDirectory(dir=result_directory) as tmp_dist_dir: |
|
sys.argv = (sys.argv[:1] + setup_command + |
|
['--dist-dir', tmp_dist_dir] + |
|
config_settings["--global-option"]) |
In this example, _build_with_temp_dir gets called with config_settings={'plat-name': 'foo'}, which then gets 'fixed' into config_settings={'plat-name': 'foo', '--global-option': []}, and then setuptools ignores everything in config_settings and only considers --global-option.
It almost seems like --global-option itself could be used for this, but unfortunately it doesn't work as it's value is passed to lots of things that don't accept the arguments I'm hoping to pass:
$ python -m build --wheel --config-setting="--global-option=--plat-name" --config-setting="--global-option=foo" -n
usage: _in_process.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: _in_process.py --help [cmd1 cmd2 ...]
or: _in_process.py --help-commands
or: _in_process.py cmd --help
error: option --plat-name not recognized
...
I created a commit that "fixes" this for me as a proof of concept: fc95b3b
Possibly related issues:
The
buildproject now has a--config-settingflag to pass options to the backend:I wanted to use this to set
wheel's--plat-nameargument like so:I found that this worked as expected until the settings got to setuptool's
_build_with_temp_dirfunction:setuptools/setuptools/build_meta.py
Lines 190 to 200 in d368be2
In this example,
_build_with_temp_dirgets called withconfig_settings={'plat-name': 'foo'}, which then gets 'fixed' intoconfig_settings={'plat-name': 'foo', '--global-option': []}, and then setuptools ignores everything inconfig_settingsand only considers--global-option.It almost seems like
--global-optionitself could be used for this, but unfortunately it doesn't work as it's value is passed to lots of things that don't accept the arguments I'm hoping to pass:I created a commit that "fixes" this for me as a proof of concept: fc95b3b
Possibly related issues: