Skip to content

feat(check): offer wheelgap --deps command when setup.cfg or pyproject.toml names a PyPI package - #228

Merged
patrickballard merged 5 commits into
wheelgap:mainfrom
dev-burnern:feat/setup-cfg-package-fallback
Nov 22, 2026
Merged

patrickballard merged 5 commits into
wheelgap:mainfrom
dev-burnern:feat/setup-cfg-package-fallback

Conversation

@dev-burnern

Copy link
Copy Markdown
Contributor

Closes #221

What this changes

  • site/check/check-logic.mjs:
    • Adds projectNameFromMetadata(filename, text) to extract a plain, valid PEP 508 package name from root setup.cfg ([metadata] name = ..., rejecting attr:, file:, and invalid characters) or pyproject.toml ([project] name = "..."), without reading setup.py.
    • Adds packageCliCommand(packageName, pythons, platforms) with strict package-name validation so nothing can be injected into a copied command line.
  • site/check/worker.mjs:
    • When a repo has no lockfile (and has root setup.cfg) or only root pyproject.toml, fetches that file and returns projectName from projectNameFromMetadata().
  • site/check/check.mjs:
    • Adds showPackageFallback(packageName): shows No lockfile found, but this looks like the PyPI package <name>., renders the uvx wheelgap --deps <name> ... command (with a Copy command button using copy()), and checks ../data/packages/<canonical>.json via HEAD to offer a link to ../p/<canonical>/ only when the package is in the scan.
    • Uses showPackageFallback() in noLockfile() and when a lone pyproject.toml fails with a source error.
    • Drops the unhelpful "Run uvx wheelgap in a checkout for anything else." sentence from noLockfile() when no readable input or package name is found.
  • tests/site/check-logic.test.mjs & tests/site/check-page.test.mjs:
    • Covers projectNameFromMetadata() (name = httpie, attr:, file:, invalid characters, [project] name = "x", wrong sections, setup.py), packageCliCommand() validation, and noLockfile() with and without a detected setup.cfg package name.

AI tools used (if any): Antigravity (Gemini)

Checklist

  • node --check site/check/*.mjs passes
  • node --test tests/site/check-logic.test.mjs tests/site/check-page.test.mjs passes (39/39)

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks, @dev-burnern! The care over the copied command is great to see: packageCliCommand() refuses anything that isn't a plain package name, and projectNameFromMetadata() turns down attr: and file: values instead of guessing, so nothing odd can end up in a visitor's terminal.

It looks good overall. #221 is a help wanted issue on the checker page, so Patrick will review and merge this one himself.

(Review assisted by Claude.)

patrickballard and others added 4 commits November 22, 2026 11:15
….toml, and parse names as configparser and TOML do

A lone root pyproject.toml with only [build-system] (the usual setuptools layout) was the only file read for the name, so the setup.cfg's [metadata] name was never offered and the visit ended in "no [project] table", the wheelgap#221 dead end. metadataFiles() now tries the pyproject.toml, then setup.cfg. The name reader also no longer takes a value continued on an indented line, a [METADATA] section, or a name under a [[tool.uv.index]] or commented header as the project's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…this repo's targets

setup.cfg: a deeper-indented line after name = httpie continues the value (configparser reads httpie\nevil), blank or comment lines in between or not; that's no plain name now. pyproject.toml: a multi-line string isn't tracked, so a name = line inside one was read as [project]'s; any triple-quoted string before the name now gives null. And onLoaded() set the Pythons and platforms only after the no-lockfile return, so the --deps command used the previous repo's; they're set first now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolved with wheelgap#226 and wheelgap#229 as the second review set out. The page state and onLoaded() take both fileInTree and projectName, and the worker returns both; onLoaded() keeps wheelgap#226's picked/fileNotice and wheelgap#229's chooser, with the targets set before the no-lockfile answer. noLockfile() puts wheelgap#226's notice first on wheelgap#228's text, without the Run uvx wheelgap sentence; showPackageFallback() shows the notice first in #alerts; onResult()'s error branch keeps wheelgap#226's notice in the status, then the package fallback. The worker reads the project name with metadataFiles() over the files that aren't wheelgap#229's other-named requirements files. chooseFile() also offers the --deps command when the repo names its package. Tests: both sides kept; wheelgap#228's harnesses given pickRequestedFile, privatePyprojectReason, autoPick and chooseFile; its status assertion matches main's capitalised Wheelgap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, then --deps

wheelgap#229's test matched the one-line alerts call that the merge's --deps addition split in two, so it failed although the notice still comes first. It now runs chooseFile() on stand-ins: a named-file notice is the first alert, the package's --deps command the second, and neither shows when there's nothing to say. Every other source-matching assertion in check-page.test.mjs was checked against the merged check.mjs, worker.mjs and index.html.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard
patrickballard merged commit 77542da into wheelgap:main Nov 22, 2026
1 check passed
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @dev-burnern! We pushed a few fixes to your branch before merging; the commits say what and why.

(Posted with help from Claude.)

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.

Repo checker: "No lockfile found" for a library that declares its dependencies in setup.cfg; offer the check that does work

2 participants