Skip to content

docs: add online validator for versions, requirements, and specifiers - #1434

Open
Topgearfanboy wants to merge 9 commits into
pypa:mainfrom
Topgearfanboy:main
Open

Topgearfanboy wants to merge 9 commits into
pypa:mainfrom
Topgearfanboy:main

Conversation

@Topgearfanboy

Copy link
Copy Markdown

Summary

This PR addresses issue #670 by adding a Pyodide-based online validator that allows users to check and validate requirements and versions in their browser without installing the packaging library.

Changes

  • Add web_validator/: New directory containing an HTML-based validator that uses Pyodide to run the packaging library in the browser
    • index.html: Full-featured web interface with three validators (Version, Requirement, Specifier)
    • README.md: Documentation for the web validator
  • Add docs/validator.rst: Comprehensive documentation for the online validator in the Sphinx docs
  • Update README.rst: Add mention of the online validator in the main README
  • Update docs/index.rst: Include the validator documentation in the docs table of contents with a dedicated Tools section
  • Update .github/workflows/docs.yml: Configure GitHub Pages deployment to publish the validator

Features

The online validator provides three main tools:

  • Version Validator: Parse and validate version strings according to PEP 440
  • Requirement Validator: Validate requirement strings and extract components
  • Specifier Validator: Test version specifiers and check if specific versions match

Use Cases

This is particularly useful for:

  • Users affected by the removal of LegacyVersion (issue Dealing with legacy version parsing functionality being removed #631) who need to test versions without installing the library
  • Quick validation of version strings and requirements
  • Understanding PEP 440 version specification
  • Debugging version comparison issues
  • Learning requirement syntax without installation

Technical Details

  • Uses Pyodide to run Python code in the browser via WebAssembly
  • Installs the latest packaging library from PyPI using micropip
  • Works in all modern browsers that support WebAssembly
  • Initial load: 5-10 seconds, subsequent validations: nearly instant

Test Plan

  • Locally tested the validator by opening web_validator/index.html in a browser
  • Verified all three validators (Version, Requirement, Specifier) work correctly
  • Tested with various valid and invalid inputs
  • Verified documentation builds correctly
  • Confirmed GitHub Pages workflow configuration is correct

Topgearfanboy and others added 2 commits October 2, 2026 11:55
This addresses issue pypa#670 by providing a Pyodide-based online validator
that allows users to check and validate requirements and versions in their
browser without installing the packaging library.

Changes:
- Add web_validator/ directory with index.html that uses Pyodide to run
  packaging library in the browser
- Add docs/validator.rst with comprehensive documentation for the online
  validator
- Update README.rst to mention the online validator
- Update docs/index.rst to include the validator documentation and link
- Update .github/workflows/docs.yml to deploy the validator to GitHub Pages

The validator provides three main tools:
- Version Validator: Parse and validate version strings per PEP 440
- Requirement Validator: Validate requirement strings and extract components
- Specifier Validator: Test version specifiers and check version matches

This helps users affected by the removal of LegacyVersion (issue pypa#631)
by providing an easy way to test versions and requirements without
installing the library.
@henryiii

henryiii commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Interesting! I'd suggest moving this into the docs, though. No need to have a separate page build just for this page when it's a static page that could be on readthedocs. The pyodide version is also old. We can save on download size by removing micropip, that also lets us use the current version easily.

I did check WASI for this, and it would be a lot more work and a 2x bigger download (extra stdlib). Micropython doesn't include (at least) re.VERBOSE.

I've got this set up locally, can push in a minute.

Serve the validator as a page in the Sphinx docs instead of a separate
GitHub Pages site. The docs build zips the packaging source, so each docs
version runs its own code in Pyodide, without micropip or PyPI. Pyodide
loads on first use. Pass input as function arguments to prevent code
injection, and render results as text.

Assisted-by: ClaudeCode:claude-opus-5-5
Run the Pyodide and source downloads in parallel, release PyProxy
objects, and simplify the zip build, CSS, and ruff ignores.

Assisted-by: ClaudeCode:claude-opus-5-5
Move Pyodide into a module worker so that its startup does not block the
page. The page sends checks to the worker as messages, and starts a new
worker if loading fails.

Assisted-by: ClaudeCode:claude-opus-5-5
Route all checks through one Python dispatcher, collapse the worker
lifecycle onto a single ready promise, and style results with furo
admonition classes.

Assisted-by: ClaudeCode:claude-fable-5-1
Add a status indicator, form cards, clickable examples, and result cards
with a valid/invalid header and the normalized value.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii

henryiii commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

I also used a web worker and adjusted the style a bit. You can see the result at https://packaging--1434.org.readthedocs.build/en/1434/validator.html

@henryiii henryiii changed the title Add online validator for versions, requirements, and specifiers docs: add online validator for versions, requirements, and specifiers Oct 6, 2026

This branch has not been deployed

No deployments
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