Bug 2423538

Summary: python-setuptools-git-versioning fails to build with Python 3.15: TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'color'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-buildAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: carl, code, epel-packagers-sig, ksurma, lbalhar, mhroncok, python-packagers-sig, sanjay.ankur
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-build-1.3.0-5.fc44 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-12-21 15:44:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2412434    

Description Karolina Surma 2025-12-18 11:03:38 UTC
python-setuptools-git-versioning fails to build with Python 3.15.0a3.
Over 300 tests fail with:

__________ test_version_file_not_a_repo[create_pyproject_toml-False] ___________

repo_dir = '/tmp/pytest-of-mockbuild/pytest-0/test_version_file_not_a_repo_c3/e98ea737980fcdbbe4b7abc0dcd375b448c0d294a5e5fdae2e7f8bc8ea8f4914'
create_config = <function create_pyproject_toml at 0x7f2ea14f4d50>
count_commits = False

    @pytest.mark.parametrize("count_commits", [True, False])
    def test_version_file_not_a_repo(repo_dir, create_config, count_commits):
        create_file(
            repo_dir,
            "VERSION.txt",
            "1.0.0",
            add=False,
            commit=False,
        )
        create_config(
            repo_dir,
            {
                "version_file": "VERSION.txt",
                "count_commits_from_version_file": count_commits,
            },
            add=False,
            commit=False,
        )
    
>       assert get_version(repo_dir) == "1.0.0"
               ^^^^^^^^^^^^^^^^^^^^^

tests/test_integration/test_version_file.py:248: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/lib/util.py:304: in get_version
    execute(cwd, cmd, **kwargs)
tests/lib/util.py:40: in execute
    return subprocess.check_output(cmd, cwd=cwd, shell=True, universal_newlines=True, **kwargs)  # nosec
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib64/python3.15/subprocess.py:471: in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ('/usr/bin/python3 -m build -s --no-isolation',)
kwargs = {'cwd': '/tmp/pytest-of-mockbuild/pytest-0/test_version_file_not_a_repo_c3/e98ea737980fcdbbe4b7abc0dcd375b448c0d294a5e5fdae2e7f8bc8ea8f4914', 'shell': True, 'stdout': -1, 'universal_newlines': True}
process = <Popen: returncode: 1 args: '/usr/bin/python3 -m build -s --no-isolation'>
stdout = '', stderr = None, retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
        or pass capture_output=True to capture both.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout (seconds) is given and the process takes too long,
         a TimeoutExpired exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '/usr/bin/python3 -m build -s --no-isolation' returned non-zero exit status 1.

/usr/lib64/python3.15/subprocess.py:576: CalledProcessError
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
  File "<frozen runpy>", line 196, in _run_module_as_main
  File "<frozen runpy>", line 87, in _run_code
  File "/usr/lib/python3.15/site-packages/build/__main__.py", line 480, in <module>
    main(sys.argv[1:], 'python -m build')
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.15/site-packages/build/__main__.py", line 419, in main
    parser = main_parser()
  File "/usr/lib/python3.15/site-packages/build/__main__.py", line 325, in main_parser
    parser = make_parser()
  File "/usr/lib64/python3.15/argparse.py", line 1962, in __init__
    self.add_argument(
    ~~~~~~~~~~~~~~~~~^
        default_prefix+'h', default_prefix*2+'help',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        action='help', default=SUPPRESS,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        help=_('show this help message and exit'))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.15/argparse.py", line 1595, in add_argument
    formatter = self._get_validation_formatter()
  File "/usr/lib64/python3.15/argparse.py", line 2787, in _get_validation_formatter
    self._cached_formatter = self._get_formatter()
                             ~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.15/argparse.py", line 2779, in _get_formatter
    formatter = self.formatter_class(prog=self.prog)
TypeError: HelpFormatter.__init__() got an unexpected keyword argument 'color'

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/09930475-python-setuptools-git-versioning/

For all our attempts to build python-setuptools-git-versioning with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/python-setuptools-git-versioning/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2025-12-18 11:56:16 UTC
This is a code in python-build, not here. Backporting https://github.com/pypa/build/pull/962 will make it go away.

However, I think this is a regression in Python 3.15.0a3: https://github.com/python/cpython/pull/142274#issuecomment-3669929215

Comment 2 Miro Hrončok 2025-12-18 20:38:26 UTC
> However, I think this is a regression in Python 3.15.0a3: https://github.com/python/cpython/pull/142274#issuecomment-3669929215

Upstream considers this API private, so we'll need to backport https://github.com/pypa/build/pull/962 either way.