Skip to content

Warn when VCS file discovery cannot find its executable - #1570

Merged
RonnyPfannschmidt merged 6 commits into
pypa:mainfrom
mayankdhingra02:codex/warn-missing-vcs-file-finder
Nov 18, 2026
Merged

RonnyPfannschmidt merged 6 commits into
pypa:mainfrom
mayankdhingra02:codex/warn-missing-vcs-file-finder

Conversation

@mayankdhingra02

@mayankdhingra02 mayankdhingra02 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1404.

Warn when file discovery finds Git, Mercurial, or Jujutsu metadata but its executable is missing and no registered finder can return tracked files. Diagnostics are deferred until all finders have been tried, so colocated Git/Jujutsu checkouts stay quiet when either working tool supplies the file list. Direct backend calls retain their existing warning behavior.

The diagnostic uses the nearest checkout, respects ignored roots, and handles missing-command errors without a filename. Finder deduplication applies across both primary and fallback entry-point groups. When version inference has already failed, discovery short-circuits with the existing “file discovery is suppressed” warning instead.

The sdist integration helper uses the existing environment-sanitizing command wrapper, with opt-in merged stdout/stderr. Failed builds expose their complete transcript, preserving output order. Tests cover both missing-tool choices and finder orders, unsuccessful discovery, collector cleanup, command environment cleanup, and a real failed build.

Validation for the latest follow-up on macOS/Python 3.12.9:

  • uv run pytest -n12 --basetemp=<short-task-local-directory>: 901 passed, 76 skipped, 1 expected failure. A short directory avoids macOS GPG socket-path limits; network access was enabled for the PyPI integration tests.
  • All 11 pre-commit run --all-files checks and uv run mkdocs build --clean --strict passed.
  • The affected file-finder, command-wrapper and sdist suites passed independently: 49 passed, 27 skipped. Additional reviewer controls verified nested searches and exception cleanup.
  • The file-finder and command-wrapper tests also pass with the member package's DEBUG logging configuration: 42 passed, 27 skipped. Repository setup logs are cleared before checking search warnings; an independent injected-warning control confirms the assertion still catches warnings from the search itself.

Mercurial and Jujutsu executables were unavailable locally. The new colocated-checkout tests use a real Git repository with stubbed Jujutsu command responses; they do not establish interoperability with a live Jujutsu installation. Other full-suite skips cover optional tools, platform and filesystem cases; the ownership test retains its expected failure without passwordless sudo.

Hosted CI also encountered runner setup failures before executing tests: Python 3.8/3.9 are unavailable on its Ubuntu 26.04 image, and several jobs cannot find hg. These failures are outside the changed file-discovery code; the corresponding jobs remain unverified.

Codex helped reproduce and implement the change, with a separate review of the final diff.

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Claude Opus 5.5 via Claude Code for mayankdhingra02; I prompted it, it did the work, I read it.

Thanks for picking this up. The diagnostic fills a real gap, and the tests cover the tricky bits (worktree marker, nested markers, ignored roots). A few details that slipped through:

  • In the most common case the new warning doesn't fire: a project versioned by setuptools-scm, .git present, git missing. Inference fails first, ScmEggInfoMixin.find_sources enters scm_search_known_failed(), and find_files returns before reaching the finders, so the #1540 warning shows instead. Worth stating in the docs paragraph, or covering that path. (Traced through the code, not run.)
  • Fixes #1404 would close the issue. The issue also asks about an error or a config option, and about frontends that hide log output. Refs #1404 fits better unless those are out of scope.
  • _file_finders/_jj.py has the same silent except OSError, so .jj could get the same treatment.
  • The attempted dedup in find_files applies to every finder in both groups, which is wider than the issue. Please call it out in the description.

@mayankdhingra02 mayankdhingra02 changed the title Warn when file discovery cannot find Git or Mercurial Warn when VCS file discovery cannot find its executable Nov 11, 2026
""")
(cwd / "dist").mkdir(exist_ok=True)
return run([sys.executable, "-c", code], cwd).stdout
result = run([sys.executable, "-c", code], cwd)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for correct interleaving this should use the subprocess constant that sets stderr to stdout

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Claude Opus 5.5 via Claude Code for mayankdhingra02; I prompted it, it did the work, I read it.

Sorry, I should have caught these in my first pass instead of sending you a second round. Thanks for working through the first one so quickly.

1. False warning when a colocated jj+git checkout has only one tool installed

find_files tries the finders one after another. Each backend logs its missing-command warning as soon as the command fails, even if a later finder then lists the files. Installed entry points come back in the order .git, .jj. So in a colocated checkout (.git and .jj at the root, the default for jj git init now) with git missing and jj present, you get:

WARNING:vcs_versioning.file_finder:cannot list tracked files for .git in …/repo because the Git executable was not found
['…/repo/sub/a.py']

The warning says files are missing, but the result is complete. This was reproduced against the PR head with a stub jj on PATH.

A possible fix: the backends record the missing command instead of logging it, and find_files logs what was recorded only if no finder returned results. That also stops the warning depending on entry-point order. A test with two markers at the same root, one tool missing and the other working, would cover it.

2. _build_sdist hides the build output when the build fails

With check=True, a failed build raises CalledProcessError, and pytest doesn't show the captured build output then, which is exactly what you need to debug it. It would be better to keep vcs_versioning._run_cmd.run and check .stdout and .stderr, or to add a way for run to merge the two streams. (This was traced through the code, not run.)

Note: switching to plain subprocess.run also drops the environment cleanup run does (no_git_env, avoid_pip_isolation, LC_ALL). That doesn't matter for this test, but keeping run gets it back for free.

@RonnyPfannschmidt

Copy link
Copy Markdown
Contributor

i will fix the hg install issues on main as they are unrelated to this

@RonnyPfannschmidt
RonnyPfannschmidt merged commit b0c44de into pypa:main Nov 18, 2026
35 checks passed
@RonnyPfannschmidt

Copy link
Copy Markdown
Contributor

thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants