Skip to content

Commit

Permalink
Relax validation of --global-option in build_meta
Browse files Browse the repository at this point in the history
In `pip` docs, the following example is mentioned:

> python -m pip wheel --global-option bdist_ext --global-option -DFOO wheel

Since both `--global-option` and `--build-option` are supposed to be
compatible with `pip` options, we should not prevent this abuse...
(Although it is still error prone and the user is responsible for
understanding in detail what is going on how this accidentally works).
  • Loading branch information
abravalheri committed Nov 20, 2023
1 parent f431962 commit a5a7505
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ def _get_config(self, key: str, config_settings: _ConfigSettings) -> List[str]:
opts = cfg.get(key) or []
return shlex.split(opts) if isinstance(opts, str) else opts

def _valid_global_options(self):
"""Global options accepted by setuptools (e.g. quiet or verbose)."""
options = (opt[:2] for opt in setuptools.dist.Distribution.global_options)
return {flag for long_and_short in options for flag in long_and_short if flag}

def _global_args(self, config_settings: _ConfigSettings) -> Iterator[str]:
"""
Let the user specify ``verbose`` or ``quiet`` + escape hatch via
Expand Down Expand Up @@ -220,9 +215,7 @@ def _global_args(self, config_settings: _ConfigSettings) -> Iterator[str]:
level = str(cfg.get("quiet") or cfg.get("--quiet") or "1")
yield ("-v" if level.lower() in falsey else "-q")

valid = self._valid_global_options()
args = self._get_config("--global-option", config_settings)
yield from (arg for arg in args if arg.strip("-") in valid)
yield from self._get_config("--global-option", config_settings)

def __dist_info_args(self, config_settings: _ConfigSettings) -> Iterator[str]:
"""
Expand Down

0 comments on commit a5a7505

Please sign in to comment.