Repository navigation
Single-source the version, package GRAPH.md, harden the publish gate - #41
Draft
Deep-Sixed wants to merge 1 commit into
Draft
Deep-Sixed wants to merge 1 commit into
Deep-Sixed wants to merge 1 commit into
Conversation
The 0.1.1 wheel on PyPI reports __version__ "0.1.0" from both packages because the version was written by hand in three places and the publish check compared the tag against only pyproject.toml. The version now lives once, in contextmesh/__init__.py; pyproject.toml reads it as dynamic metadata and contextmesh_mcp re-exports it. GRAPH.md was shipped through package data "../GRAPH.md", which installs it loose at the top of site-packages where any other distribution's GRAPH.md can overwrite or delete it. A build_py hook in setup.py now copies it into contextmesh/, MANIFEST.in keeps it in the sdist, and the ontology loader prefers the packaged copy, falling back to the repository root for source checkouts and editable installs. The publish workflow now verifies release identity against the built wheel's metadata: tag and version are compared as PEP 440 versions and filenames use the normalized form, so v1.0.0-rc.1 publishes 1.0.0rc1. A GitHub pre-release must carry a pre-release version and a full release must not. The checks exit explicitly instead of using assert, which python -O strips. The release-candidate gate now fails a wheel without exactly contextmesh/GRAPH.md, and an installed wheel whose version strings disagree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes five findings from a review of #39 (the 0.1.1 PyPI release).
What was wrong
contextmesh-graph0.1.1 wheel on PyPI reportscontextmesh.__version__ == contextmesh_mcp.__version__ == "0.1.0". The version was typed by hand in three places, and the publish check compared the tag againstpyproject.tomlonly.GRAPH.mdinstalled loose in site-packages. The package-data entrycontextmesh = ["../GRAPH.md"]puts the file atsite-packages/GRAPH.md, outside any package. Another distribution'sGRAPH.mdcan overwrite or delete it, and the ontology then fails to load.v0.1.2, would have gone to PyPI as the releasepip install contextmesh-graphpicks up.v1.0.0-rc.1(files are named1.0.0rc1) could never publish.assert. Python skipsassertunderpython -OorPYTHONOPTIMIZE, so every check would pass silently.Changes
pyproject.toml:dynamic = ["version"], read fromcontextmesh.__version__. That constant is now the only place to bump the version, andcontextmesh_mcpre-exports it.setup.py(new): abuild_pyhook that copies the repository-rootGRAPH.mdintocontextmesh/in the wheel. It skips editable installs.MANIFEST.inkeepsGRAPH.mdin the sdist.contextmesh/ontology.pyreads the packaged copy first and falls back to the repository root, which covers source checkouts and editable installs.GRAPH.mdstays at the repository root as the one copy.publish.yml: one post-build step checks release identity against the built wheel's own METADATA instead ofpyproject.toml:Version.is_prerelease;It exits explicitly instead of using
assert.release-candidate.yml: the build job fails unless the wheel containscontextmesh/GRAPH.mdand no otherGRAPH.md. Thecore-wheeljob (Linux and Windows) fails ifcontextmesh.__version__,contextmesh_mcp.__version__and the installed metadata disagree.RELEASE_NOTES.md: anUnreleasedsection describing these fixes.The version stays at
0.1.1. Getting a correct__version__onto PyPI needs a 0.1.2 release, which this PR does not cut.Verification
python -m unittest discover -s testsfrom the checkout: 989 tests, OK.ruff check .is clean, andops/leak-check.sh origin/mainreports clean.A wheel built from a clean checkout contains only
contextmesh/GRAPH.md. Installed in a fresh venv, all three version strings are0.1.1, the ontology loads from inside the package, there is no loosesite-packages/GRAPH.md, the MCP schema resource reads the file, andcontextmesh --helpworks.With
pip install -e ., the versions agree, the ontology reads the rootGRAPH.md, and no copy is written into the package.I ran the publish identity script, extracted from the YAML, against real builds:
v0.1.1v0.1.1v0.1.2v0.1.2underPYTHONOPTIMIZE=2vtagv1.0.0-rc.1v1.0.0-rc.1The new release-candidate checks fail against the old 0.1.1 wheel layout (top-level
GRAPH.md) and the old installed versions (0.1.0against0.1.1), and pass on the new build.Note: a checkout that still has the old, git-ignored
contextmesh_graph.egg-info/can carry the stalecontextmesh/../GRAPH.mdentry into a local build. Delete it before building locally. CI starts from a fresh checkout, and the new wheel-layout check catches it if it ever happens.Not in this PR
These are left for separate decisions:
contextmeshPyPI package;publish.yml;🤖 Generated with Claude Code
Generated by Claude Code