pypa / pypa/setuptools

distutils.FancyGetopt does not hadle repeating options with argument

Open
#2,482 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools inherits command line parsing from distutils which uses the distutils.FancyGetopt class for setting up and performing the parsing. Documentation and comments in the code suggest that it exists a way to specify command line options that can be repeated. However, trying to use this facility for options that take arguments results in only the last specified argument to be retained. It works as expected for boolean options. I believe this is a bug that went so far unnoticed because the code base uses this feature only for the --verbose option which does not take arguments.

I know setuptools is moving away from command line invocation and toward a more declarative style. Is there any motivation to fix this? The patch for making distutils.FancyGetopt.getopt() do the right thing for repeated options with argumentsis just a few lines and I can submit a PR.

I currently monkey patch the method in my project. Some more monkey patching when it comes to setuptools does not even look that bad ;)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the distutils.FancyGetopt.getopt() method named in the issue and inspect how repeated options with arguments are stored, contrasting them with boolean options. Confirm the behavior with a focused regression check: repeated argument-bearing options should retain each specified argument, while existing boolean-option behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.