Skip to content

Phase 2: Python examples standalone & cross-platform via pyproject#15

Merged
karlkauc merged 1 commit into
mainfrom
feat/python-pyproject-standalone
May 16, 2026
Merged

Phase 2: Python examples standalone & cross-platform via pyproject#15
karlkauc merged 1 commit into
mainfrom
feat/python-pyproject-standalone

Conversation

@karlkauc

Copy link
Copy Markdown
Contributor

Why

Phase 2 of 4. The Python examples relied on ad-hoc pip install lxml / pip install saxonche and on the bash tools/fetch-schema.sh to materialise the XSD — not standalone, not Windows-friendly. This makes the Python stack install with one idiomatic OS-agnostic command and resolve the schema in-language (mirroring Phase 1's Java XsdValidate).

What changed

  • pyproject.toml (setuptools): declares lxml + saxonche; ships tools/fundsxml_schema.py as the importable top-level module fundsxml_schema. Bootstrap: python -m venv .venv && pip install -e . (venv works on Windows too).
  • tools/fundsxml_schema.py — 3-step resolver, same convention as Java: $FUNDSXML_SCHEMA_DIR (offline/corporate escape hatch) → .schema-cache/ → download from the official GitHub release (urllib follows the 302; pulls the xmldsig-core-schema.xsd sibling when imported). Also runnable as python -m fundsxml_schema <version>. No committed catalog.
  • XSD_Validation/python/validate.py now uses resolve_schema (dropped the fetch-schema.sh subprocess) → fully standalone.
  • validate_schematron.py: SchXslt jar via $FUNDSXML_SCHXSLT_JAR or the Maven local repo (no PyPI SchXslt); saxonche via the venv. Reference variant — the Java Schematron path remains the verified standalone one.
  • CI: new Python - venv & install (pyproject) + Python - XSD validation (in-language schema resolve) steps; every python3.venv/bin/python; ad-hoc pip install lxml removed.
  • .gitignore: .venv/, *.egg-info/, .claude/.
  • Docs swept: XSD/Schematron/XQuery/XSLT/DataBinding READMEs, root README, CONTRIBUTING, CLAUDE.md → venv + pyproject bootstrap.

Verification

Verified locally in a fresh python -m venv .venv && pip install -e .: validate.py (cold download / cache-hit / $FUNDSXML_SCHEMA_DIR / negative fixture exits 1), DB round-trip + xml_equiv + XSD-valid, JSON round-trip equiv, large-file make/stream/split/delta, saxonche XSLT (CSV, 22 lines) and XQuery (top-holdings n=5 → 5).

Phases 3 (.NET) and 4 (CLI pair + final bash purge + windows-latest CI) follow as separate PRs off fresh main.

🤖 Generated with Claude Code

Replace ad-hoc `pip install lxml/saxonche` and the bash fetch-schema.sh
prerequisite for the Python stack with an idiomatic, OS-agnostic install.

- Root pyproject.toml (setuptools): deps lxml + saxonche; ships
  tools/fundsxml_schema.py as the importable top-level module
  `fundsxml_schema`. Bootstrap is one cross-platform command:
  `python -m venv .venv && pip install -e .` (venv works on Windows too).
- tools/fundsxml_schema.py: the Python counterpart of the Java resolver —
  $FUNDSXML_SCHEMA_DIR (offline/corporate escape hatch) -> .schema-cache/ ->
  download from the official GitHub release (urllib follows the 302; pulls
  the xmldsig-core-schema.xsd sibling when imported). Also runnable as
  `python -m fundsxml_schema <version>`. Official release stays the source
  of truth; no committed catalog.
- XSD_Validation/python/validate.py now uses resolve_schema (dropped the
  fetch-schema.sh subprocess) -> fully standalone.
- validate_schematron.py: SchXslt jar located via $FUNDSXML_SCHXSLT_JAR or
  the Maven local repo (no PyPI SchXslt); saxonche via the venv. Reference
  variant — the Java Schematron path is the verified standalone one.
- CI: new "Python venv & install (pyproject)" + "Python XSD validation"
  steps; every `python3` -> `.venv/bin/python`; ad-hoc pip installs removed.
- .gitignore: .venv/, *.egg-info/, .claude/ (harness state).
- Docs swept (XSD/Schematron/XQuery/XSLT/DataBinding READMEs, root README,
  CONTRIBUTING, CLAUDE.md) to the venv + pyproject bootstrap.

Verified locally in a fresh venv: validate.py (cold download / cache-hit /
$FUNDSXML_SCHEMA_DIR / negative fixture rc=1), DB round-trip + xml_equiv +
XSD-valid, JSON round-trip equiv, large-file make/stream/split/delta,
saxonche XSLT (CSV) and XQuery (top-holdings n=5 -> 5).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@karlkauc karlkauc merged commit 03c751c into main May 16, 2026
2 checks passed
@karlkauc karlkauc deleted the feat/python-pyproject-standalone branch May 16, 2026 07:00
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.

1 participant