question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setuptools does not pass config_settings through backend

See original GitHub issue

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:

https://github.com/pypa/setuptools/blob/d368be2b5be8676ba8a3d55045b45b55090f6982/setuptools/build_meta.py#L190-L200

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: https://github.com/pypa/setuptools/commit/fc95b3b83d6d5b561dc0a356995edf4c99785a6f

Possibly related issues:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
FFY00commented, Jan 16, 2021

FYI I am also in favor of removing the dashes, I don’t think they are needed in PEP 517.

1reaction
laydaycommented, Mar 3, 2022

I commented on this upthread:

Incidentally, global options in setuptools seem to mean something different than they do in pip where they are placed in front of the setuptools command. Here, they are appended to the command. pip users might find the discrepancy surprising.


It is not immediately clear to me that the spec mandates that --global-option should come before setup_command […]

This is all setuptools-specific stuff, the spec has no notion of global options nor does it expect that options will be passed to a CLI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access Python config settings from a python script ...
The link in the side note section of the question doesn't seem to be ... The build backend is setuptools but only in...
Read more >
Is `config_settings` supposed to be constant between all PEP ...
In reality, I don't think anyone has done anything much with config settings at this point - I know pip hasn't. I'm not...
Read more >
Development Mode (a.k.a. “Editable Installs”) - Setuptools
However, depending on the file and directory organization in your project, it might also expose as a side effect files that would not...
Read more >
python_distribution - Pants build system
You can also set almost any keyword argument accepted by setup.py in the ... PEP-517 config settings to pass to the build backend...
Read more >
scikit-build-core - PyPI
Wheels are not fully reproducible yet; Windows ARM support missing. Other backends are also planned: Setuptools integration highly experimental ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found