Phase 2: Python examples standalone & cross-platform via pyproject#15
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Phase 2 of 4. The Python examples relied on ad-hoc
pip install lxml/pip install saxoncheand on the bashtools/fetch-schema.shto 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 JavaXsdValidate).What changed
pyproject.toml(setuptools): declareslxml+saxonche; shipstools/fundsxml_schema.pyas the importable top-level modulefundsxml_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 (urllibfollows the 302; pulls thexmldsig-core-schema.xsdsibling when imported). Also runnable aspython -m fundsxml_schema <version>. No committed catalog.XSD_Validation/python/validate.pynow usesresolve_schema(dropped thefetch-schema.shsubprocess) → fully standalone.validate_schematron.py: SchXslt jar via$FUNDSXML_SCHXSLT_JARor the Maven local repo (no PyPI SchXslt);saxonchevia the venv. Reference variant — the Java Schematron path remains the verified standalone one.Python - venv & install (pyproject)+Python - XSD validation (in-language schema resolve)steps; everypython3→.venv/bin/python; ad-hocpip install lxmlremoved..gitignore:.venv/,*.egg-info/,.claude/.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,saxoncheXSLT (CSV, 22 lines) and XQuery (top-holdings n=5 → 5).Phases 3 (.NET) and 4 (CLI pair + final bash purge +
windows-latestCI) follow as separate PRs off freshmain.🤖 Generated with Claude Code