Skip to content

[Bug]: Sdist dependency discovery calls the wheel requirements hook #1351

Description

@mikedep333

Environment

  • Fromager version: Latest on main branch. e2e7ade Issue is present in released Fromager 0.97.0.
  • Python version: 3.14.7.
  • OS / architecture: Fedora Linux 44
  • Container or local: local checkout, tests run in a Hatch virtual environment

Bug description

Expected behavior:

default_get_build_sdist_dependencies() should call the backend's
get_requires_for_build_sdist() hook and return its requirements.
If that optional hook is absent, the result should be an empty list.
Wheel-specific dependency discovery should not execute in this function.

PEP 517 specifies these as separate hooks:
https://peps.python.org/pep-0517/#get-requires-for-build-sdist

Actual behavior:

The function calls get_requires_for_build_wheel() instead. Its docstring
also refers to the wheel hook.

When the two hooks return different requirements, Fromager returns the
wheel requirements for sdist dependency discovery, omitting sdist-only
requirements. When the sdist hook is absent, it returns wheel requirements
instead of the empty default. If the wheel hook raises, sdist dependency
discovery fails even when the sdist hook works.

Steps to reproduce / logs:

  1. Use an in-tree backend with different wheel and sdist requirements:

    def get_requires_for_build_wheel(config_settings=None):
        return ["wheel-only>=1"]
    
    
    def get_requires_for_build_sdist(config_settings=None):
        return ["sdist-only>=2"]
  2. Configure a pyproject_hooks.BuildBackendHookCaller with this backend,
    backend_path=["."], and the current Python executable.

  3. Call default_get_build_sdist_dependencies() with that caller. The
    regression test replaces only the caller factory; pyproject-hooks invokes
    the backend in a real subprocess.

  4. Observe ["wheel-only>=1"] rather than ["sdist-only>=2"].

Changing the call and matching docstring to get_requires_for_build_sdist()
makes all three pass. The complete dependency test file then passes:

26 passed in 2.50s

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions